]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix some kind of crashes
authorazv <azv@opencascade.com>
Thu, 24 Dec 2015 12:21:11 +0000 (15:21 +0300)
committerazv <azv@opencascade.com>
Thu, 24 Dec 2015 12:22:00 +0000 (15:22 +0300)
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp

index 739de6f95641f5c045de8f16955ede5fcb40b931..b8773d92d4f007f1598995fd4fadda70ec7c1ad1 100644 (file)
@@ -275,6 +275,8 @@ bool SketchSolver_Storage::removeConstraint(ConstraintPtr theConstraint)
 template <class ENT_TYPE>
 static bool isUsed(ConstraintWrapperPtr theConstraint, ENT_TYPE theEntity)
 {
+  if (!theConstraint || !theEntity)
+    return false;
   std::list<EntityWrapperPtr>::const_iterator anEntIt = theConstraint->entities().begin();
   for (; anEntIt != theConstraint->entities().end(); ++anEntIt)
     if ((*anEntIt)->isBase(theEntity))
@@ -284,6 +286,8 @@ static bool isUsed(ConstraintWrapperPtr theConstraint, ENT_TYPE theEntity)
 
 static bool isUsed(EntityWrapperPtr theFeature, AttributePtr theSubEntity)
 {
+  if (!theFeature || !theSubEntity)
+    return false;
   std::list<EntityWrapperPtr>::const_iterator aSubIt = theFeature->subEntities().begin();
   for (; aSubIt != theFeature->subEntities().end(); ++aSubIt)
     if ((*aSubIt)->isBase(theSubEntity))
@@ -352,7 +356,7 @@ bool SketchSolver_Storage::removeEntity(FeaturePtr theFeature)
   myFeatureMap.erase(aFound);
 
   // Check if the feature is not used by constraints, remove it
-  if (!isUsed(theFeature) && remove(anEntity))
+  if (!anEntity || (!isUsed(theFeature) && remove(anEntity)))
     return true;
 
   // feature is not removed, revert operation
@@ -371,7 +375,7 @@ bool SketchSolver_Storage::removeEntity(AttributePtr theAttribute)
   myAttributeMap.erase(aFound);
 
   // Check if the attribute is not used by constraints and features, remove it
-  if (!isUsed(theAttribute) && remove(anEntity))
+  if (!anEntity || (!isUsed(theAttribute) && remove(anEntity)))
     return true;
 
   // attribute is not removed, revert operation
index 3006fd5b8f7e16468fb3e6795abcc65e5f83439b..51699b90faae6d6d2ddd76a07a2f7ac919a64205 100644 (file)
@@ -408,7 +408,12 @@ void SolveSpaceSolver_Storage::replaceInConstraints(
             aConstr.entityC == aSlvsCIt->entityC && aConstr.entityD == aSlvsCIt->entityD) {
           Slvs_hConstraint anIDToRemove = aConstr.h;
           aConstr = *aSlvsCIt;
+          int aShift = aSlvsCIt - myConstraints.begin();
           removeConstraint(anIDToRemove);
+          aSlvsCIt = myConstraints.begin() + aShift - 1;
+          for (; aSlvsCIt != myConstraints.end(); ++aSlvsCIt)
+            if (aSlvsCIt->h == aConstr.h)
+              break;
           break;
         }
 
@@ -1048,6 +1053,8 @@ bool SolveSpaceSolver_Storage::removeCoincidence(ConstraintWrapperPtr theConstra
   std::set<EntityWrapperPtr> anUpdFeatures;
   std::map<FeaturePtr, EntityWrapperPtr>::iterator aFIt = myFeatureMap.begin();
   for (; aFIt != myFeatureMap.end(); ++aFIt) {
+    if (!aFIt->second)
+      continue; // avoid not completed arcs
     for (aNotCIt = aNotCoinc.begin(); aNotCIt != aNotCoinc.end(); ++aNotCIt) {
       if (!aNotCIt->second || !aFIt->second->isUsed(aNotCIt->first->baseAttribute()))
         continue;