Salome HOME
Using test for testing number of sub-shapes.
[modules/shaper.git] / src / SketchSolver / SketchSolver_Constraint.cpp
index 47ec0fdb3beb37bb8cfa6853c2f0007b09064771..bbf00518aa95c1e1f57ec7f12aaa4f7c65e23612 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include <SketchSolver_Constraint.h>
 #include <SketchSolver_Group.h>
 #include <SketchSolver_Error.h>
@@ -15,6 +17,7 @@
 #include <SketchPlugin_ConstraintEqual.h>
 #include <SketchPlugin_ConstraintHorizontal.h>
 #include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintMiddle.h>
 #include <SketchPlugin_ConstraintMirror.h>
 #include <SketchPlugin_ConstraintParallel.h>
 #include <SketchPlugin_ConstraintPerpendicular.h>
@@ -82,6 +85,8 @@ SketchSolver_ConstraintType SketchSolver_Constraint::TYPE(ConstraintPtr theConst
     return CONSTRAINT_TANGENT;
   else if (aType == SketchPlugin_ConstraintCollinear::ID())
     return CONSTRAINT_COLLINEAR;
+  else if (aType == SketchPlugin_ConstraintMiddle::ID())
+    return CONSTRAINT_MIDDLE_POINT;
   return CONSTRAINT_UNKNOWN;
 }
 
@@ -198,6 +203,7 @@ void SketchSolver_Constraint::getAttributes(
 {
   static const int anInitNbOfAttr = 4;
   theAttributes.assign(anInitNbOfAttr, EntityWrapperPtr());
+  myAttributes.clear();
 
   DataPtr aData = myBaseConstraint->data();
   BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
@@ -222,6 +228,12 @@ void SketchSolver_Constraint::getAttributes(
 
     myStorage->update(*anIter/*, myGroupID*/);
     EntityWrapperPtr anEntity = myStorage->entity(*anIter);
+    if (!anEntity) {
+      // Force creation of an entity
+      myStorage->update(*anIter, GID_UNKNOWN, true);
+      anEntity = myStorage->entity(*anIter);
+    }
+    myAttributes.push_back(anEntity);
 
     SketchSolver_EntityType aType = anEntity->type();
     if (aType == ENTITY_UNKNOWN)
@@ -246,7 +258,8 @@ bool SketchSolver_Constraint::isUsed(FeaturePtr theFeature) const
     if ((*aCIt)->isUsed(theFeature))
       return true;
 
-  std::list<AttributePtr> anAttrList = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
+  std::list<AttributePtr> anAttrList =
+    theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
   std::list<AttributePtr>::const_iterator anAttrIt = anAttrList.begin();
   for (; anAttrIt != anAttrList.end(); ++ anAttrIt)
     if (isUsed(*anAttrIt))