]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Application crashes during sketching (issue #872)
authorazv <azv@opencascade.com>
Wed, 2 Sep 2015 14:05:33 +0000 (17:05 +0300)
committerazv <azv@opencascade.com>
Wed, 2 Sep 2015 14:06:19 +0000 (17:06 +0300)
Multi-coincidence with external point was implemented

src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp

index 0e6ee74906d94719567f80112fde232e40c9f8f8..205c744e9c30794e40f9294dbd6147e0eb09425d 100644 (file)
@@ -2,6 +2,8 @@
 #include <SketchSolver_Error.h>
 #include <SketchSolver_Group.h>
 
+#include <SketchPlugin_Point.h>
+
 #include <map>
 
 void SketchSolver_ConstraintCoincidence::getAttributes(
@@ -169,9 +171,12 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai
   Slvs_hEntity anEntity = SLVS_E_UNKNOWN;
   int anEntType;
   for (; anIter != anAttrList.end(); anIter++) {
+    Slvs_hEntity aPointID = SLVS_E_UNKNOWN;
     AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIter);
     if (!aRefAttr)
       continue;
+
+    AttributePtr aPointAttr;
     if (aRefAttr->isObject()) {
       FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
       std::map<FeaturePtr, Slvs_hEntity>::const_iterator aFeatFound = 
@@ -185,21 +190,29 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai
         else
           myFeatureMap[aFeature] = anEntity;
       }
+      // If the feature is a point, add it to the list of coincident points
+      if (aFeature->getKind() == SketchPlugin_Point::ID()) {
+        aPointID = anEntity;
+        anEntity = SLVS_E_UNKNOWN;
+        aPointAttr = aFeature->attribute(SketchPlugin_Point::COORD_ID());
+      }
     } else {
-      Slvs_hEntity anEntID = SLVS_E_UNKNOWN;
+      aPointAttr = aRefAttr->attr();
       std::map<AttributePtr, Slvs_hEntity>::const_iterator anAttrFound =
-          myAttributeMap.find(aRefAttr->attr());
+          myAttributeMap.find(aPointAttr);
       if (anAttrFound != myAttributeMap.end())
-        anEntID = anAttrFound->second;
+        aPointID = anAttrFound->second;
       else {
-        anEntID = myGroup->getAttributeId(aRefAttr->attr());
-        if (anEntID == SLVS_E_UNKNOWN)
-          anEntID = changeEntity(aRefAttr->attr(), anEntType);
-        else
-          myAttributeMap[aRefAttr->attr()] = anEntID;
+        aPointID = myGroup->getAttributeId(aPointAttr);
+        if (aPointID == SLVS_E_UNKNOWN)
+          aPointID = changeEntity(aPointAttr, anEntType);
       }
-      aPoints.push_back(anEntID);
-      myCoincidentPoints.insert(aRefAttr->attr());
+    }
+
+    if (aPointAttr) { // the point is found
+      aPoints.push_back(aPointID);
+      myCoincidentPoints.insert(aPointAttr);
+      myAttributeMap[aPointAttr] = aPointID;
     }
   }