From: azv Date: Fri, 3 Apr 2015 11:46:48 +0000 (+0300) Subject: Issue #435: Fix initial positions of base entities of mirror constraint X-Git-Tag: V_1.1.0~57^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=40fef71eff607d091f4caa0035ded6ac0a9f918b;p=modules%2Fshaper.git Issue #435: Fix initial positions of base entities of mirror constraint --- diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index b21b463fb..370bdce0d 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -131,8 +131,10 @@ void SketchSolver_Constraint::update(ConstraintPtr theConstraint) } // Value if exists + DataPtr aData = myBaseConstraint->data(); + if (!aData) return; AttributeDoublePtr aValueAttr = std::dynamic_pointer_cast( - myBaseConstraint->data()->attribute(SketchPlugin_Constraint::VALUE())); + myBaseConstraint->attribute(SketchPlugin_Constraint::VALUE())); double aValue = aValueAttr ? aValueAttr->value() : 0.0; // Update constraint @@ -295,6 +297,7 @@ Slvs_hEntity SketchSolver_Constraint::changeEntity(AttributePtr theEntity, int& if (aResult != SLVS_E_UNKNOWN) { Slvs_Entity anEnt = myStorage->getEntity(aResult); theType = anEnt.type; + myAttributeMap[theEntity] = aResult; return aResult; } } @@ -388,6 +391,7 @@ Slvs_hEntity SketchSolver_Constraint::changeEntity(FeaturePtr theEntity, int& th if (aResult != SLVS_E_UNKNOWN) { Slvs_Entity anEnt = myStorage->getEntity(aResult); theType = anEnt.type; + myFeatureMap[theEntity] = aResult; return aResult; } } diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 620768680..2c6d8f576 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -234,6 +233,12 @@ bool SketchSolver_Group::changeConstraint( myTempConstraints.insert(aConstraint); } } + // Fix base features for mirror + if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) { + AttributeRefListPtr aRefList = std::dynamic_pointer_cast( + theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_B())); + fixFeaturesList(aRefList); + } if (!myFeatureStorage) myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage); @@ -270,6 +275,29 @@ void SketchSolver_Group::moveFeature(std::shared_ptr theFe myTempConstraints.insert(aConstraint); } +// ============================================================================ +// Function: fixFeaturesList +// Class: SketchSolver_Group +// Purpose: Apply temporary rigid constraints for the list of features +// ============================================================================ +void SketchSolver_Group::fixFeaturesList(AttributeRefListPtr theList) +{ + std::list aList = theList->list(); + std::list::iterator anIt = aList.begin(); + for (; anIt != aList.end(); anIt++) { + if (!(*anIt)) + continue; + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + SolverConstraintPtr aConstraint = + SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature); + if (!aConstraint) + continue; + aConstraint->setGroup(this); + aConstraint->setStorage(myStorage); + myTempConstraints.insert(aConstraint); + } +} + // ============================================================================ // Function: addWorkplane // Class: SketchSolver_Group diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index dceff0581..30d675c63 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -16,7 +16,7 @@ #include #include #include - +#include #include #include @@ -148,6 +148,9 @@ private: */ bool addWorkplane(CompositeFeaturePtr theSketch); + /// \brief Apply temporary rigid constraints for the list of features + void fixFeaturesList(AttributeRefListPtr theList); + private: Slvs_hGroup myID; ///< Index of the group Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on