Salome HOME
Merge branch 'V9_2_2_BR'
[modules/shaper.git] / src / SketchSolver / SketchSolver_Storage.cpp
index 7c6f87be0f06df201a153eb7c9bb7b1d4757a125..9fb0369d59208b274ce90c4b7cb47966636bd16b 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    SketchSolver_Storage.cpp
-// Created: 30 Nov 2015
-// Author:  Artem ZHIDKOV
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include <SketchSolver_Storage.h>
 #include <PlaneGCSSolver_UpdateCoincidence.h>
@@ -80,41 +93,12 @@ void SketchSolver_Storage::addConstraint(ConstraintPtr        theConstraint,
     theConstraint->data()->blockSendAttributeUpdated(myEventsBlocked);
 }
 
-static std::list<AttributePtr> pointAttributes(FeaturePtr theFeature)
-{
-  std::list<AttributePtr> aPoints;
-  if (!theFeature->data() || !theFeature->data()->isValid())
-    return aPoints;
-  if (theFeature->getKind() == SketchPlugin_Arc::ID()) {
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Arc::START_ID()));
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Arc::END_ID()));
-  }
-  else if (theFeature->getKind() == SketchPlugin_Circle::ID())
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Circle::CENTER_ID()));
-  else if (theFeature->getKind() == SketchPlugin_Line::ID()) {
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Line::START_ID()));
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Line::END_ID()));
-  }
-  else if (theFeature->getKind() == SketchPlugin_Point::ID() ||
-           theFeature->getKind() == SketchPlugin_IntersectionPoint::ID())
-    aPoints.push_back(theFeature->attribute(SketchPlugin_Point::COORD_ID()));
-  return aPoints;
-}
-
 void SketchSolver_Storage::addEntity(FeaturePtr       theFeature,
                                      EntityWrapperPtr theSolverEntity)
 {
   if (theSolverEntity) {
     myFeatureMap[theFeature] = theSolverEntity;
     setNeedToResolve(true);
-  } else {
-    // feature links to the empty entity, add its attributes
-    std::list<AttributePtr> aPntAttrs = pointAttributes(theFeature);
-    std::list<AttributePtr>::const_iterator anAttrIt = aPntAttrs.begin();
-    for (; anAttrIt != aPntAttrs.end(); ++anAttrIt)
-      addEntity(*anAttrIt, EntityWrapperPtr());
-    myFeatureMap[theFeature] = theSolverEntity;
   }
 
   // block events if necessary
@@ -192,22 +176,18 @@ const EntityWrapperPtr& SketchSolver_Storage::entity(const AttributePtr& theAttr
 void SketchSolver_Storage::removeFeature(FeaturePtr theFeature)
 {
   myFeatureMap.erase(theFeature);
+  myNeedToResolve = true;
 }
 
 void SketchSolver_Storage::removeAttribute(AttributePtr theAttribute)
 {
   myAttributeMap.erase(theAttribute);
+  myNeedToResolve = true;
 }
 
 
-bool SketchSolver_Storage::isConsistent() const
+bool SketchSolver_Storage::areFeaturesValid() const
 {
-  // Check the constraints are valid
-  std::map<ConstraintPtr, ConstraintWrapperPtr>::const_iterator
-      aCIter = myConstraintMap.begin();
-  for (; aCIter != myConstraintMap.end(); ++aCIter)
-    if (!aCIter->first->data() || !aCIter->first->data()->isValid())
-      return false;
   // Check the features are valid
   std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIter = myFeatureMap.begin();
   for (; aFIter != myFeatureMap.end(); aFIter++)
@@ -238,10 +218,8 @@ std::set<ObjectPtr> SketchSolver_Storage::getConflictingConstraints(SolverPtr th
   std::map<ConstraintPtr, ConstraintWrapperPtr>::const_iterator
       aConstrIt = myConstraintMap.begin();
   for (; aConstrIt != myConstraintMap.end(); ++aConstrIt) {
-    if (theSolver->isConflicting(aConstrIt->second->id())) {
+    if (theSolver->isConflicting(aConstrIt->second->id()))
       aConflicting.insert(aConstrIt->first);
-      break;
-    }
   }
   return aConflicting;
 }