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
This commit is contained in:
Abdullah Tahiri
2021-02-10 06:40:01 +01:00
parent 3bb03af723
commit 2be7f8cbcb

View File

@@ -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));
}