From: azv Date: Fri, 24 Oct 2014 11:13:30 +0000 (+0400) Subject: SketchSolver: Updated procedure of checking attributes for initialization X-Git-Tag: V_0.5~73^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aeec09d971f5d4b300324b3c4d24b853927bd44f;p=modules%2Fshaper.git SketchSolver: Updated procedure of checking attributes for initialization --- diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 20158ab6e..bfecae21d 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -481,6 +481,9 @@ bool SketchSolver_ConstraintGroup::changeRigidConstraint( // Avoid to create additional "Rigid" constraints for coincident points bool isCoincAlreadyFixed = false; if (!anAlreadyFixed.empty()) { + if (anAlreadyFixed.find(*aPointsPtr) != anAlreadyFixed.end()) + isCoincAlreadyFixed = true; + std::vector >::const_iterator aCoincIter = myCoincidentPoints.begin(); for (; !isCoincAlreadyFixed && aCoincIter != myCoincidentPoints.end(); aCoincIter++) { @@ -651,28 +654,30 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) SketchPlugin_Feature>(theEntity); if (aFeature) { // Verify the feature by its kind const std::string& aFeatureKind = aFeature->getKind(); - - std::list anAttributes = aFeature->data()->attributes(std::string()); - std::list::iterator anAttrIter = anAttributes.begin(); - for ( ; anAttrIter != anAttributes.end(); anAttrIter++) - if (!(*anAttrIter)->isInitialized()) // the entity is not fully initialized, don't add it into solver - return SLVS_E_UNKNOWN; + AttributePtr anAttribute; // Line if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0) { - Slvs_hEntity aStart = changeEntity( - aFeature->data()->attribute(SketchPlugin_Line::START_ID())); - Slvs_hEntity aEnd = changeEntity(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); + anAttribute = aFeature->data()->attribute(SketchPlugin_Line::START_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aStart = changeEntity(anAttribute); + + anAttribute = aFeature->data()->attribute(SketchPlugin_Line::END_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aEnd = changeEntity(anAttribute); if (!isEntExists) // New entity aNewEntity = Slvs_MakeLineSegment(++myEntityMaxID, myID, myWorkplane.h, aStart, aEnd); } // Circle else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0) { - Slvs_hEntity aCenter = changeEntity( - aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); - Slvs_hEntity aRadius = changeEntity( - aFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID())); + anAttribute = aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aCenter = changeEntity(anAttribute); + + anAttribute = aFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aRadius = changeEntity(anAttribute); if (!isEntExists) // New entity aNewEntity = Slvs_MakeCircle(++myEntityMaxID, myID, myWorkplane.h, aCenter, @@ -680,10 +685,17 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) } // Arc else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0) { - Slvs_hEntity aCenter = changeEntity( - aFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID())); - Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::START_ID())); - Slvs_hEntity aEnd = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::END_ID())); + anAttribute = aFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aCenter = changeEntity(anAttribute); + + anAttribute = aFeature->data()->attribute(SketchPlugin_Arc::START_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aStart = changeEntity(anAttribute); + + anAttribute = aFeature->data()->attribute(SketchPlugin_Arc::END_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aEnd = changeEntity(anAttribute); if (!isEntExists) aNewEntity = Slvs_MakeArcOfCircle(++myEntityMaxID, myID, myWorkplane.h, @@ -691,8 +703,9 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) } // Point (it has low probability to be an attribute of constraint, so it is checked at the end) else if (aFeatureKind.compare(SketchPlugin_Point::ID()) == 0) { - Slvs_hEntity aPoint = changeEntity( - aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); + anAttribute = aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()); + if (!anAttribute->isInitialized()) return SLVS_E_UNKNOWN; + Slvs_hEntity aPoint = changeEntity(anAttribute); if (isEntExists) return aEntIter->second; @@ -716,7 +729,6 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) return aNewEntity.h; } - // Unsupported or wrong entity type return SLVS_E_UNKNOWN; }