Fix segmenting a simple curve.

This commit is contained in:
Roman Telezhynskyi 2022-08-13 17:57:26 +03:00
parent 0ab0edc654
commit 2cf2dc5985
5 changed files with 33 additions and 1 deletions

View File

@ -17,6 +17,7 @@
- Unit type for increments.
- Support for options Force Flipping and Forbid Flipping in Puzzle.
- Remember selected dimension values.
- Fix segmenting a simple curve.
# Valentina 0.7.51 April 18, 2022
- Z value change for a layout piece.

View File

@ -524,7 +524,7 @@ auto VAbstractCubicBezier::GetParmT(qreal length) const -> qreal
length = base;
}
Q_DECL_RELAXED_CONSTEXPR qreal eps = ToPixel(0.001, Unit::Mm);
Q_DECL_RELAXED_CONSTEXPR qreal eps = ToPixel(0.0001, Unit::Mm);
qreal parT = 0.5;
qreal step = parT;
qreal splLength = 0;

View File

@ -152,6 +152,9 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData)
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
auto spline2 = QSharedPointer<VAbstractBezier>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
spline1->SetApproximationScale(spl->GetApproximationScale());
spline2->SetApproximationScale(spl->GetApproximationScale());
spline1->SetAliasSuffix(initData.aliasSuffix1);
spline2->SetAliasSuffix(initData.aliasSuffix2);

View File

@ -849,6 +849,33 @@ void TST_VSpline::TestFlip()
QCOMPARE(spl.GetC2Length(), res.GetC2Length());
}
//---------------------------------------------------------------------------------------------------------------------
// See file valentina_private_collection/bugs/men_jacket/issue_cut_spline.val (private collection)
void TST_VSpline::TestCutSpline()
{
VPointF p1(187.31716535433043, 51.31464566929152, QStringLiteral("p1"), 140.42872440944885, -22.62372283464567);
VPointF p4(-991.8954330708666, 9.739842519685212, QStringLiteral("p4"), 9.999987401574804, 15.0);
VSpline spl(p1, p4, 181.0, QStringLiteral("181"), 356.0, QStringLiteral("356"), 548.7874015748031,
QStringLiteral("Line_Г3_Г6*1.1"), 226.7716535433071, QStringLiteral("6"));
spl.SetApproximationScale(0.5);
const QString name(QStringLiteral("з"));
const qreal result = 1.35; // Correct distance in cm.
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl.CutSpline(UnitConvertor(result, Unit::Cm, Unit::Px), spl1p2, spl1p3, spl2p2, spl2p3, name);
VPointF p(point, name, -16.590651968503941, 37.574173228346453);
VSpline spline1(spl.GetP1(), spl1p2, spl1p3, p);
spline1.SetApproximationScale(0.5);
// Size 54 produces incorrect spline segment distance
Q_DECL_RELAXED_CONSTEXPR qreal eps = ToPixel(0.0001, Unit::Mm);
QVERIFY(UnitConvertor(spline1.GetLength(), Unit::Px, Unit::Cm) - result < eps);
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VSpline::CompareSplines(const VSpline &spl1, const VSpline &spl2) const
{

View File

@ -56,6 +56,7 @@ private slots:
void TestLengthByPoint();
void TestFlip_data();
void TestFlip();
void TestCutSpline();
private:
// cppcheck-suppress unknownMacro