X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintRigid.cpp;h=ff52e577437e5f8db91ae8a17077de087fa94395;hb=d3883990177d27a12b8a2278cdbb82250ff19b79;hp=7247553ae345d4adcf618b0340f43f348f0e2c7d;hpb=0743cb80e101f1a59e0d0fec0844949cda35ecf7;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintRigid.cpp b/src/SketchSolver/SketchSolver_ConstraintRigid.cpp index 7247553ae..ff52e5774 100644 --- a/src/SketchSolver/SketchSolver_ConstraintRigid.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintRigid.cpp @@ -35,28 +35,42 @@ void SketchSolver_ConstraintRigid::process() double aValue; std::vector anEntities; getAttributes(aValue, anEntities); - if (!myErrorMsg.empty() || myFeatureMap.empty()) + if (!myErrorMsg.empty() || (myFeatureMap.empty() && myAttributeMap.empty())) return; + fixFeature(); +} - Slvs_hEntity anEntID = myFeatureMap.begin()->second; +void SketchSolver_ConstraintRigid::fixFeature() +{ + Slvs_hEntity anEntID; + if (!myFeatureMap.empty()) + anEntID = myFeatureMap.begin()->second; + else + anEntID = myAttributeMap.begin()->second; if (myStorage->isEntityFixed(anEntID, true)) { myErrorMsg = SketchSolver_Error::ALREADY_FIXED(); return; } - if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Line::ID()) { + std::string aKind; + if (!myFeatureMap.empty()) + aKind = myFeatureMap.begin()->first->getKind(); + else + aKind = myAttributeMap.begin()->first->attributeType(); + + if (aKind == SketchPlugin_Line::ID()) { Slvs_Entity aLine = myStorage->getEntity(anEntID); fixLine(aLine); } - else if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Arc::ID()) { + else if (aKind == SketchPlugin_Arc::ID()) { Slvs_Entity anArc = myStorage->getEntity(anEntID); fixArc(anArc); } - else if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Circle::ID()) { + else if (aKind == SketchPlugin_Circle::ID()) { Slvs_Entity aCirc = myStorage->getEntity(anEntID); fixCircle(aCirc); } - else if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Point::ID()) { + else if (aKind == SketchPlugin_Point::ID() || aKind == GeomDataAPI_Point2D::typeId()) { fixPoint(anEntID); } } @@ -193,6 +207,13 @@ void SketchSolver_ConstraintRigid::fixLine(const Slvs_Entity& theLine) !myStorage->isPointFixed(theLine.point[1], aFixed, true)) fixPoint(theLine.point[0]); if (!isUsedInEqual(theLine, anEqual)) { + // Check the distance is not set yet + std::list aDistConstr = myStorage->getConstraintsByType(SLVS_C_PT_PT_DISTANCE); + std::list::const_iterator aDIt = aDistConstr.begin(); + for (; aDIt != aDistConstr.end(); aDIt++) + if ((aDIt->ptA == theLine.point[0] && aDIt->ptB == theLine.point[1]) || + (aDIt->ptA == theLine.point[1] && aDIt->ptB == theLine.point[0])) + return; // Calculate distance between points on the line double aCoords[4]; for (int i = 0; i < 2; i++) {