Remove class VAbstractDetail.
--HG-- branch : feature
This commit is contained in:
parent
10a13a499d
commit
fb86e6c51f
|
@ -1,855 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
**
|
|
||||||
** @file vabstractdetail.cpp
|
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** @date 2 1, 2015
|
|
||||||
**
|
|
||||||
** @brief
|
|
||||||
** @copyright
|
|
||||||
** This source code is part of the Valentine project, a pattern making
|
|
||||||
** program, whose allow create and modeling patterns of clothing.
|
|
||||||
** Copyright (C) 2013-2015 Valentina project
|
|
||||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
||||||
**
|
|
||||||
** Valentina is free software: you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Valentina is distributed in the hope that it will be useful,
|
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
** GNU General Public License for more details.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#include "vabstractdetail.h"
|
|
||||||
|
|
||||||
#include <QLine>
|
|
||||||
#include <QLineF>
|
|
||||||
#include <QMessageLogger>
|
|
||||||
#include <QPainterPath>
|
|
||||||
#include <QPoint>
|
|
||||||
#include <QPointF>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
#include "../vgeometry/vgobject.h"
|
|
||||||
#include "vabstractdetail_p.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief VAbstractDetail default contructor. Create empty detail.
|
|
||||||
*/
|
|
||||||
VAbstractDetail::VAbstractDetail()
|
|
||||||
:d(new VAbstractDetailData)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief VAbstractDetail constructor.
|
|
||||||
* @param name detail name.
|
|
||||||
*/
|
|
||||||
VAbstractDetail::VAbstractDetail(const QString &name)
|
|
||||||
:d(new VAbstractDetailData(name))
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief VAbstractDetail copy constructor.
|
|
||||||
* @param detail detail.
|
|
||||||
*/
|
|
||||||
VAbstractDetail::VAbstractDetail(const VAbstractDetail &detail)
|
|
||||||
:d (detail.d)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief operator = assignment operator.
|
|
||||||
* @param detail detail.
|
|
||||||
* @return new detail.
|
|
||||||
*/
|
|
||||||
VAbstractDetail &VAbstractDetail::operator=(const VAbstractDetail &detail)
|
|
||||||
{
|
|
||||||
if ( &detail == this )
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
d = detail.d;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VAbstractDetail::~VAbstractDetail()
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief Clear detail full clear.
|
|
||||||
*/
|
|
||||||
void VAbstractDetail::Clear()
|
|
||||||
{
|
|
||||||
d->name.clear();
|
|
||||||
d->seamAllowance = false;
|
|
||||||
d->closed = true;
|
|
||||||
d->width = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief getName return detail name.
|
|
||||||
* @return name.
|
|
||||||
*/
|
|
||||||
QString VAbstractDetail::getName() const
|
|
||||||
{
|
|
||||||
return d->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setName set detail name.
|
|
||||||
* @param value new name.
|
|
||||||
*/
|
|
||||||
void VAbstractDetail::setName(const QString &value)
|
|
||||||
{
|
|
||||||
d->name = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief getSeamAllowance keep status for seam allowance detail.
|
|
||||||
* @return true - need seam allowance, false - no need seam allowance.
|
|
||||||
*/
|
|
||||||
bool VAbstractDetail::getSeamAllowance() const
|
|
||||||
{
|
|
||||||
return d->seamAllowance;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setSeamAllowance set status for seam allowance detail.
|
|
||||||
* @param value true - need seam allowance, false - no need seam allowance.
|
|
||||||
*/
|
|
||||||
void VAbstractDetail::setSeamAllowance(bool value)
|
|
||||||
{
|
|
||||||
d->seamAllowance = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief getClosed keep close status for detail equdistant.
|
|
||||||
* @return true - close equdistant, false - don't close equdistant.
|
|
||||||
*/
|
|
||||||
bool VAbstractDetail::getClosed() const
|
|
||||||
{
|
|
||||||
return d->closed;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setClosed set close status for detail equdistant.
|
|
||||||
* @param value true - close equdistant, false - don't close equdistant.
|
|
||||||
*/
|
|
||||||
void VAbstractDetail::setClosed(bool value)
|
|
||||||
{
|
|
||||||
d->closed = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief getWidth return value detail seam allowance.
|
|
||||||
* @return value in mm.
|
|
||||||
*/
|
|
||||||
qreal VAbstractDetail::getWidth() const
|
|
||||||
{
|
|
||||||
return d->width;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setWidth set value detail seam allowance.
|
|
||||||
* @param value width in mm.
|
|
||||||
*/
|
|
||||||
void VAbstractDetail::setWidth(const qreal &value)
|
|
||||||
{
|
|
||||||
d->width = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool VAbstractDetail::getForbidFlipping() const
|
|
||||||
{
|
|
||||||
return d->forbidFlipping;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VAbstractDetail::setForbidFlipping(bool value)
|
|
||||||
{
|
|
||||||
d->forbidFlipping = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<QPointF> VAbstractDetail::Equidistant(const QVector<QPointF> &points, const EquidistantType &eqv, qreal width)
|
|
||||||
{
|
|
||||||
QVector<QPointF> ekvPoints;
|
|
||||||
|
|
||||||
if (width <= 0)
|
|
||||||
{
|
|
||||||
qDebug()<<"Width <= 0.";
|
|
||||||
return QVector<QPointF>();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QPointF> p = CorrectEquidistantPoints(points);
|
|
||||||
if ( p.size() < 3 )
|
|
||||||
{
|
|
||||||
qDebug()<<"Not enough points for building the equidistant.";
|
|
||||||
return QVector<QPointF>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eqv == EquidistantType::CloseEquidistant)
|
|
||||||
{
|
|
||||||
p.append(p.at(0));
|
|
||||||
}
|
|
||||||
for (qint32 i = 0; i < p.size(); ++i )
|
|
||||||
{
|
|
||||||
if ( i == 0 && eqv == EquidistantType::CloseEquidistant)
|
|
||||||
{//first point, polyline closed
|
|
||||||
ekvPoints<<EkvPoint(QLineF(p.at(p.size()-2), p.at(p.size()-1)), QLineF(p.at(1), p.at(0)), width);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (i == 0 && eqv == EquidistantType::OpenEquidistant)
|
|
||||||
{//first point, polyline doesn't closed
|
|
||||||
ekvPoints.append(UnclosedEkvPoint(QLineF(p.at(0), p.at(1)), QLineF(p.at(0), p.at(p.size()-1)), width));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (i == p.size()-1 && eqv == EquidistantType::CloseEquidistant)
|
|
||||||
{//last point, polyline closed
|
|
||||||
if (not ekvPoints.isEmpty())
|
|
||||||
{
|
|
||||||
ekvPoints.append(ekvPoints.at(0));
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (i == p.size()-1 && eqv == EquidistantType::OpenEquidistant)
|
|
||||||
{//last point, polyline doesn't closed
|
|
||||||
ekvPoints.append(UnclosedEkvPoint(QLineF(p.at(p.size()-2), p.at(p.size()-1)),
|
|
||||||
QLineF(p.at(0), p.at(p.size()-1)), width));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//points in the middle of polyline
|
|
||||||
ekvPoints<<EkvPoint(QLineF(p.at(i-1), p.at(i)), QLineF(p.at(i+1), p.at(i)), width);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool removeFirstAndLast = true;
|
|
||||||
if (eqv == EquidistantType::CloseEquidistant)
|
|
||||||
{
|
|
||||||
removeFirstAndLast = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ekvPoints = CheckLoops(CorrectEquidistantPoints(ekvPoints, removeFirstAndLast));//Result path can contain loops
|
|
||||||
return ekvPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<QPointF> VAbstractDetail::RemoveDublicates(const QVector<QPointF> &points, bool removeFirstAndLast)
|
|
||||||
{
|
|
||||||
QVector<QPointF> p = points;
|
|
||||||
|
|
||||||
if (removeFirstAndLast)
|
|
||||||
{
|
|
||||||
if (not p.isEmpty() && p.size() > 1)
|
|
||||||
{
|
|
||||||
// Path can't be closed
|
|
||||||
if (p.first() == p.last())
|
|
||||||
{
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
p.remove(p.size() - 1);
|
|
||||||
#else
|
|
||||||
p.removeLast();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < p.size()-1; ++i)
|
|
||||||
{
|
|
||||||
if (p.at(i) == p.at(i+1))
|
|
||||||
{
|
|
||||||
if (not removeFirstAndLast && (i == p.size()-1))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.erase(p.begin() + i + 1);
|
|
||||||
--i;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool VAbstractDetail::CheckIntersection(const QVector<QPointF> &points, int i, int iNext, int j, int jNext,
|
|
||||||
const QPointF &crossPoint)
|
|
||||||
{
|
|
||||||
QVector<QPointF> sub1 = SubPath(points, iNext, j);
|
|
||||||
sub1.append(crossPoint);
|
|
||||||
sub1 = CheckLoops(CorrectEquidistantPoints(sub1, false));
|
|
||||||
const qreal sub1Sum = SumTrapezoids(sub1);
|
|
||||||
|
|
||||||
QVector<QPointF> sub2 = SubPath(points, jNext, i);
|
|
||||||
sub2.append(crossPoint);
|
|
||||||
sub2 = CheckLoops(CorrectEquidistantPoints(sub2, false));
|
|
||||||
const qreal sub2Sum = SumTrapezoids(sub2);
|
|
||||||
|
|
||||||
if (sub1Sum < 0 && sub2Sum < 0)
|
|
||||||
{
|
|
||||||
if (Crossing(sub1, sub2))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (not Crossing(sub1, sub2))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool VAbstractDetail::ParallelCrossPoint(const QLineF &line1, const QLineF &line2, QPointF &point)
|
|
||||||
{
|
|
||||||
const bool l1p1el2p1 = (line1.p1() == line2.p1());
|
|
||||||
const bool l1p2el2p2 = (line1.p2() == line2.p2());
|
|
||||||
const bool l1p1el2p2 = (line1.p1() == line2.p2());
|
|
||||||
const bool l1p2el2p1 = (line1.p2() == line2.p1());
|
|
||||||
|
|
||||||
if (l1p2el2p2 || l1p2el2p1)
|
|
||||||
{
|
|
||||||
point = line1.p2();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (l1p1el2p1 || l1p1el2p2)
|
|
||||||
{
|
|
||||||
point = line1.p1();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
point = QPointF();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool VAbstractDetail::Crossing(const QVector<QPointF> &sub1, const QVector<QPointF> &sub2)
|
|
||||||
{
|
|
||||||
if (sub1.isEmpty() || sub2.isEmpty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QRectF sub1Rect = QPolygonF(sub1).boundingRect();
|
|
||||||
const QRectF sub2Rect = QPolygonF(sub2).boundingRect();
|
|
||||||
if (not sub1Rect.intersects(sub2Rect))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPainterPath sub1Path;
|
|
||||||
sub1Path.setFillRule(Qt::WindingFill);
|
|
||||||
sub1Path.moveTo(sub1.at(0));
|
|
||||||
for (qint32 i = 1; i < sub1.count(); ++i)
|
|
||||||
{
|
|
||||||
sub1Path.lineTo(sub1.at(i));
|
|
||||||
}
|
|
||||||
sub1Path.lineTo(sub1.at(0));
|
|
||||||
|
|
||||||
QPainterPath sub2Path;
|
|
||||||
sub2Path.setFillRule(Qt::WindingFill);
|
|
||||||
sub2Path.moveTo(sub2.at(0));
|
|
||||||
for (qint32 i = 1; i < sub2.count(); ++i)
|
|
||||||
{
|
|
||||||
sub2Path.lineTo(sub2.at(i));
|
|
||||||
}
|
|
||||||
sub2Path.lineTo(sub2.at(0));
|
|
||||||
|
|
||||||
if (not sub1Path.intersects(sub2Path))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<QPointF> VAbstractDetail::SubPath(const QVector<QPointF> &path, int startIndex, int endIndex)
|
|
||||||
{
|
|
||||||
if (path.isEmpty()
|
|
||||||
|| startIndex < 0 || startIndex >= path.size()
|
|
||||||
|| endIndex < 0 || endIndex >= path.size()
|
|
||||||
|| startIndex == endIndex)
|
|
||||||
{
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QPointF> subPath;
|
|
||||||
int i = startIndex - 1;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
++i;
|
|
||||||
if (i >= path.size())
|
|
||||||
{
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
subPath.append(path.at(i));
|
|
||||||
} while (i != endIndex);
|
|
||||||
|
|
||||||
return subPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief CorrectEquidistantPoints clear equivalent points and remove point on line from equdistant.
|
|
||||||
* @param points list of points equdistant.
|
|
||||||
* @return corrected list.
|
|
||||||
*/
|
|
||||||
QVector<QPointF> VAbstractDetail::CorrectEquidistantPoints(const QVector<QPointF> &points, bool removeFirstAndLast)
|
|
||||||
{
|
|
||||||
if (points.size()<4)//Better don't check if only three points. We can destroy equidistant.
|
|
||||||
{
|
|
||||||
qDebug()<<"Only three points.";
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear equivalent points
|
|
||||||
QVector<QPointF> buf1 = RemoveDublicates(points, removeFirstAndLast);
|
|
||||||
|
|
||||||
if (buf1.size()<3)
|
|
||||||
{
|
|
||||||
return buf1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QPointF> buf2;
|
|
||||||
//Remove point on line
|
|
||||||
for (qint32 i = 0; i < buf1.size(); ++i)
|
|
||||||
{// In this case we alwayse will have bounded intersection, so all is need is to check if point i is on line.
|
|
||||||
// Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem.
|
|
||||||
int prev = i-1;
|
|
||||||
int next = i+1;
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
prev = buf1.size() - 1;
|
|
||||||
}
|
|
||||||
else if (i == buf1.size() - 1)
|
|
||||||
{
|
|
||||||
next = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QPointF &iPoint = buf1.at(i);
|
|
||||||
const QPointF &prevPoint = buf1.at(prev);
|
|
||||||
const QPointF &nextPoint = buf1.at(next);
|
|
||||||
|
|
||||||
if (not VGObject::IsPointOnLineviaPDP(buf1.at(i), buf1.at(prev), buf1.at(next))
|
|
||||||
&& prevPoint != nextPoint) // not zigzag
|
|
||||||
{
|
|
||||||
buf2.append(buf1.at(i));
|
|
||||||
}
|
|
||||||
else if ((i == 0 || i == buf1.size() - 1) && (iPoint == prevPoint || iPoint == nextPoint))
|
|
||||||
{
|
|
||||||
// If RemoveDublicates does not remove these points it is a valid case.
|
|
||||||
// Case where last point equal first point
|
|
||||||
buf2.append(buf1.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buf2 = RemoveDublicates(buf2, false);
|
|
||||||
|
|
||||||
return buf2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief CheckLoops seek and delete loops in equidistant.
|
|
||||||
* @param points vector of points of equidistant.
|
|
||||||
* @return vector of points of equidistant.
|
|
||||||
*/
|
|
||||||
QVector<QPointF> VAbstractDetail::CheckLoops(const QVector<QPointF> &points)
|
|
||||||
{
|
|
||||||
int count = points.size();
|
|
||||||
/*If we got less than 4 points no need seek loops.*/
|
|
||||||
if (count < 4)
|
|
||||||
{
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool pathClosed = (points.first() == points.last());
|
|
||||||
|
|
||||||
QVector<QPointF> ekvPoints;
|
|
||||||
|
|
||||||
qint32 i, j, jNext = 0;
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
/*Last three points no need check.*/
|
|
||||||
/*Triangle has not contain loops*/
|
|
||||||
if (i > count-3)
|
|
||||||
{
|
|
||||||
ekvPoints.append(points.at(i));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum LoopIntersectType { NoIntersection, BoundedIntersection, ParallelIntersection };
|
|
||||||
|
|
||||||
QPointF crosPoint;
|
|
||||||
LoopIntersectType status = NoIntersection;
|
|
||||||
const QLineF line1(points.at(i), points.at(i+1));
|
|
||||||
// Because a path can contains several loops we will seek the last and only then remove the loop(s)
|
|
||||||
// That's why we parse from the end
|
|
||||||
for (j = count-1; j >= i+2; --j)
|
|
||||||
{
|
|
||||||
j == count-1 ? jNext = 0 : jNext = j+1;
|
|
||||||
QLineF line2(points.at(j), points.at(jNext));
|
|
||||||
|
|
||||||
if(qFuzzyIsNull(line2.length()))
|
|
||||||
{//If a path is closed the edge (count-1;0) length will be 0
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<qint32> uniqueVertices;
|
|
||||||
uniqueVertices << i << i+1 << j;
|
|
||||||
|
|
||||||
// For closed path last point is equal to first. Using index of the first.
|
|
||||||
pathClosed && jNext == count-1 ? uniqueVertices << 0 : uniqueVertices << jNext;
|
|
||||||
|
|
||||||
const QLineF::IntersectType intersect = line1.intersect(line2, &crosPoint);
|
|
||||||
if (intersect == QLineF::NoIntersection)
|
|
||||||
{ // According to the documentation QLineF::NoIntersection indicates that the lines do not intersect;
|
|
||||||
// i.e. they are parallel. But parallel also mean they can be on the same line.
|
|
||||||
// Method IsPointOnLineviaPDP will check it.
|
|
||||||
if (VGObject::IsPointOnLineviaPDP(points.at(j), points.at(i), points.at(i+1))
|
|
||||||
// Lines are not neighbors
|
|
||||||
&& uniqueVertices.size() == 4)
|
|
||||||
{
|
|
||||||
// Left to catch case where segments are on the same line, but do not have real intersections.
|
|
||||||
QLineF tmpLine1 = line1;
|
|
||||||
QLineF tmpLine2 = line2;
|
|
||||||
|
|
||||||
tmpLine1.setAngle(tmpLine1.angle()+90);
|
|
||||||
|
|
||||||
QPointF tmpCrosPoint;
|
|
||||||
const QLineF::IntersectType tmpIntrs1 = tmpLine1.intersect(tmpLine2, &tmpCrosPoint);
|
|
||||||
|
|
||||||
tmpLine1 = line1;
|
|
||||||
tmpLine2.setAngle(tmpLine2.angle()+90);
|
|
||||||
|
|
||||||
const QLineF::IntersectType tmpIntrs2 = tmpLine1.intersect(tmpLine2, &tmpCrosPoint);
|
|
||||||
|
|
||||||
if (tmpIntrs1 == QLineF::BoundedIntersection || tmpIntrs2 == QLineF::BoundedIntersection)
|
|
||||||
{ // Now we really sure that lines are on the same line and have real intersections.
|
|
||||||
QPointF cPoint;
|
|
||||||
const bool caseFlag = ParallelCrossPoint(line1, line2, cPoint);
|
|
||||||
if (not caseFlag || CheckIntersection(points, i, i+1, j, jNext, cPoint))
|
|
||||||
{
|
|
||||||
status = ParallelIntersection;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (intersect == QLineF::BoundedIntersection)
|
|
||||||
{
|
|
||||||
if (uniqueVertices.size() == 4)
|
|
||||||
{ // Break, but not if lines are neighbors
|
|
||||||
if ((line1.p1() != crosPoint
|
|
||||||
&& line1.p2() != crosPoint
|
|
||||||
&& line2.p1() != crosPoint
|
|
||||||
&& line2.p2() != crosPoint) || CheckIntersection(points, i, i+1, j, jNext, crosPoint))
|
|
||||||
{
|
|
||||||
status = BoundedIntersection;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status = NoIntersection;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (status)
|
|
||||||
{
|
|
||||||
case ParallelIntersection:
|
|
||||||
/*We have found a loop.*/
|
|
||||||
ekvPoints.append(points.at(i));
|
|
||||||
ekvPoints.append(points.at(jNext));
|
|
||||||
jNext > j ? i = jNext : i = j; // Skip a loop
|
|
||||||
break;
|
|
||||||
case BoundedIntersection:
|
|
||||||
ekvPoints.append(points.at(i));
|
|
||||||
ekvPoints.append(crosPoint);
|
|
||||||
i = j;
|
|
||||||
break;
|
|
||||||
case NoIntersection:
|
|
||||||
/*We have not found loop.*/
|
|
||||||
ekvPoints.append(points.at(i));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ekvPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief EkvPoint return vector of points of equidistant two lines. Last point of two lines must be equal.
|
|
||||||
* @param line1 first line.
|
|
||||||
* @param line2 second line.
|
|
||||||
* @param width width of equidistant.
|
|
||||||
* @return vector of points.
|
|
||||||
*/
|
|
||||||
QVector<QPointF> VAbstractDetail::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)
|
|
||||||
{
|
|
||||||
if (width <= 0)
|
|
||||||
{
|
|
||||||
return QVector<QPointF>();
|
|
||||||
}
|
|
||||||
QVector<QPointF> points;
|
|
||||||
if (line1.p2() != line2.p2())
|
|
||||||
{
|
|
||||||
qDebug()<<"Last points of two lines must be equal.";
|
|
||||||
return QVector<QPointF>();
|
|
||||||
}
|
|
||||||
QPointF CrosPoint;
|
|
||||||
const QLineF bigLine1 = ParallelLine(line1, width );
|
|
||||||
const QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width );
|
|
||||||
QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint );
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case (QLineF::BoundedIntersection):
|
|
||||||
points.append(CrosPoint);
|
|
||||||
return points;
|
|
||||||
break;
|
|
||||||
case (QLineF::UnboundedIntersection):
|
|
||||||
{
|
|
||||||
QLineF line( line1.p2(), CrosPoint );
|
|
||||||
|
|
||||||
const int angle1 = BisectorAngle(line1.p1(), line1.p2(), line2.p1());
|
|
||||||
const int angle2 = BisectorAngle(bigLine1.p1(), CrosPoint, bigLine2.p2());
|
|
||||||
|
|
||||||
if (angle1 == angle2)
|
|
||||||
{//Regular equdistant case
|
|
||||||
const qreal length = line.length();
|
|
||||||
if (length > width*2.4)
|
|
||||||
{ // Cutting too long a cut angle
|
|
||||||
line.setLength(width); // Not sure about width value here
|
|
||||||
QLineF cutLine(line.p2(), CrosPoint); // Cut line is a perpendicular
|
|
||||||
cutLine.setLength(length); // Decided take this length
|
|
||||||
|
|
||||||
// We do not check intersection type because intersection must alwayse exist
|
|
||||||
QPointF px;
|
|
||||||
cutLine.setAngle(cutLine.angle()+90);
|
|
||||||
QLineF::IntersectType type = bigLine1.intersect( cutLine, &px );
|
|
||||||
if (type == QLineF::NoIntersection)
|
|
||||||
{
|
|
||||||
qDebug()<<"Couldn't find intersection with cut line.";
|
|
||||||
}
|
|
||||||
points.append(px);
|
|
||||||
|
|
||||||
cutLine.setAngle(cutLine.angle()-180);
|
|
||||||
type = bigLine2.intersect( cutLine, &px );
|
|
||||||
if (type == QLineF::NoIntersection)
|
|
||||||
{
|
|
||||||
qDebug()<<"Couldn't find intersection with cut line.";
|
|
||||||
}
|
|
||||||
points.append(px);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
points.append(CrosPoint);
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{// Dart. Create a loop.
|
|
||||||
points.append(bigLine1.p2());
|
|
||||||
points.append(bigLine2.p1());
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case (QLineF::NoIntersection):
|
|
||||||
/*If we have correct lines this means lines lie on a line.*/
|
|
||||||
points.append(bigLine1.p2());
|
|
||||||
return points;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief UnclosedEkvPoint helps find point of an unclosed seam allowance. One side of two lines should be equal.
|
|
||||||
*
|
|
||||||
* In case of the first seam allowance point equal should be the first point of the two lines. In case the last point -
|
|
||||||
* the last point of the two lines.
|
|
||||||
*
|
|
||||||
* @param line line of a seam allowance
|
|
||||||
* @param helpLine help line of the main path that cut unclosed seam allowance
|
|
||||||
* @param width seam allowance width
|
|
||||||
* @return seam allowance point
|
|
||||||
*/
|
|
||||||
QPointF VAbstractDetail::UnclosedEkvPoint(const QLineF &line, const QLineF &helpLine, const qreal &width)
|
|
||||||
{
|
|
||||||
if (width <= 0)
|
|
||||||
{
|
|
||||||
return QPointF();
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool firstPoint = line.p1() == helpLine.p1();
|
|
||||||
if (not (line.p2() == helpLine.p2() || firstPoint))
|
|
||||||
{
|
|
||||||
qDebug()<<"Two points of two lines must be equal.";
|
|
||||||
return QPointF();
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF CrosPoint;
|
|
||||||
const QLineF bigLine = ParallelLine(line, width );
|
|
||||||
QLineF::IntersectType type = bigLine.intersect( helpLine, &CrosPoint );
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case (QLineF::BoundedIntersection):
|
|
||||||
return CrosPoint;
|
|
||||||
break;
|
|
||||||
case (QLineF::UnboundedIntersection):
|
|
||||||
{
|
|
||||||
// This case is very tricky.
|
|
||||||
// User can create very wrong path that will create crospoint far from main path.
|
|
||||||
// Such an annomaly we try to catch and fix.
|
|
||||||
// If don't do this the program will crash.
|
|
||||||
QLineF test;
|
|
||||||
firstPoint ? test = QLineF(line.p1(), CrosPoint) : test = QLineF(line.p2(), CrosPoint);
|
|
||||||
const qreal length = test.length();
|
|
||||||
if (length > width*2.4)
|
|
||||||
{
|
|
||||||
test.setLength(width);
|
|
||||||
return test.p2();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return CrosPoint;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case (QLineF::NoIntersection):
|
|
||||||
/*If we have correct lines this means lines lie on a line.*/
|
|
||||||
if (firstPoint)
|
|
||||||
{
|
|
||||||
return bigLine.p1();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return bigLine.p2();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QPointF();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ParallelLine create parallel line.
|
|
||||||
* @param line starting line.
|
|
||||||
* @param width width to parallel line.
|
|
||||||
* @return parallel line.
|
|
||||||
*/
|
|
||||||
QLineF VAbstractDetail::ParallelLine(const QLineF &line, qreal width)
|
|
||||||
{
|
|
||||||
QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), SingleParallelPoint(QLineF(line.p2(), line.p1()),
|
|
||||||
-90, width));
|
|
||||||
return paralel;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SingleParallelPoint return point of parallel line.
|
|
||||||
* @param line starting line.
|
|
||||||
* @param angle angle in degree.
|
|
||||||
* @param width width to parallel line.
|
|
||||||
* @return point of parallel line.
|
|
||||||
*/
|
|
||||||
QPointF VAbstractDetail::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width)
|
|
||||||
{
|
|
||||||
QLineF pLine = line;
|
|
||||||
pLine.setAngle( pLine.angle() + angle );
|
|
||||||
pLine.setLength( width );
|
|
||||||
return pLine.p2();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
int VAbstractDetail::BisectorAngle(const QPointF &p1, const QPointF &p2, const QPointF &p3)
|
|
||||||
{
|
|
||||||
QLineF line1(p2, p1);
|
|
||||||
QLineF line2(p2, p3);
|
|
||||||
QLineF bLine;
|
|
||||||
|
|
||||||
const qreal angle1 = line1.angleTo(line2);
|
|
||||||
const qreal angle2 = line2.angleTo(line1);
|
|
||||||
|
|
||||||
if (angle1 <= angle2)
|
|
||||||
{
|
|
||||||
bLine = line1;
|
|
||||||
bLine.setAngle(bLine.angle() + angle1/2.0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bLine = line2;
|
|
||||||
bLine.setAngle(bLine.angle() + angle2/2.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return qRound(bLine.angle());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
qreal VAbstractDetail::SumTrapezoids(const QVector<QPointF> &points)
|
|
||||||
{
|
|
||||||
// Calculation a polygon area through the sum of the areas of trapezoids
|
|
||||||
qreal s, res = 0;
|
|
||||||
const int n = points.size();
|
|
||||||
|
|
||||||
if(n > 2)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < n; ++i)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
s = points.at(i).x()*(points.at(n-1).y() - points.at(i+1).y()); //if i == 0, then y[i-1] replace on y[n-1]
|
|
||||||
res += s;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (i == n-1)
|
|
||||||
{
|
|
||||||
s = points.at(i).x()*(points.at(i-1).y() - points.at(0).y()); // if i == n-1, then y[i+1] replace on y[0]
|
|
||||||
res += s;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = points.at(i).x()*(points.at(i-1).y() - points.at(i+1).y());
|
|
||||||
res += s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
|
@ -1,98 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
**
|
|
||||||
** @file vabstractdetail.h
|
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** @date 2 1, 2015
|
|
||||||
**
|
|
||||||
** @brief
|
|
||||||
** @copyright
|
|
||||||
** This source code is part of the Valentine project, a pattern making
|
|
||||||
** program, whose allow create and modeling patterns of clothing.
|
|
||||||
** Copyright (C) 2013-2015 Valentina project
|
|
||||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
||||||
**
|
|
||||||
** Valentina is free software: you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Valentina is distributed in the hope that it will be useful,
|
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
** GNU General Public License for more details.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#ifndef VABSTRACTDETAIL_H
|
|
||||||
#define VABSTRACTDETAIL_H
|
|
||||||
|
|
||||||
#include <QSharedDataPointer>
|
|
||||||
#include <QTypeInfo>
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "vlayoutdef.h"
|
|
||||||
|
|
||||||
class QLineF;
|
|
||||||
class QPointF;
|
|
||||||
class QString;
|
|
||||||
class VAbstractDetailData;
|
|
||||||
template <typename T> class QVector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The VAbstractDetail class abstract class for all details.
|
|
||||||
*/
|
|
||||||
class VAbstractDetail
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VAbstractDetail();
|
|
||||||
explicit VAbstractDetail(const QString &name);
|
|
||||||
VAbstractDetail(const VAbstractDetail &detail);
|
|
||||||
VAbstractDetail &operator=(const VAbstractDetail &detail);
|
|
||||||
virtual ~VAbstractDetail();
|
|
||||||
|
|
||||||
void Clear();
|
|
||||||
|
|
||||||
QString getName() const;
|
|
||||||
void setName(const QString &value);
|
|
||||||
|
|
||||||
bool getSeamAllowance() const;
|
|
||||||
void setSeamAllowance(bool value);
|
|
||||||
|
|
||||||
bool getClosed() const;
|
|
||||||
void setClosed(bool value);
|
|
||||||
|
|
||||||
qreal getWidth() const;
|
|
||||||
void setWidth(const qreal &value);
|
|
||||||
|
|
||||||
bool getForbidFlipping() const;
|
|
||||||
void setForbidFlipping(bool value);
|
|
||||||
|
|
||||||
static QVector<QPointF> Equidistant(const QVector<QPointF> &points, const EquidistantType &eqv, qreal width);
|
|
||||||
static qreal SumTrapezoids(const QVector<QPointF> &points);
|
|
||||||
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
|
|
||||||
static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points, bool removeFirstAndLast = true);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static QVector<QPointF> RemoveDublicates(const QVector<QPointF> &points, bool removeFirstAndLast = true);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QSharedDataPointer<VAbstractDetailData> d;
|
|
||||||
|
|
||||||
static bool CheckIntersection(const QVector<QPointF> &points, int i, int iNext, int j, int jNext,
|
|
||||||
const QPointF &crossPoint);
|
|
||||||
static bool ParallelCrossPoint(const QLineF &line1, const QLineF &line2, QPointF &point);
|
|
||||||
static bool Crossing(const QVector<QPointF> &sub1, const QVector<QPointF> &sub2);
|
|
||||||
static QVector<QPointF> SubPath(const QVector<QPointF> &path, int startIndex, int endIndex);
|
|
||||||
static QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width);
|
|
||||||
static QPointF UnclosedEkvPoint(const QLineF &line, const QLineF &helpLine, const qreal &width);
|
|
||||||
static QLineF ParallelLine(const QLineF &line, qreal width );
|
|
||||||
static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width);
|
|
||||||
static int BisectorAngle(const QPointF &p1, const QPointF &p2, const QPointF &p3);
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(VAbstractDetail, Q_MOVABLE_TYPE);
|
|
||||||
|
|
||||||
#endif // VABSTRACTDETAIL_H
|
|
|
@ -1,75 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
**
|
|
||||||
** @file vabstractdetail_p.h
|
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** @date 2 1, 2015
|
|
||||||
**
|
|
||||||
** @brief
|
|
||||||
** @copyright
|
|
||||||
** This source code is part of the Valentine project, a pattern making
|
|
||||||
** program, whose allow create and modeling patterns of clothing.
|
|
||||||
** Copyright (C) 2013-2015 Valentina project
|
|
||||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
||||||
**
|
|
||||||
** Valentina is free software: you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Valentina is distributed in the hope that it will be useful,
|
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
** GNU General Public License for more details.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#ifndef VABSTRACTDETAIL_P_H
|
|
||||||
#define VABSTRACTDETAIL_P_H
|
|
||||||
|
|
||||||
#include <QSharedData>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include "../vmisc/diagnostic.h"
|
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
|
||||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
|
||||||
|
|
||||||
class VAbstractDetailData : public QSharedData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VAbstractDetailData()
|
|
||||||
:name(QString()), seamAllowance(false), closed(true), width(0), forbidFlipping(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
explicit VAbstractDetailData(const QString &name)
|
|
||||||
:name(name), seamAllowance(false), closed(true), width(0), forbidFlipping(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
VAbstractDetailData(const VAbstractDetailData &detail)
|
|
||||||
:QSharedData(detail), name(detail.name), seamAllowance(detail.seamAllowance), closed(detail.closed),
|
|
||||||
width(detail.width), forbidFlipping(detail.forbidFlipping)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~VAbstractDetailData() {}
|
|
||||||
|
|
||||||
/** @brief name detail name. */
|
|
||||||
QString name;
|
|
||||||
/** @brief seamAllowance status seamAllowance detail. */
|
|
||||||
bool seamAllowance;
|
|
||||||
/** @brief closed status equdistant detail. */
|
|
||||||
bool closed;
|
|
||||||
/** @brief width value seamAllowance in mm. */
|
|
||||||
qreal width;
|
|
||||||
/** @brief forbidFlipping forbid piece be mirrored in a layout. */
|
|
||||||
bool forbidFlipping;
|
|
||||||
|
|
||||||
private:
|
|
||||||
VAbstractDetailData &operator=(const VAbstractDetailData &) Q_DECL_EQ_DELETE;
|
|
||||||
};
|
|
||||||
|
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
#endif // VABSTRACTDETAIL_P_H
|
|
|
@ -4,8 +4,6 @@
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/stable.h \
|
$$PWD/stable.h \
|
||||||
$$PWD/vlayoutgenerator.h \
|
$$PWD/vlayoutgenerator.h \
|
||||||
$$PWD/vabstractdetail.h \
|
|
||||||
$$PWD/vabstractdetail_p.h \
|
|
||||||
$$PWD/vlayoutdef.h \
|
$$PWD/vlayoutdef.h \
|
||||||
$$PWD/vlayoutpaper.h \
|
$$PWD/vlayoutpaper.h \
|
||||||
$$PWD/vlayoutpaper_p.h \
|
$$PWD/vlayoutpaper_p.h \
|
||||||
|
@ -24,7 +22,6 @@ HEADERS += \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vlayoutgenerator.cpp \
|
$$PWD/vlayoutgenerator.cpp \
|
||||||
$$PWD/vabstractdetail.cpp \
|
|
||||||
$$PWD/vlayoutpaper.cpp \
|
$$PWD/vlayoutpaper.cpp \
|
||||||
$$PWD/vbank.cpp \
|
$$PWD/vbank.cpp \
|
||||||
$$PWD/vcontour.cpp \
|
$$PWD/vcontour.cpp \
|
||||||
|
|
|
@ -36,7 +36,6 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qttestmainlambda.cpp \
|
qttestmainlambda.cpp \
|
||||||
tst_vposter.cpp \
|
tst_vposter.cpp \
|
||||||
tst_vabstractdetail.cpp \
|
|
||||||
tst_vspline.cpp \
|
tst_vspline.cpp \
|
||||||
tst_nameregexp.cpp \
|
tst_nameregexp.cpp \
|
||||||
tst_vlayoutdetail.cpp \
|
tst_vlayoutdetail.cpp \
|
||||||
|
@ -62,7 +61,6 @@ win32-msvc*:SOURCES += stable.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
tst_vposter.h \
|
tst_vposter.h \
|
||||||
tst_vabstractdetail.h \
|
|
||||||
tst_vspline.h \
|
tst_vspline.h \
|
||||||
tst_nameregexp.h \
|
tst_nameregexp.h \
|
||||||
tst_vlayoutdetail.h \
|
tst_vlayoutdetail.h \
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
#include "tst_vposter.h"
|
#include "tst_vposter.h"
|
||||||
#include "tst_vabstractdetail.h"
|
|
||||||
#include "tst_vabstractpiece.h"
|
#include "tst_vabstractpiece.h"
|
||||||
#include "tst_vspline.h"
|
#include "tst_vspline.h"
|
||||||
#include "tst_nameregexp.h"
|
#include "tst_nameregexp.h"
|
||||||
|
@ -70,7 +69,6 @@ int main(int argc, char** argv)
|
||||||
ASSERT_TEST(new TST_FindPoint());
|
ASSERT_TEST(new TST_FindPoint());
|
||||||
ASSERT_TEST(new TST_VDetail());
|
ASSERT_TEST(new TST_VDetail());
|
||||||
ASSERT_TEST(new TST_VPoster());
|
ASSERT_TEST(new TST_VPoster());
|
||||||
//ASSERT_TEST(new TST_VAbstractDetail());
|
|
||||||
ASSERT_TEST(new TST_VAbstractPiece());
|
ASSERT_TEST(new TST_VAbstractPiece());
|
||||||
ASSERT_TEST(new TST_VSpline());
|
ASSERT_TEST(new TST_VSpline());
|
||||||
ASSERT_TEST(new TST_VSplinePath());
|
ASSERT_TEST(new TST_VSplinePath());
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,87 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
**
|
|
||||||
** @file tst_vabstractdetail.h
|
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** @date 16 4, 2015
|
|
||||||
**
|
|
||||||
** @brief
|
|
||||||
** @copyright
|
|
||||||
** This source code is part of the Valentine project, a pattern making
|
|
||||||
** program, whose allow create and modeling patterns of clothing.
|
|
||||||
** Copyright (C) 2015 Valentina project
|
|
||||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
||||||
**
|
|
||||||
** Valentina is free software: you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Valentina is distributed in the hope that it will be useful,
|
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
** GNU General Public License for more details.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TST_VABSTRACTDETAIL_H
|
|
||||||
#define TST_VABSTRACTDETAIL_H
|
|
||||||
|
|
||||||
#include "../vmisc/abstracttest.h"
|
|
||||||
|
|
||||||
class TST_VAbstractDetail : public AbstractTest
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit TST_VAbstractDetail(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void EquidistantRemoveLoop_data();
|
|
||||||
void EquidistantRemoveLoop() const;
|
|
||||||
void SumTrapezoids() const;
|
|
||||||
void PathRemoveLoop_data() const;
|
|
||||||
void PathRemoveLoop() const;
|
|
||||||
void PathLoopsCase_data() const;
|
|
||||||
void PathLoopsCase() const;
|
|
||||||
void BrokenDetailEquidistant_data() const;
|
|
||||||
void BrokenDetailEquidistant() const;
|
|
||||||
void CorrectEquidistantPoints_data() const;
|
|
||||||
void CorrectEquidistantPoints() const;
|
|
||||||
void TestCorrectEquidistantPoints_data();
|
|
||||||
void TestCorrectEquidistantPoints() const;
|
|
||||||
#ifndef Q_OS_WIN
|
|
||||||
void PossibleInfiniteClearLoops_data() const;
|
|
||||||
void PossibleInfiniteClearLoops() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Case3() const;
|
|
||||||
void Case4() const;
|
|
||||||
void Case5() const;
|
|
||||||
|
|
||||||
QVector<QPointF> InputPointsIssue298Case1() const;
|
|
||||||
QVector<QPointF> OutputPointsIssue298Case1() const;
|
|
||||||
|
|
||||||
QVector<QPointF> InputPointsIssue298Case2() const;
|
|
||||||
QVector<QPointF> OutputPointsIssue298Case2() const;
|
|
||||||
|
|
||||||
QVector<QPointF> InputPointsIssue548Case1() const;
|
|
||||||
QVector<QPointF> OutputPointsIssue548Case1() const;
|
|
||||||
|
|
||||||
QVector<QPointF> InputPointsIssue548Case2() const;
|
|
||||||
QVector<QPointF> OutputPointsIssue548Case2() const;
|
|
||||||
|
|
||||||
QVector<QPointF> InputPointsIssue548Case3() const;
|
|
||||||
QVector<QPointF> OutputPointsIssue548Case3() const;
|
|
||||||
|
|
||||||
QVector<QPointF> InputPointsCase3() const;
|
|
||||||
QVector<QPointF> InputPointsCase4() const;
|
|
||||||
QVector<QPointF> InputPointsCase5() const;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TST_VABSTRACTDETAIL_H
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,6 +42,22 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void EquidistantRemoveLoop_data();
|
void EquidistantRemoveLoop_data();
|
||||||
void EquidistantRemoveLoop() const;
|
void EquidistantRemoveLoop() const;
|
||||||
|
void SumTrapezoids() const;
|
||||||
|
void PathRemoveLoop_data() const;
|
||||||
|
void PathRemoveLoop() const;
|
||||||
|
void PathLoopsCase_data() const;
|
||||||
|
void PathLoopsCase() const;
|
||||||
|
void BrokenDetailEquidistant_data() const;
|
||||||
|
void BrokenDetailEquidistant() const;
|
||||||
|
void CorrectEquidistantPoints_data() const;
|
||||||
|
void CorrectEquidistantPoints() const;
|
||||||
|
void TestCorrectEquidistantPoints_data();
|
||||||
|
void TestCorrectEquidistantPoints() const;
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
void PossibleInfiniteClearLoops_data() const;
|
||||||
|
void PossibleInfiniteClearLoops() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<VSAPoint> InputPointsCase1() const;
|
QVector<VSAPoint> InputPointsCase1() const;
|
||||||
QVector<QPointF> OutputPointsCase1() const;
|
QVector<QPointF> OutputPointsCase1() const;
|
||||||
|
@ -51,6 +67,29 @@ private:
|
||||||
|
|
||||||
QVector<VSAPoint> InputPointsCase3() const;
|
QVector<VSAPoint> InputPointsCase3() const;
|
||||||
QVector<QPointF> OutputPointsCase3() const;
|
QVector<QPointF> OutputPointsCase3() const;
|
||||||
|
|
||||||
|
void Case3() const;
|
||||||
|
void Case4() const;
|
||||||
|
void Case5() const;
|
||||||
|
|
||||||
|
QVector<QPointF> InputPointsIssue298Case1() const;
|
||||||
|
QVector<QPointF> OutputPointsIssue298Case1() const;
|
||||||
|
|
||||||
|
QVector<QPointF> InputPointsIssue298Case2() const;
|
||||||
|
QVector<QPointF> OutputPointsIssue298Case2() const;
|
||||||
|
|
||||||
|
QVector<QPointF> InputPointsIssue548Case1() const;
|
||||||
|
QVector<QPointF> OutputPointsIssue548Case1() const;
|
||||||
|
|
||||||
|
QVector<QPointF> InputPointsIssue548Case2() const;
|
||||||
|
QVector<QPointF> OutputPointsIssue548Case2() const;
|
||||||
|
|
||||||
|
QVector<QPointF> InputPointsIssue548Case3() const;
|
||||||
|
QVector<QPointF> OutputPointsIssue548Case3() const;
|
||||||
|
|
||||||
|
QVector<QPointF> InputPointsCase3a() const;
|
||||||
|
QVector<QPointF> InputPointsCase4a() const;
|
||||||
|
QVector<QPointF> InputPointsCase5a() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TST_VABSTRACTPIECE_H
|
#endif // TST_VABSTRACTPIECE_H
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "tst_varc.h"
|
#include "tst_varc.h"
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
#include "../vlayout/vabstractdetail.h"
|
#include "../vlayout/vabstractpiece.h"
|
||||||
#include "../vmisc/logging.h"
|
#include "../vmisc/logging.h"
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
@ -203,7 +203,7 @@ void TST_VArc::TestGetPoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculated square
|
// calculated square
|
||||||
const qreal cSquare = qAbs(VAbstractDetail::SumTrapezoids(points)/2.0);
|
const qreal cSquare = qAbs(VAbstractPiece::SumTrapezoids(points)/2.0);
|
||||||
const qreal value = qAbs(gSquere - cSquare);
|
const qreal value = qAbs(gSquere - cSquare);
|
||||||
const QString errorMsg =
|
const QString errorMsg =
|
||||||
QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value);
|
QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "tst_vellipticalarc.h"
|
#include "tst_vellipticalarc.h"
|
||||||
#include "../vgeometry/vellipticalarc.h"
|
#include "../vgeometry/vellipticalarc.h"
|
||||||
#include "../vlayout/vabstractdetail.h"
|
#include "../vlayout/vabstractpiece.h"
|
||||||
#include "../vmisc/logging.h"
|
#include "../vmisc/logging.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
@ -372,7 +372,7 @@ void TST_VEllipticalArc::TestGetPoints3()
|
||||||
{// calculated full ellipse square
|
{// calculated full ellipse square
|
||||||
const qreal ellipseSquare = M_PI * radius1 * radius2;
|
const qreal ellipseSquare = M_PI * radius1 * radius2;
|
||||||
const qreal epsSquare = ellipseSquare * 0.5 / 100; // computing error 0.5 % from origin squere
|
const qreal epsSquare = ellipseSquare * 0.5 / 100; // computing error 0.5 % from origin squere
|
||||||
const qreal arcSquare = qAbs(VAbstractDetail::SumTrapezoids(points)/2.0);
|
const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points)/2.0);
|
||||||
const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
|
const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
|
||||||
const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. "
|
const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. "
|
||||||
"Difference ='%1' bigger than eps = '%2'.").arg(diffSquare).arg(epsSquare);
|
"Difference ='%1' bigger than eps = '%2'.").arg(diffSquare).arg(epsSquare);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user