From caa079890d75a6f34a9c544558cec3e752e29b08 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 9 Apr 2015 08:25:57 +0300 Subject: [PATCH] Update for properly work with Length constraint --- src/SketchSolver/SketchSolver_ConstraintLength.cpp | 6 ++++++ src/SketchSolver/SketchSolver_ConstraintLength.h | 4 ++++ src/SketchSolver/SketchSolver_Storage.cpp | 8 +------- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.cpp b/src/SketchSolver/SketchSolver_ConstraintLength.cpp index 3d1d1bf22..bf519342b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintLength.cpp @@ -34,3 +34,9 @@ void SketchSolver_ConstraintLength::process() adjustConstraint(); } +void SketchSolver_ConstraintLength::adjustConstraint() +{ + // No need to store the line, which length is constrained + myFeatureMap.clear(); +} + diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.h b/src/SketchSolver/SketchSolver_ConstraintLength.h index 5d0583752..7f91d7e3a 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.h +++ b/src/SketchSolver/SketchSolver_ConstraintLength.h @@ -27,6 +27,10 @@ public: protected: /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints virtual void process(); + + /// \brief This method is used in derived objects to check consistence of constraint. + /// E.g. the distance between line and point may be signed. + virtual void adjustConstraint(); }; #endif diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 1690d7d56..d4a517132 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -151,19 +151,13 @@ bool SketchSolver_Storage::removeEntity(const Slvs_hEntity& theEntityID) if (anEntIter->distance == theEntityID) return false; } - std::set anEntAndSubs; - anEntAndSubs.insert(theEntityID); - for (int i = 0; i < 4; i++) - if (myEntities[aPos].point[i] != SLVS_E_UNKNOWN) - anEntAndSubs.insert(myEntities[aPos].point[i]); - std::vector::const_iterator aConstrIter = myConstraints.begin(); for (; aConstrIter != myConstraints.end(); aConstrIter++) { Slvs_hEntity anEntIDs[6] = {aConstrIter->ptA, aConstrIter->ptB, aConstrIter->entityA, aConstrIter->entityB, aConstrIter->entityC, aConstrIter->entityD}; for (int i = 0; i < 6; i++) - if (anEntAndSubs.find(anEntIDs[i]) != anEntAndSubs.end()) + if (anEntIDs[i] == theEntityID) return false; } // The entity is not used, remove it and its parameters -- 2.39.2