From 1dfea8e40b4a842bc56e796ff2baa1e0a7dd0ed4 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 10 Apr 2015 13:19:45 +0300 Subject: [PATCH 1/1] Fix the problem with updating of an arc by moving a line which has coincident point with the arc --- src/SketchSolver/SketchSolver_Constraint.cpp | 8 +++++++- src/SketchSolver/SketchSolver_Constraint.h | 3 +++ .../SketchSolver_ConstraintCoincidence.cpp | 12 +++++------- .../SketchSolver_ConstraintCoincidence.h | 1 + src/SketchSolver/SketchSolver_Group.cpp | 4 ++++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 946ee0ede..2a2c85f38 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -62,6 +62,12 @@ void SketchSolver_Constraint::setGroup(SketchSolver_Group* theGroup) process(); } +void SketchSolver_Constraint::addFeature(FeaturePtr theFeature) +{ + int aType; + changeEntity(theFeature, aType); +} + void SketchSolver_Constraint::process() { @@ -527,7 +533,7 @@ void SketchSolver_Constraint::refresh() } if (fabs(aPoint2D->x() - aXY[0]) > tolerance || fabs(aPoint2D->y() - aXY[1]) > tolerance) - aPoint2D->setValue(aXY[0], aXY[1]); + aPoint2D->setValue(aXY[0], aXY[1]); } else { // Scalar value (used for the distance entities) AttributeDoublePtr aScalar = diff --git a/src/SketchSolver/SketchSolver_Constraint.h b/src/SketchSolver/SketchSolver_Constraint.h index 134263412..b6ff8f55b 100644 --- a/src/SketchSolver/SketchSolver_Constraint.h +++ b/src/SketchSolver/SketchSolver_Constraint.h @@ -66,6 +66,9 @@ public: /// \brief Return identifier of SolveSpace entity relating to the attribute Slvs_hEntity getId(AttributePtr theAttribute) const; + /// \brief Adds a feature to constraint and create its analogue in SolveSpace + void addFeature(FeaturePtr theFeature); + /// \brief Shows error message const std::string& error() const { return myErrorMsg; } diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp index 2ae6bf381..bfa65c19e 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp @@ -28,13 +28,9 @@ std::list SketchSolver_ConstraintCoincidence::constraints() const bool SketchSolver_ConstraintCoincidence::isCoincide( std::shared_ptr theConstraint) const { - std::map::const_iterator aFeatIter = myFeatureMap.begin(); - for (; aFeatIter != myFeatureMap.end(); aFeatIter++) - if (theConstraint->myFeatureMap.find(aFeatIter->first) != theConstraint->myFeatureMap.end()) - return true; - std::map::const_iterator anAttrIter = myAttributeMap.begin(); - for (; anAttrIter != myAttributeMap.end(); anAttrIter++) - if (theConstraint->myAttributeMap.find(anAttrIter->first) != theConstraint->myAttributeMap.end()) + std::set::const_iterator anAttrIter = theConstraint->myCoincidentPoints.begin(); + for (; anAttrIter != theConstraint->myCoincidentPoints.end(); anAttrIter++) + if (myCoincidentPoints.find(*anAttrIter) != myCoincidentPoints.end()) return true; return false; } @@ -96,6 +92,7 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai if (anEntityID == SLVS_E_UNKNOWN) anEntityID = changeEntity(aRefAttr->attr(), aType); anEntities.push_back(anEntityID); + myCoincidentPoints.insert(aRefAttr->attr()); } Slvs_Constraint aBaseCoincidence = myStorage->getConstraint(mySlvsConstraints.front()); @@ -176,6 +173,7 @@ bool SketchSolver_ConstraintCoincidence::remove(ConstraintPtr theConstraint) while (anAttrIter != myAttributeMap.end()) { if (anEntRemoved.find(anAttrIter->second) != anEntRemoved.end()) { std::map::iterator aTempIt = anAttrIter++; + myCoincidentPoints.erase(aTempIt->first); myAttributeMap.erase(aTempIt); continue; } diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.h b/src/SketchSolver/SketchSolver_ConstraintCoincidence.h index f726020c7..e8cbb8e40 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.h +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.h @@ -50,6 +50,7 @@ private: private: std::map myExtraCoincidence; ///< multiple coincidence of points + std::set myCoincidentPoints; ///< list of points under the Coincidence constraint }; #endif diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 5a6e9802a..3c5832cdb 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -258,6 +258,10 @@ bool SketchSolver_Group::updateFeature(std::shared_ptr the std::set::iterator aCIter = aConstraints.begin(); for (; aCIter != aConstraints.end(); aCIter++) { ConstraintConstraintMap::iterator aSolConIter = myConstraints.find(*aCIter); + if (aSolConIter == myConstraints.end()) + continue; + myFeatureStorage->changeFeature(theFeature, aSolConIter->first); + aSolConIter->second->addFeature(theFeature); aSolConIter->second->update(); } return true; -- 2.30.2