Fixed bug in seam allowance with mirror line.

This commit is contained in:
Roman Telezhynskyi 2024-01-19 18:15:30 +02:00
parent 25a8da8259
commit 225cb47f17
3 changed files with 43 additions and 14 deletions

View File

@ -779,15 +779,17 @@ auto VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype m
{ {
{ {
VSAPoint ekvPoint = VPiecePath::PreparePointEkv(node, data); VSAPoint ekvPoint = VPiecePath::PreparePointEkv(node, data);
if (showMirrorLine && VFuzzyComparePoints(ekvPoint, mirrorLine.p1())) if (showMirrorLine)
{
if (VFuzzyComparePoints(ekvPoint, mirrorLine.p1()))
{ {
ekvPoint.SetSAAfter(0); ekvPoint.SetSAAfter(0);
} }
else if (VFuzzyComparePoints(ekvPoint, mirrorLine.p2()))
if (showMirrorLine && VFuzzyComparePoints(ekvPoint, mirrorLine.p2()))
{ {
ekvPoint.SetSABefore(0); ekvPoint.SetSABefore(0);
} }
}
pointsEkv.append(ekvPoint); pointsEkv.append(ekvPoint);
} }
@ -832,7 +834,7 @@ auto VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype m
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId()); const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
pointsEkv += VPiecePath::CurveSeamAllowanceSegment(data, unitedPath, curve, i, node.GetReverse(), pointsEkv += VPiecePath::CurveSeamAllowanceSegment(data, unitedPath, curve, i, node.GetReverse(),
width, GetName()); width, mirrorLine, GetName());
} }
} }
break; break;
@ -1081,7 +1083,8 @@ auto VPiece::GetNodeSAPoints(const QVector<VPieceNode> &path, vsizetype index, c
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId()); const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
points += VPiecePath::CurveSeamAllowanceSegment(data, path, curve, index, node.GetReverse(), width, GetName()); points += VPiecePath::CurveSeamAllowanceSegment(data, path, curve, index, node.GetReverse(), width, QLineF(),
GetName());
} }
return points; return points;
} }

View File

@ -552,7 +552,8 @@ auto VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool r
case (Tool::NodeSplinePath): case (Tool::NodeSplinePath):
{ {
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId()); const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
pointsEkv += CurveSeamAllowanceSegment(data, d->m_nodes, curve, i, node.GetReverse(), width, GetName()); pointsEkv += CurveSeamAllowanceSegment(data, d->m_nodes, curve, i, node.GetReverse(), width, QLineF(),
GetName());
} }
break; break;
default: default:
@ -1152,10 +1153,34 @@ auto VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes, auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes,
const QSharedPointer<VAbstractCurve> &curve, vsizetype i, bool reverse, const QSharedPointer<VAbstractCurve> &curve, vsizetype i, bool reverse,
qreal width, const QString &piece) -> QVector<VSAPoint> qreal width, const QLineF &mirrorLine, const QString &piece)
-> QVector<VSAPoint>
{ {
const VSAPoint begin = StartSegment(data, nodes, i); VSAPoint begin = StartSegment(data, nodes, i);
const VSAPoint end = EndSegment(data, nodes, i); if (!mirrorLine.isNull())
{
if (VFuzzyComparePoints(begin, mirrorLine.p1()))
{
begin.SetSAAfter(0);
}
else if (VFuzzyComparePoints(begin, mirrorLine.p2()))
{
begin.SetSABefore(0);
}
}
VSAPoint end = EndSegment(data, nodes, i);
if (!mirrorLine.isNull())
{
if (VFuzzyComparePoints(end, mirrorLine.p1()))
{
end.SetSAAfter(0);
}
else if (VFuzzyComparePoints(end, mirrorLine.p2()))
{
end.SetSABefore(0);
}
}
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse, piece); const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse, piece);
if (points.size() < 2) if (points.size() < 2)

View File

@ -137,7 +137,8 @@ public:
static auto CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes, static auto CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes,
const QSharedPointer<VAbstractCurve> &curve, vsizetype i, bool reverse, const QSharedPointer<VAbstractCurve> &curve, vsizetype i, bool reverse,
qreal width, const QString &piece = QString()) -> QVector<VSAPoint>; qreal width, const QLineF &mirrorLine, const QString &piece = QString())
-> QVector<VSAPoint>;
static auto NodeName(const QVector<VPieceNode> &nodes, vsizetype nodeIndex, const VContainer *data) -> QString; static auto NodeName(const QVector<VPieceNode> &nodes, vsizetype nodeIndex, const VContainer *data) -> QString;