]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixed storing names (generated and primitives) for sub-results.
authordbv <dbv@opencascade.com>
Fri, 26 Oct 2018 13:47:54 +0000 (16:47 +0300)
committerdbv <dbv@opencascade.com>
Fri, 26 Oct 2018 13:48:22 +0000 (16:48 +0300)
src/Model/Model_BodyBuilder.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h

index fbfd692a87964c6593802433ccc58443ab46e4b7..30fb12584ff1cf293afac68c53d44002d845f55a 100755 (executable)
@@ -311,6 +311,13 @@ void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
 void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
                                   const std::string& theName)
 {
+  GeomShapePtr aResultShape = shape();
+
+  bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
+  if (aNewShapeIsNotInResultShape) {
+    return;
+  }
+
   TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
   builder(myFreePrimitiveTag)->Generated(aShape);
   if (!theName.empty()) {
@@ -565,7 +572,9 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
                                             const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
                                             const std::string& theName)
 {
+  GeomShapePtr aResultShape = shape();
   TopTools_MapOfShape anAlreadyProcessedShapes;
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   for (GeomAPI_ShapeExplorer anOldShapeExp(theOldShape, theShapeTypeToExplore);
        anOldShapeExp.more();
        anOldShapeExp.next())
@@ -573,8 +582,16 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
     GeomShapePtr anOldSubShape = anOldShapeExp.current();
     const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
 
-    // There is no sense to write history if shape already processed.
-    if (!anAlreadyProcessedShapes.Add(anOldSubShape_)) continue;
+    // There is no sense to write history if shape already processed
+    // or old shape does not exist in the document.
+    bool anOldSubShapeAlreadyProcessed = !anAlreadyProcessedShapes.Add(anOldSubShape_);
+    bool anOldSubShapeNotInTree = TNaming_Tool::NamedShape(anOldSubShape_, aData->shapeLab())
+                                  .IsNull();
+    if (anOldSubShapeAlreadyProcessed
+        || anOldSubShapeNotInTree)
+    {
+      continue;
+    }
 
     // Get new shapes.
     ListOfShape aNewShapes;
@@ -589,6 +606,14 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
       GeomShapePtr aNewShape = *aNewShapesIt;
       const TopoDS_Shape& aNewShape_ = aNewShape->impl<TopoDS_Shape>();
 
+      bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape);
+      bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false);
+      if (aNewShapeIsSameAsOldShape
+        || aNewShapeIsNotInResultShape)
+      {
+        continue;
+      }
+
       TopAbs_ShapeEnum aNewShapeType = aNewShape_.ShapeType();
       if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) {
         // TODO: This is a workaround. New shape should be only edge or face.
index 384bbd61a4c61a026cf0acc5467bcf5f7588b1f0..cfc9ff6e306d1b28ba1b12614e4def24dca8e0ac 100644 (file)
@@ -52,11 +52,44 @@ Model_ResultBody::~Model_ResultBody()
   delete myBuilder;
 }
 
-void Model_ResultBody::loadModifiedShapes(
-  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
-  const GeomShapePtr& theOldShape,
-  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
-  const std::string& theName)
+void Model_ResultBody::generated(const GeomShapePtr& theNewShape,
+                                 const std::string& theName)
+{
+  if (mySubs.size()) { // consists of subs
+    for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+         aSubIter != mySubs.cend();
+         ++aSubIter)
+    {
+      const ResultBodyPtr& aSub = *aSubIter;
+      aSub->generated(theNewShape, theName);
+    }
+  } else { // do for this directly
+    myBuilder->generated(theNewShape, theName);
+  }
+}
+
+void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+                                           const GeomShapePtr& theOldShape,
+                                           const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                           const std::string& theName)
+{
+  if (mySubs.size()) { // consists of subs
+    for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+         aSubIter != mySubs.cend();
+         ++aSubIter)
+    {
+      const ResultBodyPtr& aSub = *aSubIter;
+      aSub->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
+    }
+  } else { // do for this directly
+    myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
+  }
+}
+
+void Model_ResultBody::loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+                                          const GeomShapePtr& theOldShape,
+                                          const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                          const std::string& theName)
 {
   if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs
     // optimization of getting of new shapes for specific sub-result
index eda74f541740dafbc2ee62546cd848205bfddf2d..bca729d8f7a2d382cce2b282e94c760f7cea9801 100644 (file)
@@ -49,12 +49,24 @@ public:
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_ResultBody();
 
-  /// load and orient modified shapes for sub-objects
+  /// Records the subshape newShape which was generated during a topological construction.
+  /// As an example, consider the case of a face generated in construction of a box.
+  MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
+                                         const std::string& theName);
+
+  /// load generated shapes
+  MODELAPI_EXPORT
+  virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+                                   const GeomShapePtr& theOldShape,
+                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                   const std::string& theName = "") override;
+
+  /// load modified shapes for sub-objects
   MODEL_EXPORT
   virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
                                   const GeomShapePtr& theOldShape,
                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
-                                  const std::string& theName) override;
+                                  const std::string& theName = "") override;
 
 
   /// Returns the number of sub-elements