From 0ea4c7c280c46e2c13a89d34f40b4794e8edcb6c Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Tue, 13 Aug 2024 17:50:42 +0530 Subject: [PATCH] [Sketcher] Move some checks to `Constraint` --- src/Mod/Sketcher/App/SketchObject.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index ee2a26c819..9e7a437efc 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -3069,9 +3069,7 @@ void SketchObject::changeConstraintAfterDeletingGeo(Constraint* constr, return; } - if (constr->First == deletedGeoId || - constr->Second == deletedGeoId || - constr->Third == deletedGeoId) { + if (constr->involvesGeoId(deletedGeoId)) { constr->Type = ConstraintType::None; return; } @@ -5516,9 +5514,7 @@ int SketchObject::removeAxesAlignment(const std::vector& geoIdList) for (size_t i = 0; i < constrvals.size(); i++) { for (const auto& geoid : geoIdList) { - if (constrvals[i]->First != geoid - && constrvals[i]->Second != geoid - && constrvals[i]->Third != geoid) { + if (!constrvals[i]->involvesGeoId(geoid)) { continue; } switch (constrvals[i]->Type) { @@ -6599,14 +6595,10 @@ bool SketchObject::convertToNURBS(int GeoId) // to-be-converted curve. for (; index >= 0; index--) { auto otherthancoincident = cvals[index]->Type != Sketcher::Coincident - && (cvals[index]->First == GeoId || cvals[index]->Second == GeoId - || cvals[index]->Third == GeoId); + && cvals[index]->involvesGeoId(GeoId); auto coincidentonmidpoint = cvals[index]->Type == Sketcher::Coincident - && ((cvals[index]->First == GeoId - && cvals[index]->FirstPos == Sketcher::PointPos::mid) - || (cvals[index]->Second == GeoId - && cvals[index]->SecondPos == Sketcher::PointPos::mid)); + && cvals[index]->involvesGeoIdAndPosId(GeoId, Sketcher::PointPos::mid); if (otherthancoincident || coincidentonmidpoint) newcVals.erase(newcVals.begin() + index); @@ -9812,7 +9804,7 @@ void SketchObject::getConstraintIndices(int GeoId, std::vector& constraintL int i = 0; for (const auto& constr : constraints) { - if (constr->First == GeoId || constr->Second == GeoId || constr->Third == GeoId) { + if (constr->involvesGeoId(GeoId)) { constraintList.push_back(i); } ++i;