From 2be7f8cbcb68bf00417a65654969c8e7b62f97ce Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 10 Feb 2021 06:40:01 +0100 Subject: [PATCH] Sketcher: fix malformed constraint on nurbs conversion ====================================================== Coincident on midpoint cannot be supported by a bspline. Fixes: https://forum.freecadweb.org/viewtopic.php?p=476410#p476410 --- src/Mod/Sketcher/App/SketchObject.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index e33fc25ef5..c848140b11 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -5474,14 +5474,21 @@ bool SketchObject::convertToNURBS(int GeoId) std::vector< Constraint * > newcVals(cvals); int index = cvals.size()-1; - // delete constraints on this elements other than coincident constraints (bspline does not support them currently) + // delete constraints on this elements other than coincident constraints (bspline does not support them currently), except + // for coincidents on mid point of the to-be-converted curve. for (; index >= 0; index--) { - if (cvals[index]->Type != Sketcher::Coincident && ( cvals[index]->First == GeoId || cvals[index]->Second == GeoId || cvals[index]->Third == GeoId)) { + auto otherthancoincident = cvals[index]->Type != Sketcher::Coincident && + (cvals[index]->First == GeoId || cvals[index]->Second == GeoId || cvals[index]->Third == GeoId); + auto coincidentonmidpoint = cvals[index]->Type == Sketcher::Coincident && + ( (cvals[index]->First == GeoId && cvals[index]->FirstPos == Sketcher::mid) || + (cvals[index]->Second == GeoId && cvals[index]->SecondPos == Sketcher::mid) ); + + if (otherthancoincident || coincidentonmidpoint) newcVals.erase(newcVals.begin()+index); - } } + this->Constraints.setValues(std::move(newcVals)); }