Salome HOME
Using test for testing number of sub-shapes.
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintCoincidence.cpp
index b10d7e95d44f25e14850f441cd45410275752e05..18594018c4f38fe3c38f00aa468eae76d1d478d2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include <SketchSolver_ConstraintCoincidence.h>
 #include <SketchSolver_Error.h>
 #include <SketchSolver_Manager.h>
@@ -14,6 +16,12 @@ void SketchSolver_ConstraintCoincidence::getAttributes(
 
   if (theAttributes[1]) {
     myType = CONSTRAINT_PT_PT_COINCIDENT;
+    if (myStorage->isFixed(theAttributes[1]) && !myStorage->isFixed(theAttributes[0])) {
+      // fixed point should go first
+      EntityWrapperPtr aTemp = theAttributes[0];
+      theAttributes[0] = theAttributes[1];
+      theAttributes[1] = aTemp;
+    }
     // Set the slave (second) point the same as master (first) point.
     // This will allow to skip adding point-point coincidence to the set of constraints
     // and give us speed-up in solving the set of equations
@@ -31,28 +39,3 @@ void SketchSolver_ConstraintCoincidence::getAttributes(
   } else
     myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
 }
-
-
-static bool isBase(const std::list<ConstraintWrapperPtr>& theConstraints, AttributePtr theAttribute)
-{
-  AttributePtr anAttribute = theAttribute;
-  FeaturePtr aFeature;
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-  if (aRefAttr) {
-    if (aRefAttr->isObject())
-      aFeature = ModelAPI_Feature::feature(aRefAttr->object());
-    else
-      anAttribute = aRefAttr->attr();
-  }
-
-  std::list<ConstraintWrapperPtr>::const_iterator aCIt = theConstraints.begin();
-  for (; aCIt != theConstraints.end(); ++aCIt) {
-    std::list<EntityWrapperPtr> aSubs = (*aCIt)->entities();
-    std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
-    for (; aSIt != aSubs.end(); ++aSIt)
-      if ((aFeature && (*aSIt)->isBase(aFeature)) ||
-         (!aFeature && (*aSIt)->isBase(anAttribute)))
-        return true;
-  }
-  return false;
-}