Salome HOME
#1802 Crash when I create a circle on projected axis
[modules/shaper.git] / src / SketchSolver / SketchSolver_Group.cpp
index 5a1ff49fbc122747495399c842cf2cb7ea2c201d..67e0d6cccf0e80d795d331a98bc07d529159a4db 100644 (file)
@@ -378,7 +378,8 @@ bool SketchSolver_Group::resolveConstraints()
       }
     } catch (...) {
 //      Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
-      getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH());
+      getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())
+        ->setValue(SketchSolver_Error::SOLVESPACE_CRASH());
       if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
         // the error message should be changed before sending the message
         sendMessage(EVENT_SOLVER_FAILED);
@@ -387,11 +388,13 @@ bool SketchSolver_Group::resolveConstraints()
       mySketchSolver->undo();
       return false;
     }
-    if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) {  // solution succeeded, store results into correspondent attributes
+    // solution succeeded, store results into correspondent attributes
+    if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) {  
       myStorage->setNeedToResolve(false);
       myStorage->refresh();
       updateMultiConstraints(myConstraints);
-      if (myStorage->isNeedToResolve()) // multi-constraints updated some parameters, need to store them
+      // multi-constraints updated some parameters, need to store them
+      if (myStorage->isNeedToResolve()) 
         resolveConstraints();
 
       if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
@@ -406,8 +409,11 @@ bool SketchSolver_Group::resolveConstraints()
       mySketchSolver->undo();
       if (!myConstraints.empty()) {
         // the error message should be changed before sending the message
-        getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS());
-        if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN || myPrevResult == STATUS_FAILED) {
+        getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())
+          ->setValue(SketchSolver_Error::CONSTRAINTS());
+        if (myPrevResult != aResult || 
+            myPrevResult == STATUS_UNKNOWN || 
+            myPrevResult == STATUS_FAILED) {
           // Obtain list of conflicting constraints
           std::set<ObjectPtr> aConflicting = myStorage->getConflictingConstraints(mySketchSolver);
 
@@ -482,7 +488,8 @@ void SketchSolver_Group::splitGroup(std::list<SketchSolver_Group*>& theCuts)
 {
   // New storage will be used in trimmed way to store the list of constraint interacted together.
   StoragePtr aNewStorage = SketchSolver_Manager::instance()->builder()->createStorage(getId());
-  std::list<ConstraintWrapperPtr> aDummyVec; // empty vector to avoid creation of solver's constraints
+  // empty vector to avoid creation of solver's constraints
+  std::list<ConstraintWrapperPtr> aDummyVec; 
 
   // Obtain constraints, which should be separated
   std::list<ConstraintPtr> anUnusedConstraints;
@@ -494,7 +501,8 @@ void SketchSolver_Group::splitGroup(std::list<SketchSolver_Group*>& theCuts)
       anUnusedConstraints.push_back(aCIter->first);
   }
 
-  // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
+  // Check the unused constraints once again, 
+  // because they may become interacted with new storage since adding constraints
   std::list<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
   while (aUnuseIt != anUnusedConstraints.end()) {
     if (aNewStorage->isInteract(FeaturePtr(*aUnuseIt))) {
@@ -675,7 +683,8 @@ static double featureToVal(FeaturePtr theFeature)
     AttributeRefAttrPtr anAttrB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
         aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
     if (anAttrA && anAttrB && (anAttrA->isObject() || anAttrB->isObject()))
-      return 2.0; // point-on-line and point-on-circle should go before points coincidence constraint
+      // point-on-line and point-on-circle should go before points coincidence constraint
+      return 2.0; 
     return 2.5;
   }
   if (anID == SketchPlugin_ConstraintDistance::ID() ||
@@ -709,7 +718,8 @@ static bool isLess(FeaturePtr theFeature1, FeaturePtr theFeature2)
   return featureToVal(theFeature1) < featureToVal(theFeature2);
 }
 
-std::list<FeaturePtr> SketchSolver_Group::selectApplicableFeatures(const std::set<ObjectPtr>& theObjects)
+std::list<FeaturePtr> SketchSolver_Group::
+  selectApplicableFeatures(const std::set<ObjectPtr>& theObjects)
 {
   std::list<FeaturePtr> aResult;
   std::list<FeaturePtr>::iterator aResIt;
@@ -717,7 +727,8 @@ std::list<FeaturePtr> SketchSolver_Group::selectApplicableFeatures(const std::se
   std::set<ObjectPtr>::const_iterator anObjIter = theObjects.begin();
   for (; anObjIter != theObjects.end(); ++anObjIter) {
     // Operate sketch itself and SketchPlugin features only.
-    // Also, the Fillet and Split need to be skipped, because there are several separated constraints composing it.
+    // Also, the Fillet and Split need to be skipped, 
+    // because there are several separated constraints composing it.
     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
     if (!aFeature)
       continue;