]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Fri, 17 Apr 2015 07:44:26 +0000 (10:44 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 17 Apr 2015 07:44:26 +0000 (10:44 +0300)
src/Model/Model_Application.cpp
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_Constraint.h
src/SketchSolver/SketchSolver_ConstraintMirror.cpp
src/SketchSolver/SketchSolver_ConstraintMirror.h

index a825e747104b6482f68a0b14a7bbbbcc4b13d182..212fd4c9cab1ec924a6fe9fd14d2ced24b7a74ec 100644 (file)
@@ -61,6 +61,10 @@ void Model_Application::deleteDocument(string theDocID)
 
 void Model_Application::deleteAllDocuments()
 {
+  std::map<std::string, std::shared_ptr<Model_Document> >::iterator aDoc = myDocs.begin();
+  for(; aDoc != myDocs.end(); aDoc++) {
+    aDoc->second->close();
+  }
   myDocs.clear();
   myLoadedByDemand.clear();
 }
index 4db4c4636bfcfa54936257b11bda9c9c28841d63..4e815d649a632a0c73132394dc7aa998f0b569cb 100644 (file)
@@ -113,48 +113,45 @@ void SketchSolver_Constraint::process()
   adjustConstraint();
 }
 
-void SketchSolver_Constraint::update(ConstraintPtr theConstraint)
+bool SketchSolver_Constraint::checkAttributesChanged(ConstraintPtr theConstraint)
 {
-  cleanErrorMsg();
-  bool needToRebuild = (theConstraint && theConstraint != myBaseConstraint);
-  if (!needToRebuild) {
-    // Check the attrbutes of constraint are changed
-    ConstraintPtr aConstraint = theConstraint ? theConstraint : myBaseConstraint;
-    std::list<AttributePtr> anAttrList = aConstraint->data()->attributes(std::string());
-    std::list<AttributePtr>::iterator anAttrIter = anAttrList.begin();
-    for (; anAttrIter != anAttrList.end(); anAttrIter++) {
-      AttributeRefAttrPtr aRefAttr =
-          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
-      if (aRefAttr) {
-        if (aRefAttr->isObject()) {
-          FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
-          if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end()) {
-            needToRebuild = true;
-            break;
-          }
-        } else if (aRefAttr->attr() &&
-                    myAttributeMap.find(aRefAttr->attr()) == myAttributeMap.end()) {
-          needToRebuild = true;
-          break;
-        }
-      }
-      AttributeRefListPtr aRefList =
-          std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrIter);
-      if (aRefList) {
-        std::list<ObjectPtr> anItems = aRefList->list();
-        std::list<ObjectPtr>::iterator anIt = anItems.begin();
-        for (; anIt != anItems.end(); anIt++) {
-          FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
-          if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end()) {
-            needToRebuild = true;
-            break;
-          }
-        }
-        if (needToRebuild)
-          break;
+  // Check the attrbutes of constraint are changed
+  ConstraintPtr aConstraint = theConstraint ? theConstraint : myBaseConstraint;
+  std::list<AttributePtr> anAttrList = aConstraint->data()->attributes(std::string());
+  std::list<AttributePtr>::iterator anAttrIter = anAttrList.begin();
+  for (; anAttrIter != anAttrList.end(); anAttrIter++) {
+    AttributeRefAttrPtr aRefAttr =
+        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
+    if (aRefAttr) {
+      if (aRefAttr->isObject()) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
+        if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end())
+          return true;
+      } else if (aRefAttr->attr() &&
+                 myAttributeMap.find(aRefAttr->attr()) == myAttributeMap.end())
+        return true;
+    }
+    AttributeRefListPtr aRefList =
+        std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrIter);
+    if (aRefList) {
+      std::list<ObjectPtr> anItems = aRefList->list();
+      std::list<ObjectPtr>::iterator anIt = anItems.begin();
+      for (; anIt != anItems.end(); anIt++) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+        if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end())
+          return true;
       }
     }
   }
+  return false;
+}
+
+void SketchSolver_Constraint::update(ConstraintPtr theConstraint)
+{
+  cleanErrorMsg();
+  bool needToRebuild = (theConstraint && theConstraint != myBaseConstraint);
+  if (!needToRebuild)
+    needToRebuild = checkAttributesChanged(theConstraint);
   if (needToRebuild) {
     if (theConstraint && theConstraint->getKind() != myBaseConstraint->getKind())
       return;
index b6ff8f55bdca282594442ec350b5e550d3bb3464..0ceac28125645ed10fc5aa39649ccc1cc1d21695 100644 (file)
@@ -82,6 +82,11 @@ protected:
   /// \param[out] theAttributes list of attributes to be filled
   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes);
 
+  /// \brief Verify the attributes of constraint are changed (and constraint need to rebuild)
+  /// \param[in] theConstraint constraint, which attributes should be checked (if NULL, the myBaseConstraint is used)
+  /// \return \c true if some attributes are changed
+  virtual bool checkAttributesChanged(ConstraintPtr theConstraint);
+
   /// \brief This method is used in derived objects to check consistence of constraint.
   ///        E.g. the distance between line and point may be signed.
   virtual void adjustConstraint()
index 8ed85ff49cbfc140c1e1b57065a9040ce602c8eb..c27000bd14eb292ddee8239d80eaa601f68cd092 100644 (file)
@@ -233,6 +233,39 @@ bool SketchSolver_ConstraintMirror::remove(ConstraintPtr theConstraint)
   return true;
 }
 
+bool SketchSolver_ConstraintMirror::checkAttributesChanged(ConstraintPtr theConstraint)
+{
+  // First of all, check the mirror line is changed.
+  // It may be changed to one of mirrored lines, which is already in this constraint
+  // (this case is not marked as attribute changing)
+  ConstraintPtr aConstraint = theConstraint ? theConstraint : myBaseConstraint;
+  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+      aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  if (!aRefAttr || !aRefAttr->isObject() || !aRefAttr->object())
+    return true;
+  FeaturePtr aMirrorLine = ModelAPI_Feature::feature(aRefAttr->object());
+  if (!aMirrorLine)
+    return true;
+
+  std::map<FeaturePtr, Slvs_hEntity>::iterator aMirrorIter = myFeatureMap.find(aMirrorLine);
+  if (aMirrorIter == myFeatureMap.end())
+    return true;
+
+  // Check the entity is not used as mirror line
+  std::vector<Slvs_hConstraint>::iterator aCIter = mySlvsConstraints.begin();
+  for (; aCIter != mySlvsConstraints.end(); aCIter++) {
+    Slvs_Constraint aMirrorConstr = myStorage->getConstraint(*aCIter);
+    if (aMirrorConstr.type != SLVS_C_SYMMETRIC_LINE)
+      continue;
+    if (aMirrorConstr.entityA != aMirrorIter->second)
+      return true;
+    else break; // check just one symmetric constraint
+  }
+
+  // Base verification
+  return SketchSolver_Constraint::checkAttributesChanged(theConstraint);
+}
+
 void SketchSolver_ConstraintMirror::makeMirrorEntity(
     const Slvs_Entity& theBase,
     const Slvs_Entity& theMirror,
index eb3af1fb34aeeba34cce6a084953c519f47896c0..e65dcb90bc77363098636fda0ef710fb3c07a52b 100644 (file)
@@ -42,6 +42,11 @@ protected:
   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
   { /* do nothing here */ }
 
+  /// \brief Verify the attributes of constraint are changed (and constraint need to rebuild)
+  /// \param[in] theConstraint constraint, which attributes should be checked (if NULL, the myBaseConstraint is used)
+  /// \return \c true if some attributes are changed
+  virtual bool checkAttributesChanged(ConstraintPtr theConstraint);
+
   /// \brief Generate list of entities of mirror constraint
   /// \param[out] theMirrorLine     entity corresponding to mirror line
   /// \param[out] theBaseEntities   list of entities to mirror