Refactor CastTo.

This commit is contained in:
Roman Telezhynskyi 2022-10-28 13:55:24 +03:00
parent 0bf3d93d7e
commit 9c7ab2fb4a
22 changed files with 216 additions and 146 deletions

View File

@ -409,7 +409,8 @@ auto VPPiece::StickyPosition(qreal &dx, qreal &dy) const -> bool
return false;
}
QVector<QPointF> path = CastTo<QPointF>(GetMappedExternalContourPoints());
QVector<QPointF> path;
CastTo(GetMappedExternalContourPoints(), path);
QRectF boundingRect = VLayoutPiece::BoundingRect(path);
const qreal stickyDistance = pieceGap+minStickyDistance;
QRectF stickyZone = QRectF(boundingRect.topLeft().x()-stickyDistance, boundingRect.topLeft().y()-stickyDistance,
@ -425,7 +426,8 @@ auto VPPiece::StickyPosition(qreal &dx, qreal &dy) const -> bool
continue;
}
QVector<QPointF> piecePath = CastTo<QPointF>(piece->GetMappedExternalContourPoints());
QVector<QPointF> piecePath;
CastTo(piece->GetMappedExternalContourPoints(), piecePath);
QRectF pieceBoundingRect = VLayoutPiece::BoundingRect(piecePath);
if (stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) ||

View File

@ -507,7 +507,8 @@ void VPSheet::ValidateSuperpositionOfPieces() const
}
const bool oldSuperpositionOfPieces = piece->HasSuperpositionWithPieces();
QVector<QPointF> path1 = CastTo<QPointF>(piece->GetMappedExternalContourPoints());
QVector<QPointF> path1;
CastTo(piece->GetMappedExternalContourPoints(), path1);
bool hasSuperposition = false;
for (const auto &p : pieces)
@ -517,7 +518,8 @@ void VPSheet::ValidateSuperpositionOfPieces() const
continue;
}
QVector<QPointF> path2 = CastTo<QPointF>(p->GetMappedExternalContourPoints());
QVector<QPointF> path2;
CastTo(p->GetMappedExternalContourPoints(), path2);
bool superposition = VPPiece::PathsSuperposition(path1, path2);
if (superposition)

View File

@ -709,7 +709,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos)
QVector<QPointF> path;
if (not p.isNull() && p->StickyPosition(m_stickyTranslateX, m_stickyTranslateY))
{
path = CastTo<QPointF>(p->GetMappedExternalContourPoints());
CastTo(p->GetMappedExternalContourPoints(), path);
QTransform m;
m.translate(m_stickyTranslateX, m_stickyTranslateY);
path = m.map(path);

View File

@ -521,7 +521,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
QVector<QPointF> path;
if (not p.isNull() && p->StickyPosition(m_stickyTranslateX, m_stickyTranslateY))
{
path = CastTo<QPointF>(p->GetMappedExternalContourPoints());
CastTo(p->GetMappedExternalContourPoints(), path);
QTransform m;
m.translate(m_stickyTranslateX, m_stickyTranslateY);
path = m.map(path);

View File

@ -225,7 +225,8 @@ void VLayoutConverter::ConvertPathToV0_1_3(QDomElement &node)
}
RemoveAllChildren(node);
QVector<VLayoutPoint> path = CastTo<VLayoutPoint>(StringV0_1_2ToPath(oldPath));
QVector<VLayoutPoint> path;
CastTo(StringV0_1_2ToPath(oldPath), path);
for (auto &point : path)
{

View File

@ -1122,15 +1122,20 @@ auto VAbstractPiece::Equidistant(QVector<VSAPoint> points, qreal width, const QS
QT_WARNING_POP
}
QVector<VLayoutPoint> cleaned;
// Uncomment for debug
// QVector<VLayoutPoint> cleaned = CastTo<VLayoutPoint>(ekvPoints);
// CastTo(ekvPoints, cleaned);
const bool removeFirstAndLast = false;
ekvPoints = RemoveDublicates(ekvPoints, removeFirstAndLast);
QVector<VLayoutPoint> cleaned = CastTo<VLayoutPoint>(CheckLoops(ekvPoints));//Result path can contain loops
ekvPoints = CheckLoops(ekvPoints);
CastTo(ekvPoints, cleaned);//Result path can contain loops
cleaned = CorrectEquidistantPoints(cleaned, removeFirstAndLast);
cleaned = CorrectPathDistortion(cleaned);
// DumpVector(CastTo<QPointF>(cleaned), QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
// QVector<QPointF> dump;
// CastTo(cleaned, dump);
// DumpVector(dump, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return cleaned;
}
@ -2041,76 +2046,10 @@ auto VAbstractPiece::LabelShapePath(const PlaceLabelImg &shape) -> QPainterPath
if (not p.isEmpty())
{
path.moveTo(ConstFirst<QPointF>(p));
path.addPolygon(CastTo<QPointF>(p));
QVector<QPointF> polygon;
CastTo(p, polygon);
path.addPolygon(polygon);
}
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
auto VAbstractPiece::ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool
{
if (not VFuzzyComparePoints(p1, p2, accuracy))
{
points.append(p2);
return false;
}
if (not points.isEmpty() && p2.TurnPoint())
{
points.last().SetTurnPoint(true);
}
if (not points.isEmpty() && p2.CurvePoint())
{
points.last().SetCurvePoint(true);
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, const QPointF &p1, const QPointF &p2,
qreal accuracy) -> bool
{
if (not VFuzzyComparePoints(p1, p2, accuracy))
{
points.append(p2);
return false;
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
{
if (VFuzzyComparePoints(ConstFirst(points), ConstLast(points), accuracy))
{
const T& l = ConstLast(points);
points.removeLast();
if (not points.isEmpty() && l.TurnPoint())
{
points.last().SetTurnPoint(true);
}
if (not points.isEmpty() && l.CurvePoint())
{
points.last().SetCurvePoint(true);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
template <>
auto VAbstractPiece::CompareFirstAndLastPoints<QPointF>(QVector<QPointF> &points, qreal accuracy) -> void
{
if (VFuzzyComparePoints(ConstFirst(points), ConstLast(points), accuracy))
{
points.removeLast();
}
}

View File

@ -328,6 +328,74 @@ inline auto VAbstractPiece::RemoveDublicates(const QVector<T> &points, bool remo
return p;
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto VAbstractPiece::ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool
{
if (not VFuzzyComparePoints(p1, p2, accuracy))
{
points.append(p2);
return false;
}
if (not points.isEmpty() && p2.TurnPoint())
{
points.last().SetTurnPoint(true);
}
if (not points.isEmpty() && p2.CurvePoint())
{
points.last().SetCurvePoint(true);
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, const QPointF &p1, const QPointF &p2,
qreal accuracy) -> bool
{
if (not VFuzzyComparePoints(p1, p2, accuracy))
{
points.append(p2);
return false;
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
{
const T& l = ConstLast(points);
if (VFuzzyComparePoints(ConstFirst(points), l, accuracy))
{
points.removeLast();
if (not points.isEmpty() && l.TurnPoint())
{
points.last().SetTurnPoint(true);
}
if (not points.isEmpty() && l.CurvePoint())
{
points.last().SetCurvePoint(true);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline auto VAbstractPiece::CompareFirstAndLastPoints<QPointF>(QVector<QPointF> &points, qreal accuracy) -> void
{
if (VFuzzyComparePoints(ConstFirst(points), ConstLast(points), accuracy))
{
points.removeLast();
}
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon, qreal accuracy) -> bool

View File

@ -1198,13 +1198,17 @@ auto VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const -> int
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::MappedDetailBoundingRect() const -> QRectF
{
return BoundingRect(CastTo<QPointF>(GetMappedExternalContourPoints()));
QVector<QPointF> points;
CastTo(GetMappedExternalContourPoints(), points);
return BoundingRect(points);
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::DetailBoundingRect() const -> QRectF
{
return BoundingRect(CastTo<QPointF>(GetExternalContourPoints()));
QVector<QPointF> points;
CastTo(GetExternalContourPoints(), points);
return BoundingRect(points);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1245,24 +1249,30 @@ void VLayoutPiece::SetLayoutAllowancePoints()
{
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
{
d->m_layoutAllowance = CastTo<QPointF>(Equidistant(CastTo<VSAPoint>(GetMappedSeamAllowancePoints()),
d->m_layoutWidth, GetName()));
QVector<VSAPoint> seamAllowancePoints;
CastTo(GetMappedSeamAllowancePoints(), seamAllowancePoints);
CastTo(Equidistant(seamAllowancePoints, d->m_layoutWidth, GetName()), d->m_layoutAllowance);
if (not d->m_layoutAllowance.isEmpty())
{
d->m_layoutAllowance.removeLast();
d->m_square = qFloor(qAbs(SumTrapezoids(CastTo<QPointF>(GetSeamAllowancePoints()))/2.0));
QVector<QPointF> points;
CastTo(GetSeamAllowancePoints(), points);
d->m_square = qFloor(qAbs(SumTrapezoids(points)/2.0));
}
}
else
{
d->m_layoutAllowance = CastTo<QPointF>(Equidistant(CastTo<VSAPoint>(GetMappedContourPoints()),
d->m_layoutWidth, GetName()));
QVector<VSAPoint> seamLinePoints;
CastTo(GetMappedContourPoints(), seamLinePoints);
CastTo(Equidistant(seamLinePoints, d->m_layoutWidth, GetName()), d->m_layoutAllowance);
if (not d->m_layoutAllowance.isEmpty())
{
d->m_layoutAllowance.removeLast();
d->m_square = qFloor(qAbs(SumTrapezoids(CastTo<QPointF>(GetContourPoints()))/2.0));
QVector<QPointF> points;
CastTo(GetContourPoints(), points);
d->m_square = qFloor(qAbs(SumTrapezoids(points)/2.0));
}
}
}
@ -1486,7 +1496,9 @@ auto VLayoutPiece::IsLayoutAllowanceValid() const -> bool
{
QVector<VLayoutPoint> base = (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) ?
d->m_seamAllowance : d->m_contour;
return VAbstractPiece::IsAllowanceValid(CastTo<QPointF>(base), d->m_layoutAllowance);
QVector<QPointF> points;
CastTo(base, points);
return VAbstractPiece::IsAllowanceValid(points, d->m_layoutAllowance);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -197,7 +197,9 @@ inline auto operator>>(QDataStream &dataStream, VLayoutPieceData &piece) -> QDat
{
QVector<QPointF> points;
dataStream >> points;
return CastTo<VLayoutPoint>(points);
QVector<VLayoutPoint> casted;
CastTo(points, casted);
return casted;
};
piece.m_contour = ReadPoints();

View File

@ -100,7 +100,9 @@ QPainterPath VLayoutPiecePath::GetPainterPath() const
QPainterPath path;
if (not d->m_points.isEmpty())
{
path.addPolygon(QPolygonF(CastTo<QPointF>(d->m_points)));
QVector<QPointF> points;
CastTo(d->m_points, points);
path.addPolygon(QPolygonF(points));
path.setFillRule(Qt::WindingFill);
}
return path;

View File

@ -126,7 +126,7 @@ QDataStream& operator>>(QDataStream &dataStream, VLayoutPiecePathData &path)
{
QVector<QPointF> points;
dataStream >> points;
path.m_points = CastTo<VLayoutPoint>(points);
CastTo(points, path.m_points);
}
else
{

View File

@ -67,31 +67,36 @@ Q_DECLARE_TYPEINFO(VLayoutPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto CastTo(const QVector<T> &points) -> QVector<T>
inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
{
return points;
Q_UNUSED(points)
Q_UNUSED(casted)
}
//---------------------------------------------------------------------------------------------------------------------
//upcast
template <class Derived, class Base, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type* = nullptr>
inline auto CastTo(const QVector<Base> &points) -> QVector<Derived>
inline auto CastTo(const QVector<Base> &points, QVector<Derived> &casted) -> void
{
QVector<Derived> castedPoints;
castedPoints.reserve(points.size());
std::transform(points.begin(), points.end(), castedPoints.begin(), [](const Base &p) { return Derived(p); });
return castedPoints;
casted.clear();
casted.reserve(points.size());
for (const auto &p : points)
{
casted.append(Derived(p));
}
}
//---------------------------------------------------------------------------------------------------------------------
//downcast
template <class Base, class Derived, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type* = nullptr>
inline auto CastTo(const QVector<Derived> &points) -> QVector<Base>
inline auto CastTo(const QVector<Derived> &points, QVector<Base> &casted) -> void
{
QVector<Base> castedPoints;
castedPoints.reserve(points.size());
std::transform(points.begin(), points.end(), castedPoints.begin(), [](const Base &p) { return p; });
return castedPoints;
casted.clear();
casted.reserve(points.size());
for (const auto &p : points)
{
casted.append(p);
}
}
/*****************************************************************************

View File

@ -462,9 +462,9 @@ auto VPosition::Crossing(const VLayoutPiece &detail) const -> VPosition::Crossin
const QRectF layoutBoundingRect = VLayoutPiece::BoundingRect(layoutPoints);
const QPainterPath layoutAllowancePath = VAbstractPiece::PainterPath(layoutPoints);
const QVector<QPointF> contourPoints =
CastTo<QPointF>(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints());
QVector<QPointF> contourPoints;
CastTo(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints(), contourPoints);
const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints);
const QPainterPath contourPath = VAbstractPiece::PainterPath(contourPoints);

View File

@ -688,7 +688,7 @@ QVector<QLineF> VPassmark::FullPassmark(const VPiece &piece, const VContainer *d
{
if (m_null)
{
return QVector<QLineF>();
return {};
}
if (not piece.IsSeamAllowanceBuiltIn())
@ -719,16 +719,18 @@ QVector<QLineF> VPassmark::SAPassmark(const VPiece &piece, const VContainer *dat
{
if (m_null)
{
return QVector<QLineF>();
return {};
}
if (not piece.IsSeamAllowanceBuiltIn())
{
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
return SAPassmark(CastTo<QPointF>(piece.SeamAllowancePointsWithRotation(data, m_data.passmarkIndex)), side);
QVector<QPointF> points;
CastTo(piece.SeamAllowancePointsWithRotation(data, m_data.passmarkIndex), points);
return SAPassmark(points, side);
}
return QVector<QLineF>();
return {};
}
//---------------------------------------------------------------------------------------------------------------------
@ -736,7 +738,7 @@ QVector<QLineF> VPassmark::SAPassmark(const QVector<QPointF> &seamAllowance, Pas
{
if (m_null)
{
return QVector<QLineF>();
return {};
}
// Because rollback @seamAllowance must be rotated here.
@ -800,8 +802,9 @@ QVector<QLineF> VPassmark::BuiltInSAPassmark(const VPiece &piece, const VContain
return QVector<QLineF>();
}
return CreatePassmarkLines(m_data.passmarkLineType, m_data.passmarkAngleType, lines,
CastTo<QPointF>(piece.MainPathPoints(data)), PassmarkSide::All);
QVector<QPointF> points;
CastTo(piece.MainPathPoints(data), points);
return CreatePassmarkLines(m_data.passmarkLineType, m_data.passmarkAngleType, lines, points, PassmarkSide::All);
}
//---------------------------------------------------------------------------------------------------------------------
@ -853,7 +856,7 @@ QVector<QLineF> VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.);
edge1.setLength(length);
return QVector<QLineF>({edge1});
return {edge1};
}
//---------------------------------------------------------------------------------------------------------------------
@ -861,17 +864,18 @@ QVector<QLineF> VPassmark::SAPassmarkBaseLine(const VPiece &piece, const VContai
{
if (m_null)
{
return QVector<QLineF>();
return {};
}
if (not piece.IsSeamAllowanceBuiltIn())
{
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
return SAPassmarkBaseLine(CastTo<QPointF>(piece.SeamAllowancePointsWithRotation(data, m_data.passmarkIndex)),
side);
QVector<QPointF> points;
CastTo(piece.SeamAllowancePointsWithRotation(data, m_data.passmarkIndex), points);
return SAPassmarkBaseLine(points, side);
}
return QVector<QLineF>();
return {};
}
//---------------------------------------------------------------------------------------------------------------------
@ -879,7 +883,7 @@ QVector<QLineF> VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowa
{
if (m_null)
{
return QVector<QLineF>();
return {};
}
if (seamAllowance.size() < 2)

View File

@ -208,12 +208,15 @@ QVector<VLayoutPoint> VPiece::SeamAllowancePoints(const VContainer *data) const
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPiece::CuttingPathPoints(const VContainer *data) const
{
QVector<QPointF> points;
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
{
return CastTo<QPointF>(SeamAllowancePoints(data));
CastTo(SeamAllowancePoints(data), points);
return points;
}
return CastTo<QPointF>(MainPathPoints(data));
CastTo(MainPathPoints(data), points);
return points;
}
//---------------------------------------------------------------------------------------------------------------------
@ -269,7 +272,9 @@ QVector<QPainterPath> VPiece::CurvesPainterPath(const VContainer *data) const
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VPiece::MainPathPath(const VContainer *data) const
{
return VPiece::MainPathPath(CastTo<QPointF>(MainPathPoints(data)));
QVector<QPointF> points;
CastTo(MainPathPoints(data), points);
return VPiece::MainPathPath(points);
}
//---------------------------------------------------------------------------------------------------------------------
@ -349,8 +354,13 @@ bool VPiece::IsSeamAllowanceValid(const VContainer *data) const
{
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
{
return VAbstractPiece::IsAllowanceValid(CastTo<QPointF>(UniteMainPathPoints(data)),
CastTo<QPointF>(SeamAllowancePoints(data)));
QVector<QPointF> mainPathPoints;
CastTo<QPointF>(UniteMainPathPoints(data), mainPathPoints);
QVector<QPointF> seamAllowancePoints;
CastTo<QPointF>(SeamAllowancePoints(data), seamAllowancePoints);
return VAbstractPiece::IsAllowanceValid(mainPathPoints, seamAllowancePoints);
}
return true;

View File

@ -570,7 +570,10 @@ QVector<VSAPoint> VPiecePath::SeamAllowancePoints(const VContainer *data, qreal
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VPiecePath::PainterPath(const VContainer *data, const QVector<QPointF> &cuttingPath) const
{
return MakePainterPath(CastTo<QPointF>(PathPoints(data, cuttingPath)));
QVector<VLayoutPoint> points = PathPoints(data, cuttingPath);
QVector<QPointF> casted;
CastTo(points, casted);
return MakePainterPath(casted);
}
//---------------------------------------------------------------------------------------------------------------------
@ -580,7 +583,7 @@ QVector<QPainterPath> VPiecePath::CurvesPainterPath(const VContainer *data) cons
QVector<QPainterPath> paths;
paths.reserve(curves.size());
for(auto &curve : curves)
for(const auto &curve : curves)
{
paths.append(MakePainterPath(curve));
}
@ -1258,7 +1261,7 @@ QString VPiecePath::NodeName(const QVector<VPieceNode> &nodes, int nodeIndex, co
{
// ignore
}
return QString();
return {};
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -2763,7 +2763,8 @@ void DialogSeamAllowance::ValidObjects(bool value)
//---------------------------------------------------------------------------------------------------------------------
bool DialogSeamAllowance::MainPathIsClockwise() const
{
const QVector<QPointF> points = CastTo<QPointF>(CreatePiece().MainPathPoints(data));
QVector<QPointF> points;
CastTo(CreatePiece().MainPathPoints(data), points);
if(points.count() < 3)
{

View File

@ -2093,9 +2093,10 @@ auto VToolSeamAllowance::IsGrainlinePositionValid() const -> bool
{
QLineF grainLine = m_grainLine->Grainline();
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
const QVector<QPointF> contourPoints =
detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
CastTo<QPointF>(detail.SeamAllowancePoints(getData())) : CastTo<QPointF>(detail.MainPathPoints(getData()));
QVector<QPointF> contourPoints;
detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn()
? CastTo(detail.SeamAllowancePoints(getData()), contourPoints)
: CastTo(detail.MainPathPoints(getData()), contourPoints);
QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(contourPoints, grainLine);
if (not points.isEmpty())

View File

@ -52,7 +52,7 @@ void VisToolPiece::RefreshGeometry()
if (GetMode() == Mode::Creation)
{
m_cachedCurvesPath = m_piece.CurvesPainterPath(GetData());
m_cachedMainPathPoints = CastTo<QPointF>(m_piece.MainPathPoints(GetData()));
CastTo(m_piece.MainPathPoints(GetData()), m_cachedMainPathPoints);
m_cachedMainPath = VPiece::MainPathPath(m_cachedMainPathPoints);
}
else

View File

@ -308,7 +308,8 @@ void TST_VAbstractPiece::EquidistantRemoveLoop() const
QFETCH(qreal, width);
QFETCH(QVector<QPointF>, ekvOrig);
const QVector<QPointF> ekv = CastTo<QPointF>(VAbstractPiece::Equidistant(points, width, QString()));
QVector<QPointF> ekv;
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);
// Begin comparison
ComparePathsDistance(ekv, ekvOrig);
@ -360,7 +361,8 @@ void TST_VAbstractPiece::LayoutAllowanceRemoveLoop() const
QFETCH(qreal, width);
QFETCH(QVector<QPointF>, ekvOrig);
const QVector<QPointF> ekv = CastTo<QPointF>(VAbstractPiece::Equidistant(points, width, QString()));
QVector<QPointF> ekv;
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);
// Begin comparison
ComparePathsDistance(ekv, ekvOrig);
@ -402,7 +404,8 @@ void TST_VAbstractPiece::RawPathRemoveLoop() const
QFETCH(QVector<VRawSAPoint>, path);
QFETCH(QVector<QPointF>, expect);
QVector<QPointF> res = CastTo<QPointF>(VAbstractPiece::CheckLoops(path));
QVector<QPointF> res;
CastTo(VAbstractPiece::CheckLoops(path), res);
ComparePathsDistance(res, expect);
}
@ -962,7 +965,8 @@ void TST_VAbstractPiece::BrokenDetailEquidistant() const
QFETCH(qreal, width);
QFETCH(QVector<QPointF>, ekvOrig);
const QVector<QPointF> ekv = CastTo<QPointF>(VAbstractPiece::Equidistant(points, width, QString()));// Take result
QVector<QPointF> ekv;
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);// Take result
// Begin comparison
ComparePathsDistance(ekv, ekvOrig);
@ -1074,7 +1078,8 @@ void TST_VAbstractPiece::EquidistantAngleType() const
QFETCH(qreal, width);
QFETCH(QVector<QPointF>, ekvOrig);
const QVector<QPointF> ekv = CastTo<QPointF>(VAbstractPiece::Equidistant(points, width, QString()));// Take result
QVector<QPointF> ekv;
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);// Take result
// Begin comparison
ComparePathsDistance(ekv, ekvOrig);

View File

@ -57,10 +57,14 @@ void TST_VLayoutDetail::Case1() const
// https://bitbucket.org/dismine/valentina/issue/304/layout-appears-different-than-my-pattern
VLayoutPiece det = VLayoutPiece();
det.SetCountourPoints(CastTo<VLayoutPoint>(InputPointsCase1()));
QVector<VLayoutPoint> inputPoints;
CastTo(InputPointsCase1(), inputPoints);
det.SetCountourPoints(inputPoints);
// Begin comparison
ComparePathsDistance(CastTo<QPointF>(det.GetMappedContourPoints()), OutputPointsCase1());
QVector<QPointF> contourPoints;
CastTo(det.GetMappedContourPoints(), contourPoints);
ComparePathsDistance(contourPoints, OutputPointsCase1());
}
//---------------------------------------------------------------------------------------------------------------------
@ -119,10 +123,14 @@ QVector<QPointF> TST_VLayoutDetail::OutputPointsCase1() const //-V524
void TST_VLayoutDetail::Case2() const
{
VLayoutPiece det = VLayoutPiece();
det.SetCountourPoints(CastTo<VLayoutPoint>(InputPointsCase2()));
QVector<VLayoutPoint> inputPoints;
CastTo(InputPointsCase2(), inputPoints);
det.SetCountourPoints(inputPoints);
// Begin comparison
ComparePathsDistance(CastTo<QPointF>(det.GetMappedContourPoints()), OutputPointsCase2());
QVector<QPointF> contourPoints;
CastTo(det.GetMappedContourPoints(), contourPoints);
ComparePathsDistance(contourPoints, OutputPointsCase2());
}
//---------------------------------------------------------------------------------------------------------------------
@ -160,10 +168,14 @@ QVector<QPointF> TST_VLayoutDetail::OutputPointsCase2() const
void TST_VLayoutDetail::Case3() const
{
VLayoutPiece det = VLayoutPiece();
det.SetCountourPoints(CastTo<VLayoutPoint>(InputPointsCase3()));
QVector<VLayoutPoint> inputPoints;
CastTo(InputPointsCase3(), inputPoints);
det.SetCountourPoints(inputPoints);
// Begin comparison
ComparePathsDistance(CastTo<QPointF>(det.GetMappedContourPoints()), OutputPointsCase3());
QVector<QPointF> contourPoints;
CastTo(det.GetMappedContourPoints(), contourPoints);
ComparePathsDistance(contourPoints, OutputPointsCase3());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -53,7 +53,8 @@ void TST_VPiece::Issue620()
VPiece detail;
AbstractTest::PieceFromJson(QStringLiteral("://Issue_620/input.json"), detail, data);
const QVector<QPointF> pointsEkv = CastTo<QPointF>(detail.MainPathPoints(data.data()));
QVector<QPointF> pointsEkv;
CastTo(detail.MainPathPoints(data.data()), pointsEkv);
QVector<QPointF> origPoints = AbstractTest::VectorFromJson<QPointF>(QStringLiteral("://Issue_620/output.json"));
// Begin comparison