Salome HOME
Updated modified shapes storing.
authordbv <dbv@opencascade.com>
Tue, 16 Oct 2018 09:23:10 +0000 (12:23 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
52 files changed:
src/BuildPlugin/BuildPlugin_Compound.cpp
src/BuildPlugin/BuildPlugin_Edge.cpp
src/BuildPlugin/BuildPlugin_Interpolation.cpp
src/BuildPlugin/BuildPlugin_Polyline.cpp
src/BuildPlugin/BuildPlugin_Shell.cpp
src/BuildPlugin/BuildPlugin_Solid.cpp
src/BuildPlugin/BuildPlugin_SubShapes.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.h
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h
src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp
src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.h
src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.h
src/FeaturesPlugin/FeaturesPlugin_Scale.cpp
src/FeaturesPlugin/FeaturesPlugin_Scale.h
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.h
src/FeaturesPlugin/FeaturesPlugin_Tools.cpp
src/FeaturesPlugin/FeaturesPlugin_Tools.h
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.h
src/FeaturesPlugin/FeaturesPlugin_Union.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h
src/Model/Model_BodyBuilder.cpp
src/Model/Model_BodyBuilder.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/ModelAPI/ModelAPI_BodyBuilder.h
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h

index 69c8551bbbc6ee15bb9625feb7433c0858631ea6..39c136ade64a88c25d4ccaff449d24661fd8ea6f 100644 (file)
@@ -70,24 +70,16 @@ void BuildPlugin_Compound::execute()
   // Build compound.
   GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(anOriginalShapes);
   // Copy shape.
-  GeomAlgoAPI_Copy aCopyAlgo(aCompound);
-  GeomShapePtr aCopyCompound = aCopyAlgo.shape();
+  GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aCompound));
+  GeomShapePtr aCopyCompound = aCopyAlgo->shape();
 
   int anIndexToRemove = 0;
   if (aCopyCompound) {
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = aCopyAlgo.mapOfSubShapes();
-
     ResultBodyPtr aResultBody = document()->createBody(data(), anIndexToRemove++);
     aResultBody->store(aCopyCompound);
-    aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX,
-                                              1, "Modified_Vertex", *aMapOfShapes.get(),
-                                              true, false, true);
-    aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::EDGE,
-                                              100000, "Modified_Edge", *aMapOfShapes.get(),
-                                              true, false, true);
-    aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::FACE,
-                                              200000, "Modified_Face", *aMapOfShapes.get(),
-                                              true, false, true);
+    aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX, "Modified_Vertex");
+    aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::EDGE, "Modified_Edge");
+    aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::FACE, "Modified_Face");
     setResult(aResultBody);
   }
   removeResults(anIndexToRemove);
index 253de35b573f465e337c72eac1e9af642759c138..2004281d7783bc2820de073c82dff0d91a6ccd2a 100644 (file)
@@ -76,35 +76,30 @@ void BuildPlugin_Edge::execute()
     }
 
     // Copy shape.
-    GeomAlgoAPI_Copy aCopyAlgo(aShape);
+    GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
 
     // Check that algo is done.
-    if(!aCopyAlgo.isDone()) {
+    if(!aCopyAlgo->isDone()) {
       setError("Error: " + getKind() + " algorithm failed.");
       return;
     }
 
     // Check if shape is not null.
-    if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
+    if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) {
       setError("Error: Resulting shape is null.");
       return;
     }
 
     // Check that resulting shape is valid.
-    if(!aCopyAlgo.isValid()) {
+    if(!aCopyAlgo->isValid()) {
       setError("Error: Resulting shape is not valid.");
       return;
     }
 
     // Store result.
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    aResultBody->storeModified(aShape, aCopyAlgo.shape());
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = aCopyAlgo.mapOfSubShapes();
-    int aModVertexTag = 1;
-    std::string aModVertexName = "Modified_Vertex";
-    aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX,
-                                             aModVertexTag, aModVertexName, *aSubShapes.get(),
-                                             true);
+    aResultBody->storeModified(aShape, aCopyAlgo->shape());
+    aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::VERTEX, "Modified_Vertex");
 
     setResult(aResultBody, aResultIndex);
     ++aResultIndex;
index e1ace5e4a235293acad4fa5a670786c2259a4130..481a51ff1fe3d039528d1cf1277645fc1a85ae57 100644 (file)
@@ -128,7 +128,7 @@ void BuildPlugin_Interpolation::execute()
   ResultBodyPtr aResultBody = document()->createBody(data());
   std::set<GeomShapePtr>::const_iterator aContextIt = aContexts.begin();
   for (; aContextIt != aContexts.end(); aContextIt++) {
-    aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin() ? 0 : -2);
+    aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin());
   }
   int aVertexIndex = 1;
   for (GeomAPI_ShapeExplorer anExp(anEdge, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) {
index d06f265d142f822182d8666635d9d914d35103fd..312f1779082a6611a6930fb0f3a13eb2b31b9126 100644 (file)
@@ -107,7 +107,7 @@ void BuildPlugin_Polyline::execute()
   ResultBodyPtr aResultBody = document()->createBody(data());
   std::set<GeomShapePtr>::const_iterator aContextIt = aContexts.begin();
   for (; aContextIt != aContexts.end(); aContextIt++) {
-    aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin() ? 0 : -2);
+    aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin());
   }
 
   aPointsIt = aPoints.cbegin();
@@ -115,7 +115,7 @@ void BuildPlugin_Polyline::execute()
   for (; anExp.more() && aPointsIt != aPoints.cend(); anExp.next(), ++aPointsIt) {
     GeomShapePtr aPoint = *aPointsIt;
     GeomShapePtr anEdge = anExp.current();
-    aResultBody->generated(aPoint, anEdge, "Edge", 1);
+    aResultBody->generated(aPoint, anEdge, "Edge");
   }
 
   if (!isClosed) {
index 725f8d336949c7de467ce1b871ba516d8261b69b..9e55284cec355fc841f23b6ccc31ce5a74b3ff49 100644 (file)
@@ -56,29 +56,28 @@ void BuildPlugin_Shell::execute()
   }
 
   // Sew faces.
-  GeomAlgoAPI_Sewing aSewingAlgo(aShapes);
+  GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes));
 
   // Check that algo is done.
-  if(!aSewingAlgo.isDone()) {
+  if(!aSewingAlgo->isDone()) {
     setError("Error: " + getKind() + " algorithm failed.");
     return;
   }
 
   // Check if shape is not null.
-  if(!aSewingAlgo.shape().get() || aSewingAlgo.shape()->isNull()) {
+  if(!aSewingAlgo->shape().get() || aSewingAlgo->shape()->isNull()) {
     setError("Error: Resulting shape is null.");
     return;
   }
 
   // Check that resulting shape is valid.
-  if(!aSewingAlgo.isValid()) {
+  if(!aSewingAlgo->isValid()) {
     setError("Error: Resulting shape is not valid.");
     return;
   }
 
   // Store result.
-  GeomShapePtr aResult = aSewingAlgo.shape();
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = aSewingAlgo.mapOfSubShapes();
+  GeomShapePtr aResult = aSewingAlgo->shape();
 
   int anIndex = 0;
   for(GeomAPI_ShapeExplorer anExp(aResult, GeomAPI_Shape::SHELL); anExp.more(); anExp.next()) {
@@ -86,23 +85,27 @@ void BuildPlugin_Shell::execute()
     ResultBodyPtr aResultBody = document()->createBody(data(), anIndex);
     aResultBody->store(aShell);
     for(ListOfShape::const_iterator anIt = aShapes.cbegin(); anIt != aShapes.cend(); ++anIt) {
-      for(GeomAPI_ShapeExplorer
-          aFaceExp(*anIt, GeomAPI_Shape::FACE); aFaceExp.more(); aFaceExp.next()) {
+      for (GeomAPI_ShapeExplorer aFaceExp(*anIt, GeomAPI_Shape::FACE);
+           aFaceExp.more();
+           aFaceExp.next())
+      {
         GeomShapePtr aFace = aFaceExp.current();
         ListOfShape aHistory;
-        aSewingAlgo.modified(aFace, aHistory);
-        for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin();
-            aHistoryIt != aHistory.cend();
-            ++aHistoryIt) {
+        aSewingAlgo->modified(aFace, aHistory);
+        for (ListOfShape::const_iterator aHistoryIt = aHistory.cbegin();
+             aHistoryIt != aHistory.cend();
+             ++aHistoryIt)
+        {
           GeomShapePtr aHistoryShape = *aHistoryIt;
-          if(aMapOfShapes->isBound(aHistoryShape)) {
-            aHistoryShape = aMapOfShapes->find(aHistoryShape);
-          }
-          if(aShell->isSubShape(aHistoryShape)) {
-            aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::EDGE,
-                                                     1, "Modified_Edge", *aMapOfShapes.get());
-            aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::FACE,
-                                                     2, "Modified_Face", *aMapOfShapes.get());
+          if (aShell->isSubShape(aHistoryShape, false)) {
+            aResultBody->loadModifiedShapes(aSewingAlgo,
+                                            aFace,
+                                            GeomAPI_Shape::EDGE,
+                                            "Modified_Edge");
+            aResultBody->loadModifiedShapes(aSewingAlgo,
+                                            aFace,
+                                            GeomAPI_Shape::FACE,
+                                            "Modified_Face");
             break;
           }
         }
index 0f044564e5a0355f4c340ee5af970fd53f127953..6e79e3b89517d5c007eaefe40fe8598285bd890c 100644 (file)
@@ -60,19 +60,18 @@ void BuildPlugin_Solid::execute()
 
 void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes,
                                     const GeomShapePtr& theResultShape,
-                                    const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
+                                    const GeomMakeShapePtr& theAlgorithm)
 {
   ResultBodyPtr aResultBody = document()->createBody(data());
   aResultBody->store(theResultShape);
 
   // Store faces
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubs = theAlgorithm->mapOfSubShapes();
-  int aModifiedTag = 1;
-  for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
-      anIt != theOriginalShapes.cend(); ++anIt) {
+  for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
+       anIt != theOriginalShapes.cend();
+       ++anIt)
+  {
     GeomShapePtr aShape = *anIt;
-    aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE,
-        aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true);
+    aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE, "Modified_Face");
   }
   setResult(aResultBody);
 }
index 35aa48914036197f31628a583661cfce70f9c210..bb2fa74c94c37a538cb65dd1c7fa718708c61428 100644 (file)
@@ -105,9 +105,9 @@ void BuildPlugin_SubShapes::execute()
   if(!aBaseShape.get()) {
     return;
   }
-  GeomAlgoAPI_ShapeBuilder aBuilder;
-  aBuilder.removeInternal(aBaseShape);
-  GeomShapePtr aResultShape = aBuilder.shape();
+  std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder());
+  aBuilder->removeInternal(aBaseShape);
+  GeomShapePtr aResultShape = aBuilder->shape();
 
   // Get list of shapes.
   ListOfShape aShapesToAdd;
@@ -118,8 +118,8 @@ void BuildPlugin_SubShapes::execute()
 
   // Copy sub-shapes from list to new shape.
   if(!aShapesToAdd.empty()) {
-    aBuilder.addInternal(aResultShape, aShapesToAdd);
-    aResultShape = aBuilder.shape();
+    aBuilder->addInternal(aResultShape, aShapesToAdd);
+    aResultShape = aBuilder->shape();
   }
 
   // Store result.
@@ -127,15 +127,17 @@ void BuildPlugin_SubShapes::execute()
   const int aModEdgeTag = 2;
   ResultBodyPtr aResultBody = document()->createBody(data());
   aResultBody->storeModified(aBaseShape, aResultShape);
-  aResultBody->loadAndOrientModifiedShapes(&aBuilder, aBaseShape, GeomAPI_Shape::EDGE, aModEdgeTag,
-                                          "Modified_Edge", *aBuilder.mapOfSubShapes().get());
-  for(ListOfShape::const_iterator
-      anIt = aShapesToAdd.cbegin(); anIt != aShapesToAdd.cend(); ++anIt) {
+  aResultBody->loadModifiedShapes(aBuilder, aBaseShape, GeomAPI_Shape::EDGE, "Modified_Edge");
+  for (ListOfShape::const_iterator anIt = aShapesToAdd.cbegin();
+       anIt != aShapesToAdd.cend();
+       ++anIt)
+  {
     GeomAPI_Shape::ShapeType aShType = (*anIt)->shapeType();
-    aResultBody->loadAndOrientModifiedShapes(&aBuilder, *anIt, aShType,
-                        aShType == GeomAPI_Shape::VERTEX ? aModVertexTag : aModEdgeTag,
-                        aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex" : "Modified_Edge",
-                        *aBuilder.mapOfSubShapes().get());
+    aResultBody->loadModifiedShapes(aBuilder,
+                                    *anIt,
+                                    aShType,
+                                    aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex"
+                                                                     : "Modified_Edge");
   }
   setResult(aResultBody);
 }
index 99afc6e8dbf6d78c1c37838d639f26fad7caf9f4..e12238eaa5bc1cc43880aabd984621456e9d1c23 100644 (file)
@@ -167,7 +167,7 @@ void FeaturesPlugin_Boolean::execute()
         std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
         ListOfShape aListWithObject;
         aListWithObject.push_back(anObject);
-        GeomAlgoAPI_MakeShapeList aMakeShapeList;
+        std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
         std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
         GeomShapePtr aResShape;
 
@@ -201,7 +201,7 @@ void FeaturesPlugin_Boolean::execute()
               std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
                 new GeomAlgoAPI_MakeShapeCustom);
               aMkShCustom->addModified(aPlane, aTool);
-              aMakeShapeList.appendAlgo(aMkShCustom);
+              aMakeShapeList->appendAlgo(aMkShCustom);
               aToolsWithPlanes.push_back(aTool);
             }
 
@@ -241,7 +241,7 @@ void FeaturesPlugin_Boolean::execute()
           return;
         }
 
-        aMakeShapeList.appendAlgo(aBoolAlgo);
+        aMakeShapeList->appendAlgo(aBoolAlgo);
 
         if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27
            || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON))
@@ -254,9 +254,7 @@ void FeaturesPlugin_Boolean::execute()
             aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end());
           }
 
-          loadNamingDS(aResultBody, anObject, aUsedTools, aResShape,
-                       aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()),
-                       myOperationType == BOOL_FILL);
+          loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, aMakeShapeList);
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -285,7 +283,7 @@ void FeaturesPlugin_Boolean::execute()
           }
         }
 
-        GeomAlgoAPI_MakeShapeList aMakeShapeList;
+        std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
         std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
 
         switch(myOperationType) {
@@ -316,7 +314,7 @@ void FeaturesPlugin_Boolean::execute()
               std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
                 new GeomAlgoAPI_MakeShapeCustom);
               aMkShCustom->addModified(aPlane, aTool);
-              aMakeShapeList.appendAlgo(aMkShCustom);
+              aMakeShapeList->appendAlgo(aMkShCustom);
               aToolsWithPlanes.push_back(aTool);
             }
 
@@ -342,9 +340,7 @@ void FeaturesPlugin_Boolean::execute()
           return;
         }
 
-        aMakeShapeList.appendAlgo(aBoolAlgo);
-        GeomAPI_DataMapOfShapeShape aMapOfShapes;
-        aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
+        aMakeShapeList->appendAlgo(aBoolAlgo);
         GeomShapePtr aResultShape = aBoolAlgo->shape();
 
         // Add result to not used solids from compsolid.
@@ -359,8 +355,7 @@ void FeaturesPlugin_Boolean::execute()
             return;
           }
 
-          aMakeShapeList.appendAlgo(aFillerAlgo);
-          aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+          aMakeShapeList->appendAlgo(aFillerAlgo);
           aResultShape = aFillerAlgo->shape();
         }
 
@@ -379,9 +374,7 @@ void FeaturesPlugin_Boolean::execute()
                        aCompSolid,
                        aUsedTools,
                        aResultShape,
-                       aMakeShapeList,
-                       aMapOfShapes,
-                       myOperationType == BOOL_FILL);
+                       aMakeShapeList);
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -432,16 +425,14 @@ void FeaturesPlugin_Boolean::execute()
       anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end());
 
       // Cut edges and faces(if we have any) with solids.
-      GeomAlgoAPI_MakeShapeList aMakeShapeList;
-      GeomAPI_DataMapOfShapeShape aMapOfShapes;
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
       std::shared_ptr<GeomAPI_Shape> aCuttedEdgesAndFaces;
       if(!anEdgesAndFaces.empty()) {
         std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
                                             anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT));
         if(aCutAlgo->isDone()) {
           aCuttedEdgesAndFaces = aCutAlgo->shape();
-          aMakeShapeList.appendAlgo(aCutAlgo);
-          aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+          aMakeShapeList->appendAlgo(aCutAlgo);
         }
       }
       anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(),
@@ -459,8 +450,7 @@ void FeaturesPlugin_Boolean::execute()
 
           if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
             aSolidsToFuse.push_back(aCutAlgo->shape());
-            aMakeShapeList.appendAlgo(aCutAlgo);
-            aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+            aMakeShapeList->appendAlgo(aCutAlgo);
           }
         }
       }
@@ -501,8 +491,7 @@ void FeaturesPlugin_Boolean::execute()
         }
 
         aShape = aFuseAlgo->shape();
-        aMakeShapeList.appendAlgo(aFuseAlgo);
-        aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+        aMakeShapeList->appendAlgo(aFuseAlgo);
       }
 
       // Combine result with not used solids from compsolid and edges and faces (if we have any).
@@ -534,8 +523,7 @@ void FeaturesPlugin_Boolean::execute()
         }
 
         aShape = aFillerAlgo->shape();
-        aMakeShapeList.appendAlgo(aFillerAlgo);
-        aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+        aMakeShapeList->appendAlgo(aFillerAlgo);
       }
 
       std::shared_ptr<GeomAPI_Shape> aBackShape = anOriginalShapes.back();
@@ -543,7 +531,7 @@ void FeaturesPlugin_Boolean::execute()
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
       loadNamingDS(aResultBody, aBackShape, anOriginalShapes,
-                   aShape, aMakeShapeList, aMapOfShapes);
+                   aShape, aMakeShapeList);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
       break;
@@ -592,7 +580,7 @@ void FeaturesPlugin_Boolean::execute()
         }
       }
 
-      GeomAlgoAPI_MakeShapeList aMakeShapeList;
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList;
       GeomAPI_DataMapOfShapeShape aMapOfShapes;
       if(!aShapesToAdd.empty()) {
         // Cut objects with not used solids.
@@ -604,7 +592,7 @@ void FeaturesPlugin_Boolean::execute()
         if(GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) {
           aShapesToSmash.clear();
           aShapesToSmash.push_back(anObjectsCutAlgo->shape());
-          aMakeShapeList.appendAlgo(anObjectsCutAlgo);
+          aMakeShapeList->appendAlgo(anObjectsCutAlgo);
           aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes());
         }
 
@@ -616,7 +604,7 @@ void FeaturesPlugin_Boolean::execute()
         if(GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) {
           aTools.clear();
           aTools.push_back(aToolsCutAlgo->shape());
-          aMakeShapeList.appendAlgo(aToolsCutAlgo);
+          aMakeShapeList->appendAlgo(aToolsCutAlgo);
           aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes());
         }
       }
@@ -642,7 +630,7 @@ void FeaturesPlugin_Boolean::execute()
         setError(aFeatureError);
         return;
       }
-      aMakeShapeList.appendAlgo(aBoolAlgo);
+      aMakeShapeList->appendAlgo(aBoolAlgo);
       aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
 
       // Put all (cut result, tools and not used solids) to PaveFiller.
@@ -668,15 +656,14 @@ void FeaturesPlugin_Boolean::execute()
       }
 
       std::shared_ptr<GeomAPI_Shape> aShape = aFillerAlgo->shape();
-      aMakeShapeList.appendAlgo(aFillerAlgo);
+      aMakeShapeList->appendAlgo(aFillerAlgo);
       aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
 
       std::shared_ptr<GeomAPI_Shape> aFrontShape = anOriginalShapes.front();
       anOriginalShapes.pop_front();
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
-      loadNamingDS(aResultBody, aFrontShape, anOriginalShapes,
-        aShape, aMakeShapeList, aMapOfShapes);
+      loadNamingDS(aResultBody, aFrontShape, anOriginalShapes, aShape, aMakeShapeList);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
 
@@ -697,49 +684,37 @@ void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> t
                                           const std::shared_ptr<GeomAPI_Shape> theBaseShape,
                                           const ListOfShape& theTools,
                                           const std::shared_ptr<GeomAPI_Shape> theResultShape,
-                                          GeomAlgoAPI_MakeShape& theMakeShape,
-                                          GeomAPI_DataMapOfShapeShape& theMapOfShapes,
-                                          const bool theIsStoreAsGenerated)
+                                          const GeomMakeShapePtr& theMakeShape)
 {
   //load result
   if(theBaseShape->isEqual(theResultShape)) {
     theResultBody->store(theResultShape, false);
-  } else {
-    const int aModifyTag = 1;
-    const int aModifyEdgeTag = 2;
-    const int aModifyFaceTag = 3;
-    const int aDeletedTag = 4;
-    /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
-    const int aSubsolidsTag = 5;
-
-    theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
-    const std::string aModName = "Modified";
-    const std::string aModEName = "Modified_Edge";
-    const std::string aModFName = "Modified_Face";
-
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
-      aModifyEdgeTag, aModEName, theMapOfShapes, false, theIsStoreAsGenerated, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
-      aModifyFaceTag, aModFName, theMapOfShapes, false, theIsStoreAsGenerated, true);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::FACE, aDeletedTag);
-
-    int aTag;
-    std::string aName;
-    for(ListOfShape::const_iterator
-        anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
-      if((*anIter)->shapeType() <= GeomAPI_Shape::FACE) {
-        aTag = aModifyFaceTag;
-        aName = aModFName;
-      } else {
-        aTag = aModifyEdgeTag;
-        aName = aModEName;
-      }
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter,
-        aName == aModEName ? GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE,
-        aTag, aName, theMapOfShapes, false, theIsStoreAsGenerated, true);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
-    }
+    return;
+  }
+
+  theResultBody->storeModified(theBaseShape, theResultShape);
+
+  const std::string aModEName = "Modified_Edge";
+  const std::string aModFName = "Modified_Face";
+
+  theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, aModEName);
+  theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFName);
+
+  theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
+
+  std::string aName;
+  for (ListOfShape::const_iterator anIter = theTools.begin();
+       anIter != theTools.end();
+       ++anIter)
+  {
+    aName = (*anIter)->shapeType() <= GeomAPI_Shape::FACE ? aModFName
+                                                          : aModEName;
+    theResultBody->loadModifiedShapes(theMakeShape,
+                                      *anIter,
+                                      aName == aModEName ? GeomAPI_Shape::EDGE
+                                                         : GeomAPI_Shape::FACE,
+                                      aName);
+
+    theResultBody->loadDeletedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
   }
 }
index ce70e57bc619a23adb39ed2f23015eab795ec68b..95db064609c677506bd12fb4640afcb6840ad484 100644 (file)
@@ -78,9 +78,7 @@ private:
                     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
                     const ListOfShape& theTools,
                     const std::shared_ptr<GeomAPI_Shape> theResultShape,
-                    GeomAlgoAPI_MakeShape& theMakeShape,
-                    GeomAPI_DataMapOfShapeShape& theMapOfShapes,
-                    const bool theIsStoreAsGenerated = false);
+                    const GeomMakeShapePtr& theMakeShape);
 
 private:
   OperationType myOperationType;
index c8cee631839272fbef71d96a584e6e4fad907cae..d52e23146cafe523e46af72d592c0d667517689d 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "FeaturesPlugin_BooleanCommon.h"
 
+#include "FeaturesPlugin_Tools.h"
+
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
@@ -125,8 +127,9 @@ void FeaturesPlugin_BooleanCommon::execute()
   }
 
   int aResultIndex = 0;
-  GeomAlgoAPI_MakeShapeList aMakeShapeList;
-  GeomAPI_DataMapOfShapeShape aMapOfShapes;
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
+  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+  ListOfShape aResultShapesList;
 
   if (isSimpleMode)
   {
@@ -155,8 +158,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       }
 
       aShape = aCommonAlgo->shape();
-      aMakeShapeList.appendAlgo(aCommonAlgo);
-      aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes());
+      aMakeShapeList->appendAlgo(aCommonAlgo);
     }
 
     GeomAPI_ShapeIterator aShapeIt(aShape);
@@ -164,9 +166,23 @@ void FeaturesPlugin_BooleanCommon::execute()
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
 
-      loadNamingDS(aResultBody, anObjects.front(), anObjects, aShape, aMakeShapeList, aMapOfShapes);
+      GeomShapePtr aBaseShape = anObjects.front();
+      anObjects.pop_front();
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aBaseShape,
+                                               anObjects,
+                                               aMakeShapeList,
+                                               aShape);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
+
+      aTools = anObjects;
+      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+      aRBA.resultBody = aResultBody;
+      aRBA.baseShape = aBaseShape;
+      aRBA.makeShape = aMakeShapeList;
+      aResultBaseAlgoList.push_back(aRBA);
+      aResultShapesList.push_back(aShape);
     }
   } else {
     for (ListOfShape::iterator anObjectsIt = anObjects.begin();
@@ -176,7 +192,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
       ListOfShape aListWithObject;
       aListWithObject.push_back(anObject);
-      GeomAlgoAPI_MakeShapeList aMakeShapeList;
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
       std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
       GeomShapePtr aResShape;
 
@@ -193,7 +209,7 @@ void FeaturesPlugin_BooleanCommon::execute()
         std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
           new GeomAlgoAPI_MakeShapeCustom);
         aMkShCustom->addModified(aPlane, aTool);
-        aMakeShapeList.appendAlgo(aMkShCustom);
+        aMakeShapeList->appendAlgo(aMkShCustom);
         aToolsWithPlanes.push_back(aTool);
       }
 
@@ -219,17 +235,27 @@ void FeaturesPlugin_BooleanCommon::execute()
         return;
       }
 
-      aMakeShapeList.appendAlgo(aBoolAlgo);
+      aMakeShapeList->appendAlgo(aBoolAlgo);
 
       GeomAPI_ShapeIterator aShapeIt(aResShape);
       if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
         std::shared_ptr<ModelAPI_ResultBody> aResultBody =
           document()->createBody(data(), aResultIndex);
 
-        loadNamingDS(aResultBody, anObject, aTools, aResShape,
-                     aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()));
+        FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                                 anObject,
+                                                 aTools,
+                                                 aMakeShapeList,
+                                                 aResShape);
         setResult(aResultBody, aResultIndex);
         aResultIndex++;
+
+        FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+        aRBA.resultBody = aResultBody;
+        aRBA.baseShape = anObject;
+        aRBA.makeShape = aMakeShapeList;
+        aResultBaseAlgoList.push_back(aRBA);
+        aResultShapesList.push_back(aResShape);
       }
     }
 
@@ -284,8 +310,6 @@ void FeaturesPlugin_BooleanCommon::execute()
       }
 
       aMakeShapeList->appendAlgo(aCommonAlgo);
-      GeomAPI_DataMapOfShapeShape aMapOfShapes;
-      aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes());
       GeomShapePtr aResultShape = aCommonAlgo->shape();
 
       // Add result to not used solids from compsolid.
@@ -301,7 +325,6 @@ void FeaturesPlugin_BooleanCommon::execute()
         }
 
         aMakeShapeList->appendAlgo(aFillerAlgo);
-        aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
         aResultShape = aFillerAlgo->shape();
       }
 
@@ -311,14 +334,20 @@ void FeaturesPlugin_BooleanCommon::execute()
         std::shared_ptr<ModelAPI_ResultBody> aResultBody =
           document()->createBody(data(), aResultIndex);
 
-        loadNamingDS(aResultBody,
-          aCompSolid,
-          aTools,
-          aResultShape,
-          *aMakeShapeList,
-          aMapOfShapes);
+        FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                                 aCompSolid,
+                                                 aTools,
+                                                 aMakeShapeList,
+                                                 aResultShape);
         setResult(aResultBody, aResultIndex);
         aResultIndex++;
+
+        FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+        aRBA.resultBody = aResultBody;
+        aRBA.baseShape = aCompSolid;
+        aRBA.makeShape = aMakeShapeList;
+        aResultBaseAlgoList.push_back(aRBA);
+        aResultShapesList.push_back(aResultShape);
       }
     }
 
@@ -373,8 +402,6 @@ void FeaturesPlugin_BooleanCommon::execute()
       }
 
       aMakeShapeList->appendAlgo(aCommonAlgo);
-      GeomAPI_DataMapOfShapeShape aMapOfShapes;
-      aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes());
       GeomShapePtr aResultShape = aCommonAlgo->shape();
 
       // Add result to not used shape from compound.
@@ -402,82 +429,30 @@ void FeaturesPlugin_BooleanCommon::execute()
         std::shared_ptr<ModelAPI_ResultBody> aResultBody =
           document()->createBody(data(), aResultIndex);
 
-        loadNamingDS(aResultBody,
-          aCompound,
-          aTools,
-          aResultShape,
-          *aMakeShapeList,
-          aMapOfShapes);
+        FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                                 aCompound,
+                                                 aTools,
+                                                 aMakeShapeList,
+                                                 aResultShape);
         setResult(aResultBody, aResultIndex);
         aResultIndex++;
+
+        FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+        aRBA.resultBody = aResultBody;
+        aRBA.baseShape = aCompound;
+        aRBA.makeShape = aMakeShapeList;
+        aResultBaseAlgoList.push_back(aRBA);
+        aResultShapesList.push_back(aResultShape);
       }
     }
 
   }
 
+  // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
+  // result shape has been deleted, but in another it was modified or stayed.
+  GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+  FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
-
-//==================================================================================================
-void FeaturesPlugin_BooleanCommon::loadNamingDS(ResultBodyPtr theResultBody,
-                                                const GeomShapePtr theBaseShape,
-                                                const ListOfShape& theTools,
-                                                const GeomShapePtr theResultShape,
-                                                GeomAlgoAPI_MakeShape& theMakeShape,
-                                                GeomAPI_DataMapOfShapeShape& theMapOfShapes)
-{
-  //load result
-  if (theBaseShape->isEqual(theResultShape)) {
-    theResultBody->store(theResultShape, false);
-  } else {
-    const int aModifyVTag = 1;
-    const int aModifyETag = 2;
-    const int aModifyFTag = 3;
-    const int aDeletedTag = 4;
-    /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
-    const int aSubsolidsTag = 5;
-
-    theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
-    const std::string aModVName = "Modified_Vertex";
-    const std::string aModEName = "Modified_Edge";
-    const std::string aModFName = "Modified_Face";
-
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
-                                               aModifyVTag, aModVName, theMapOfShapes, false,
-                                               false, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
-                                               aModifyETag, aModEName, theMapOfShapes, false,
-                                               false, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
-                                               aModifyFTag, aModFName, theMapOfShapes, false,
-                                               false, true);
-
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::VERTEX, aDeletedTag);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::EDGE, aDeletedTag);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::FACE, aDeletedTag);
-
-    for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
-    {
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
-                                                 aModifyVTag, aModVName, theMapOfShapes, false,
-                                                 false, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
-                                                 aModifyETag, aModEName, theMapOfShapes, false,
-                                                 false, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
-                                                 aModifyFTag, aModFName, theMapOfShapes, false,
-                                                 false, true);
-
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
-    }
-  }
-}
index caf67d38e76c1c90999d0bca2eeda1ccd583a49c..d7dafcd6714ab29d823391392ba84fb10c9930e1 100644 (file)
@@ -91,17 +91,6 @@ public:
 
   /// Use plugin manager for features creation.
   FeaturesPlugin_BooleanCommon();
-
-private:
-
-  /// Load Naming data structure of the feature to the document
-  void loadNamingDS(ResultBodyPtr theResultBody,
-                    const GeomShapePtr theBaseShape,
-                    const ListOfShape& theTools,
-                    const GeomShapePtr theResultShape,
-                    GeomAlgoAPI_MakeShape& theMakeShape,
-                    GeomAPI_DataMapOfShapeShape& theMapOfShapes);
-
 };
 
 #endif
index 79b959e9b0531737345e9344fe49d12dc539ae44..ae5cac2f5add913a2b01f1c5bcd7a0a84b4c81dc 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "FeaturesPlugin_BooleanCut.h"
 
+#include "FeaturesPlugin_Tools.h"
+
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
-//==================================================================================================
-const int ModifyVTag = 1;
-const int ModifyETag = 2;
-const int ModifyFTag = 3;
-const int DeletedTag = 4;
-/// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
-const int SubsolidsTag = 5;
-
-
 //==================================================================================================
 FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT)
@@ -108,7 +101,7 @@ void FeaturesPlugin_BooleanCut::execute()
     return;
   }
 
-  std::vector<ResultBaseAlgo> aResultBaseAlgoList;
+  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
 
   // For solids cut each object with all tools.
@@ -148,13 +141,15 @@ void FeaturesPlugin_BooleanCut::execute()
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
 
-      loadNamingDS(aResultBody, anObject, aTools, aResShape,
-                   *aMakeShapeList, *(aCutAlgo->mapOfSubShapes()),
-                   false);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               anObject,
+                                               aTools,
+                                               aMakeShapeList,
+                                               aResShape);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
 
-      ResultBaseAlgo aRBA;
+      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
       aRBA.resultBody = aResultBody;
       aRBA.baseShape = anObject;
       aRBA.makeShape = aMakeShapeList;
@@ -214,8 +209,6 @@ void FeaturesPlugin_BooleanCut::execute()
     }
 
     aMakeShapeList->appendAlgo(aCutAlgo);
-    GeomAPI_DataMapOfShapeShape aMapOfShapes;
-    aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
     GeomShapePtr aResultShape = aCutAlgo->shape();
 
     // Add result to not used solids from compsolid.
@@ -231,7 +224,6 @@ void FeaturesPlugin_BooleanCut::execute()
       }
 
       aMakeShapeList->appendAlgo(aFillerAlgo);
-      aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
       aResultShape = aFillerAlgo->shape();
     }
 
@@ -241,17 +233,15 @@ void FeaturesPlugin_BooleanCut::execute()
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
 
-      loadNamingDS(aResultBody,
-                   aCompSolid,
-                   aTools,
-                   aResultShape,
-                   *aMakeShapeList,
-                   aMapOfShapes,
-                   false);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aCompSolid,
+                                               aTools,
+                                               aMakeShapeList,
+                                               aResultShape);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
 
-      ResultBaseAlgo aRBA;
+      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
       aRBA.resultBody = aResultBody;
       aRBA.baseShape = aCompSolid;
       aRBA.makeShape = aMakeShapeList;
@@ -311,8 +301,6 @@ void FeaturesPlugin_BooleanCut::execute()
     }
 
     aMakeShapeList->appendAlgo(aCutAlgo);
-    GeomAPI_DataMapOfShapeShape aMapOfShapes;
-    aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
     GeomShapePtr aResultShape = aCutAlgo->shape();
 
     // Add result to not used shape from compound.
@@ -338,17 +326,15 @@ void FeaturesPlugin_BooleanCut::execute()
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
 
-      loadNamingDS(aResultBody,
-                   aCompound,
-                   aTools,
-                   aResultShape,
-                   *aMakeShapeList,
-                   aMapOfShapes,
-                   false);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aCompound,
+                                               aTools,
+                                               aMakeShapeList,
+                                               aResultShape);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
 
-      ResultBaseAlgo aRBA;
+      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
       aRBA.resultBody = aResultBody;
       aRBA.baseShape = aCompound;
       aRBA.makeShape = aMakeShapeList;
@@ -360,102 +346,8 @@ void FeaturesPlugin_BooleanCut::execute()
   // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
   // result shape has been deleted, but in another it was modified or stayed.
   GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
-  storeDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+  FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
-
-//==================================================================================================
-void FeaturesPlugin_BooleanCut::loadNamingDS(ResultBodyPtr theResultBody,
-                                             const GeomShapePtr theBaseShape,
-                                             const ListOfShape& theTools,
-                                             const GeomShapePtr theResultShape,
-                                             GeomAlgoAPI_MakeShape& theMakeShape,
-                                             GeomAPI_DataMapOfShapeShape& theMapOfShapes,
-                                             const bool theIsStoreAsGenerated)
-{
-  //load result
-  if(theBaseShape->isEqual(theResultShape)) {
-    theResultBody->store(theResultShape, false);
-  } else {
-    theResultBody->storeModified(theBaseShape, theResultShape, SubsolidsTag);
-
-    const std::string aModVName = "Modified_Vertex";
-    const std::string aModEName = "Modified_Edge";
-    const std::string aModFName = "Modified_Face";
-
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
-                                               ModifyVTag, aModVName, theMapOfShapes, false,
-                                               theIsStoreAsGenerated, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
-                                               ModifyETag, aModEName, theMapOfShapes, false,
-                                               theIsStoreAsGenerated, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
-                                               ModifyFTag, aModFName, theMapOfShapes, false,
-                                               theIsStoreAsGenerated, true);
-
-    for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
-    {
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
-                                                 ModifyVTag, aModVName, theMapOfShapes, false,
-                                                 theIsStoreAsGenerated, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
-                                                 ModifyETag, aModEName, theMapOfShapes, false,
-                                                 theIsStoreAsGenerated, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
-                                                 ModifyFTag, aModFName, theMapOfShapes, false,
-                                                 theIsStoreAsGenerated, true);
-    }
-  }
-}
-
-//==================================================================================================
-void FeaturesPlugin_BooleanCut::storeDeletedShapes(
-  std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
-  const ListOfShape& theTools,
-  const GeomShapePtr theResultShapesCompound)
-{
-  for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
-       anIt != theResultBaseAlgoList.end();
-       ++anIt)
-  {
-    ResultBaseAlgo& aRCA = *anIt;
-    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
-                                       aRCA.baseShape,
-                                       GeomAPI_Shape::VERTEX,
-                                       DeletedTag,
-                                       theResultShapesCompound);
-    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
-                                       aRCA.baseShape,
-                                       GeomAPI_Shape::EDGE,
-                                       DeletedTag,
-                                       theResultShapesCompound);
-    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
-                                       aRCA.baseShape,
-                                       GeomAPI_Shape::FACE,
-                                       DeletedTag,
-                                       theResultShapesCompound);
-
-    for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
-    {
-      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
-                                         *anIter,
-                                         GeomAPI_Shape::VERTEX,
-                                         DeletedTag,
-                                         theResultShapesCompound);
-      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
-                                         *anIter,
-                                         GeomAPI_Shape::EDGE,
-                                         DeletedTag,
-                                         theResultShapesCompound);
-      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
-                                         *anIter,
-                                         GeomAPI_Shape::FACE,
-                                         DeletedTag,
-                                         theResultShapesCompound);
-    }
-  }
-}
index 11c154ced95cca7479ef5b131460c7da9e071ece..2cc8048f838de227ec84ce87085c98722b4e892f 100644 (file)
@@ -55,30 +55,6 @@ public:
   /// Use plugin manager for features creation.
   FeaturesPlugin_BooleanCut();
 
-private:
-
-  struct ResultBaseAlgo {
-    ResultBodyPtr resultBody;
-    GeomShapePtr baseShape;
-    std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape;
-  };
-
-private:
-
-  /// Load Naming data structure of the feature to the document
-  void loadNamingDS(ResultBodyPtr theResultBody,
-                    const GeomShapePtr theBaseShape,
-                    const ListOfShape& theTools,
-                    const GeomShapePtr theResultShape,
-                    GeomAlgoAPI_MakeShape& theMakeShape,
-                    GeomAPI_DataMapOfShapeShape& theMapOfShapes,
-                    const bool theIsStoreAsGenerated = false);
-
-  /// Stores deleted shapes.
-  void storeDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
-                          const ListOfShape& theTools,
-                          const GeomShapePtr theResultShapesCompound);
-
 };
 
 #endif
index 0f1ac4f724384ff62e4321a7e50b8bbd1071be19..b09cde2e789df9def3dc58a434ea18b1caa17610 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "FeaturesPlugin_BooleanFuse.h"
 
+#include "FeaturesPlugin_Tools.h"
+
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeSelectionList.h>
@@ -59,13 +61,14 @@ void FeaturesPlugin_BooleanFuse::initAttributes()
 void FeaturesPlugin_BooleanFuse::execute()
 {
   ListOfShape anObjects, aTools, anEdgesAndFaces;
-  std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
+  std::map<GeomShapePtr, ListOfShape> aCompSolidsObjects;
 
   bool isSimpleCreation = false;
 
   AttributeStringPtr aCreationMethodAttr = string(CREATION_METHOD());
   if (aCreationMethodAttr.get()
-      && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE()) {
+      && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE())
+  {
     isSimpleCreation = true;
   }
 
@@ -74,7 +77,7 @@ void FeaturesPlugin_BooleanFuse::execute()
     selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
   for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
     AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
-    std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
+    GeomShapePtr anObject = anObjectAttr->value();
     if (!anObject.get()) {
       return;
     }
@@ -82,9 +85,10 @@ void FeaturesPlugin_BooleanFuse::execute()
     ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
     if (!isSimpleCreation
         && aResCompSolidPtr.get()
-        && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) {
-      std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
-      std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
+        && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID)
+    {
+      GeomShapePtr aContextShape = aResCompSolidPtr->shape();
+      std::map<GeomShapePtr, ListOfShape>::iterator
         anIt = aCompSolidsObjects.begin();
       for (; anIt != aCompSolidsObjects.end(); anIt++) {
         if (anIt->first->isEqual(aContextShape)) {
@@ -136,10 +140,11 @@ void FeaturesPlugin_BooleanFuse::execute()
   // Collecting solids from compsolids which will not be modified
   // in boolean operation and will be added to result.
   ListOfShape aShapesToAdd;
-  for (std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
-       anIt = aCompSolidsObjects.begin();
-       anIt != aCompSolidsObjects.end(); anIt++) {
-    std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
+  for (std::map<GeomShapePtr, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
+       anIt != aCompSolidsObjects.end();
+       ++anIt)
+  {
+    GeomShapePtr aCompSolid = anIt->first;
     ListOfShape& aUsedInOperationSolids = anIt->second;
     aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(),
                          aUsedInOperationSolids.end());
@@ -147,7 +152,7 @@ void FeaturesPlugin_BooleanFuse::execute()
     // Collect solids from compsolid which will not be modified in boolean operation.
     for (GeomAPI_ShapeExplorer
          anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
-      std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
+      GeomShapePtr aSolidInCompSolid = anExp.current();
       ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
       for (; anIt != aUsedInOperationSolids.end(); anIt++) {
         if (aSolidInCompSolid->isEqual(*anIt)) {
@@ -164,16 +169,14 @@ void FeaturesPlugin_BooleanFuse::execute()
   anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end());
 
   // Cut edges and faces(if we have any) with solids.
-  GeomAlgoAPI_MakeShapeList aMakeShapeList;
-  GeomAPI_DataMapOfShapeShape aMapOfShapes;
-  std::shared_ptr<GeomAPI_Shape> aCuttedEdgesAndFaces;
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
+  GeomShapePtr aCuttedEdgesAndFaces;
   if (!anEdgesAndFaces.empty()) {
     std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
       anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT));
     if (aCutAlgo->isDone()) {
       aCuttedEdgesAndFaces = aCutAlgo->shape();
-      aMakeShapeList.appendAlgo(aCutAlgo);
-      aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+      aMakeShapeList->appendAlgo(aCutAlgo);
     }
   }
   anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(),
@@ -191,8 +194,7 @@ void FeaturesPlugin_BooleanFuse::execute()
 
       if (GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
         aSolidsToFuse.push_back(aCutAlgo->shape());
-        aMakeShapeList.appendAlgo(aCutAlgo);
-        aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+        aMakeShapeList->appendAlgo(aCutAlgo);
       }
     }
   }
@@ -205,7 +207,7 @@ void FeaturesPlugin_BooleanFuse::execute()
   }
 
   // Fuse all objects and all tools.
-  std::shared_ptr<GeomAPI_Shape> aShape;
+  GeomShapePtr aShape;
   if (anObjects.size() == 1 && aTools.empty()) {
     aShape = anObjects.front();
   } else if (anObjects.empty() && aTools.size() == 1) {
@@ -233,8 +235,7 @@ void FeaturesPlugin_BooleanFuse::execute()
     }
 
     aShape = aFuseAlgo->shape();
-    aMakeShapeList.appendAlgo(aFuseAlgo);
-    aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+    aMakeShapeList->appendAlgo(aFuseAlgo);
   }
 
   // Combine result with not used solids from compsolid and edges and faces (if we have any).
@@ -266,8 +267,7 @@ void FeaturesPlugin_BooleanFuse::execute()
     }
 
     aShape = aFillerAlgo->shape();
-    aMakeShapeList.appendAlgo(aFillerAlgo);
-    aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+    aMakeShapeList->appendAlgo(aFillerAlgo);
   }
 
   bool isRemoveEdges = false;
@@ -297,84 +297,29 @@ void FeaturesPlugin_BooleanFuse::execute()
     }
 
     aShape = aUnifyAlgo->shape();
-    aMakeShapeList.appendAlgo(aUnifyAlgo);
-    aMapOfShapes.merge(aUnifyAlgo->mapOfSubShapes());
+    aMakeShapeList->appendAlgo(aUnifyAlgo);
   }
 
   int aResultIndex = 0;
 
-  std::shared_ptr<GeomAPI_Shape> aBackShape = anOriginalShapes.back();
+  GeomShapePtr aBackShape = anOriginalShapes.back();
   anOriginalShapes.pop_back();
-  std::shared_ptr<ModelAPI_ResultBody> aResultBody =
-    document()->createBody(data(), aResultIndex);
-  loadNamingDS(aResultBody, aBackShape, anOriginalShapes,
-               aShape, aMakeShapeList, aMapOfShapes);
+  ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+
+  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                           aBackShape,
+                                           anOriginalShapes,
+                                           aMakeShapeList,
+                                           aShape);
   setResult(aResultBody, aResultIndex);
   aResultIndex++;
 
+  FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
+                                          aBackShape,
+                                          anOriginalShapes,
+                                          aMakeShapeList,
+                                          aShape);
+
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
-
-//==================================================================================================
-void FeaturesPlugin_BooleanFuse::loadNamingDS(ResultBodyPtr theResultBody,
-                                              const GeomShapePtr theBaseShape,
-                                              const ListOfShape& theTools,
-                                              const GeomShapePtr theResultShape,
-                                              GeomAlgoAPI_MakeShape& theMakeShape,
-                                              GeomAPI_DataMapOfShapeShape& theMapOfShapes)
-{
-  //load result
-  if (theBaseShape->isEqual(theResultShape)) {
-    theResultBody->store(theResultShape, false);
-  } else {
-    const int aModifyVTag = 1;
-    const int aModifyETag = 2;
-    const int aModifyFTag = 3;
-    const int aDeletedTag = 4;
-    /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
-    const int aSubsolidsTag = 5;
-
-    theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
-    const std::string aModVName = "Modified_Vertex";
-    const std::string aModEName = "Modified_Edge";
-    const std::string aModFName = "Modified_Face";
-
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
-                                               aModifyVTag, aModVName, theMapOfShapes, false,
-                                               false, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
-                                               aModifyETag, aModEName, theMapOfShapes, false,
-                                               false, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
-                                               aModifyFTag, aModFName, theMapOfShapes, false,
-                                               false, true);
-
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::VERTEX, aDeletedTag);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::EDGE, aDeletedTag);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::FACE, aDeletedTag);
-
-    for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
-    {
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
-                                                 aModifyVTag, aModVName, theMapOfShapes, false,
-                                                 false, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
-                                                 aModifyETag, aModEName, theMapOfShapes, false,
-                                                 false, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
-                                                 aModifyFTag, aModFName, theMapOfShapes, false,
-                                                 false, true);
-
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
-    }
-  }
-}
index 950b8223f769e8230eb09b666e435c2b8a0e4c29..1010871c4e0b65e33386738bee4f152e91dc1c27 100644 (file)
@@ -96,15 +96,6 @@ public:
 
   /// Use plugin manager for features creation.
   FeaturesPlugin_BooleanFuse();
-
-private:
-  /// Load Naming data structure of the feature to the document
-  void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                    const ListOfShape& theTools,
-                    const std::shared_ptr<GeomAPI_Shape> theResultShape,
-                    GeomAlgoAPI_MakeShape& theMakeShape,
-                    GeomAPI_DataMapOfShapeShape& theMapOfShapes);
 };
 
 #endif
index 0dbe5a3485dcbc1238587580dd2648057209549a..65f1a77fe69b5925dc218f659414cb9ef56ed590 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "FeaturesPlugin_BooleanSmash.h"
 
+#include "FeaturesPlugin_Tools.h"
+
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
@@ -144,8 +146,7 @@ void FeaturesPlugin_BooleanSmash::execute()
     }
   }
 
-  GeomAlgoAPI_MakeShapeList aMakeShapeList;
-  GeomAPI_DataMapOfShapeShape aMapOfShapes;
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   if (!aShapesToAdd.empty()) {
     // Cut objects with not used solids.
     std::shared_ptr<GeomAlgoAPI_Boolean> anObjectsCutAlgo(
@@ -156,8 +157,7 @@ void FeaturesPlugin_BooleanSmash::execute()
     if (GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) {
       aShapesToSmash.clear();
       aShapesToSmash.push_back(anObjectsCutAlgo->shape());
-      aMakeShapeList.appendAlgo(anObjectsCutAlgo);
-      aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes());
+      aMakeShapeList->appendAlgo(anObjectsCutAlgo);
     }
 
     // Cut tools with not used solids.
@@ -169,8 +169,7 @@ void FeaturesPlugin_BooleanSmash::execute()
     if (GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) {
       aTools.clear();
       aTools.push_back(aToolsCutAlgo->shape());
-      aMakeShapeList.appendAlgo(aToolsCutAlgo);
-      aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes());
+      aMakeShapeList->appendAlgo(aToolsCutAlgo);
     }
   }
 
@@ -196,8 +195,7 @@ void FeaturesPlugin_BooleanSmash::execute()
     setError(aFeatureError);
     return;
   }
-  aMakeShapeList.appendAlgo(aBoolAlgo);
-  aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
+  aMakeShapeList->appendAlgo(aBoolAlgo);
 
   // Put all (cut result, tools and not used solids) to PaveFiller.
   GeomShapePtr aShape = aBoolAlgo->shape();
@@ -230,88 +228,28 @@ void FeaturesPlugin_BooleanSmash::execute()
     }
 
     aShape = aFillerAlgo->shape();
-    aMakeShapeList.appendAlgo(aFillerAlgo);
-    aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+    aMakeShapeList->appendAlgo(aFillerAlgo);
   }
 
   std::shared_ptr<GeomAPI_Shape> aFrontShape = anOriginalShapes.front();
   anOriginalShapes.pop_front();
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-  loadNamingDS(aResultBody,
-               aFrontShape,
-               anOriginalShapes,
-               aShape,
-               aMakeShapeList,
-               aMapOfShapes);
+
+  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                           aFrontShape,
+                                           anOriginalShapes,
+                                           aMakeShapeList,
+                                           aShape);
 
   setResult(aResultBody, aResultIndex);
   aResultIndex++;
 
+  FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
+                                          aFrontShape,
+                                          anOriginalShapes,
+                                          aMakeShapeList,
+                                          aShape);
+
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
-
-//==================================================================================================
-void FeaturesPlugin_BooleanSmash::loadNamingDS(ResultBodyPtr theResultBody,
-                                             const GeomShapePtr theBaseShape,
-                                             const ListOfShape& theTools,
-                                             const GeomShapePtr theResultShape,
-                                             GeomAlgoAPI_MakeShape& theMakeShape,
-                                             GeomAPI_DataMapOfShapeShape& theMapOfShapes)
-{
-  //load result
-  if (theBaseShape->isEqual(theResultShape)) {
-    theResultBody->store(theResultShape, false);
-  } else if (theResultShape->isEqual(theTools.front())) {
-    theResultBody->store(theResultShape, false);
-  } else {
-    const int aModifyVTag = 1;
-    const int aModifyETag = 2;
-    const int aModifyFTag = 3;
-    const int aDeletedTag = 4;
-    /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
-    const int aSubsolidsTag = 5;
-
-    theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
-    const std::string aModVName = "Modified_Vertex";
-    const std::string aModEName = "Modified_Edge";
-    const std::string aModFName = "Modified_Face";
-
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
-                                               aModifyVTag, aModVName, theMapOfShapes, false,
-                                               true, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
-                                               aModifyETag, aModEName, theMapOfShapes, false,
-                                               true, true);
-    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
-                                               aModifyFTag, aModFName, theMapOfShapes, false,
-                                               true, true);
-
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::VERTEX, aDeletedTag);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::EDGE, aDeletedTag);
-    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
-                                     GeomAPI_Shape::FACE, aDeletedTag);
-
-    for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
-    {
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
-                                                 aModifyVTag, aModVName, theMapOfShapes, false,
-                                                 true, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
-                                                 aModifyETag, aModEName, theMapOfShapes, false,
-                                                 true, true);
-
-      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
-                                                 aModifyFTag, aModFName, theMapOfShapes, false,
-                                                 true, true);
-
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
-      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
-    }
-  }
-}
index 0238d271292a3f754c2af746dfa77d488e1e0191..8a0057c9bcf7844550e5d2777adafa31331f09bf 100644 (file)
@@ -70,17 +70,6 @@ public:
 
   /// Use plugin manager for features creation.
   FeaturesPlugin_BooleanSmash();
-
-private:
-
-  /// Load Naming data structure of the feature to the document
-  void loadNamingDS(ResultBodyPtr theResultBody,
-                    const GeomShapePtr theBaseShape,
-                    const ListOfShape& theTools,
-                    const GeomShapePtr theResultShape,
-                    GeomAlgoAPI_MakeShape& theMakeShape,
-                    GeomAPI_DataMapOfShapeShape& theMapOfShapes);
-
 };
 
 #endif
index 6f0d65f4d923f4824950dd9986ed2e64ab49b191..e17304991bf1e90881b9c98014da474c8cca9639 100644 (file)
@@ -86,7 +86,7 @@ void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean()
     }
     else
     {
-      aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape(), aTag);
+      aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape());
 
       aTag += 5000;
 
@@ -393,25 +393,21 @@ void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr the
   ListOfShape aTools = theTools;
   aTools.push_back(theObject);
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMap = theMakeShape->mapOfSubShapes();
-
-  int aTag;
   std::string aName;
   for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) {
     if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) {
-      aTag = anEdgesAndFacesTag;
       aName = aModName + "_Edge";
     }
     else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) {
-      aTag = anEdgesAndFacesTag;
       aName = aModName + "_Face";
     } else {
-      aTag = aModTag;
       aName = aModName;
     }
-    theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt,
-      (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
-      GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get(), false, false, true);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIt,
+                                      (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
+                                                              GeomAPI_Shape::EDGE :
+                                                              GeomAPI_Shape::FACE,
+                                      aName);
   }
 }
 
@@ -426,18 +422,16 @@ void FeaturesPlugin_CompositeBoolean::storeDeletedShapes(
     ++anIt)
   {
     ResultBaseAlgo& aRCA = *anIt;
-    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
       aRCA.baseShape,
       GeomAPI_Shape::FACE,
-      aRCA.delTag,
       theResultShapesCompound);
 
     for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
     {
-      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
         *anIter,
         GeomAPI_Shape::FACE,
-        aRCA.delTag,
         theResultShapesCompound);
     }
   }
index 8b0fdab8130349a2b35a6160557a2a2124f6565f..2ee269e420726f08691b28464d7d0381651e89da 100644 (file)
@@ -208,20 +208,15 @@ void FeaturesPlugin_Fillet::loadNamingDS(
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = theMakeShape->mapOfSubShapes();
 
-  const int aDeletedTag = 1;
-  const int aModifyTag = 2;
   const int aGeneratedTag = 3;
-  /// sub solids will be placed at labels 4, 5, etc. if result is compound of solids
-  const int aSubsolidsTag = 4;
 
-  theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
+  theResultBody->storeModified(theBaseShape, theResultShape);
 
   const std::string aModFaceName = "Modified_Face";
   const std::string aFilletFaceName = "Fillet_Face";
 
   // Store modified faces
-  theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), theBaseShape,
-      GeomAPI_Shape::FACE, aModifyTag, aModFaceName, *aMapOfShapes);
+  theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFaceName);
 
   // Store new faces generated from edges and vertices
   theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
@@ -230,8 +225,6 @@ void FeaturesPlugin_Fillet::loadNamingDS(
       GeomAPI_Shape::VERTEX, aGeneratedTag, aFilletFaceName, *aMapOfShapes);
 
   // Deleted shapes
-  theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape,
-                                   GeomAPI_Shape::EDGE, aDeletedTag);
-  theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape,
-                                   GeomAPI_Shape::FACE, aDeletedTag);
+  theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
+  theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
 }
index b3cc312c52097f8113056fb743f35972132a157e..12e0325e0752471bf6b5335acfc4fd26be4fd52e 100644 (file)
@@ -81,15 +81,10 @@ void FeaturesPlugin_FusionFaces::execute()
   } else {
     aResultBody->storeModified(aBaseShape, aResultShape);
 
-    const int aModifyEdgeTag = 1;
-    const int aModifyFaceTag = 2;
     const std::string aModEName = "Modified_Edge";
     const std::string aModFName = "Modified_Face";
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = anAlgo->mapOfSubShapes();
-    aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::EDGE,
-      aModifyEdgeTag, aModEName, *aMapOfShapes.get(), true);
-    aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::FACE,
-      aModifyFaceTag, aModFName, *aMapOfShapes.get(), true);
+    aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::EDGE, aModEName);
+    aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::FACE, aModFName);
   }
   setResult(aResultBody);
 }
index e421c55f42cee3d451f69cbfcc70cd91d117679a..73dec6b8a6fd486a3ee8ce9c1540277764c28c68 100644 (file)
@@ -147,8 +147,7 @@ void FeaturesPlugin_Intersection::loadNamingDS(std::shared_ptr<ModelAPI_ResultBo
           std::string("Modified_")
             + (anIndex == 0 ? "Vertex_" : "Edge_")
             + std::to_string((long long)(anIndex == 0 ? aModifiedVertexIndex++
-                                                      : aModifiedEdgeIndex++)),
-          aTag++);
+                                                      : aModifiedEdgeIndex++)));
       } else {
         theResultBody->generated(
           aSubShape,
index 90c4599492f19155b987f2121de1fba52870a797..2410ac080beb0f962d42042e5ea3e65ab9e282a5 100644 (file)
@@ -388,34 +388,16 @@ void FeaturesPlugin_MultiRotation::loadNamingDS2(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
     std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
-  int aTag = 1;
-  int anIndex = 1;
-  std::string aRotatedName;
-
   for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
     theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
-    std::cout << "LOAD" << std::endl;
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
-
     // naming of faces
-    aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
-                                               aTag++, aRotatedName, *aSubShapes.get(),
-                                               false, true);
+    theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face");
 
     // naming of edges
-    aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
-                                               aTag++, aRotatedName, *aSubShapes.get(),
-                                               false, true);
+    theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge");
 
     // naming of vertex
-    aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
-                                               aTag++, aRotatedName, *aSubShapes.get(),
-                                               false, true);
-
-    ++anIndex;
+    theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex");
   }
 }
 
@@ -450,31 +432,15 @@ void FeaturesPlugin_MultiRotation::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
     std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
-  int aTag = 1;
-  int anIndex = 1;
-  std::string aRotatedName;
-
   for (std::list<std::shared_ptr<GeomAlgoAPI_Rotation> >::const_iterator anIt =
     theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) {
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
-
     // naming of faces
-    aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
-                                               aTag++, aRotatedName, *aSubShapes.get(),
-                                               false, true);
+    theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face");
 
     // naming of edges
-    aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
-                                               aTag++, aRotatedName, *aSubShapes.get(),
-                                               false, true);
+    theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge");
 
     // naming of vertex
-    aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
-                                               aTag++, aRotatedName, *aSubShapes.get(),
-                                               false, true);
-    ++anIndex;
+    theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex");
   }
 }
index d23742c6df621107ffa698b33a2287421fa3024d..81d07b5a40d7b236637fef18463e029b8090b250 100644 (file)
@@ -368,32 +368,24 @@ void FeaturesPlugin_MultiTranslation::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
     std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
-  int aTag = 1;
-  int anIndex = 1;
-  std::string aTranslatedName;
-
   for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
     theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
-
     // naming of faces
-    aTranslatedName = "Translated_Face_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
-                                               aTag++, aTranslatedName, *aSubShapes.get(),
-                                               false, true);
+    theResultBody->loadModifiedShapes(*anIt,
+                                      theBaseShape,
+                                      GeomAPI_Shape::FACE,
+                                      "Translated_Face");
 
     // naming of edges
-    aTranslatedName = "Translated_Edge_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
-                                               aTag++, aTranslatedName, *aSubShapes.get(),
-                                               false, true);
+    theResultBody->loadModifiedShapes(*anIt,
+                                      theBaseShape,
+                                      GeomAPI_Shape::EDGE,
+                                      "Translated_Edge");
 
     // naming of vertex
-    aTranslatedName = "Translated_Vertex_" + std::to_string((long long) anIndex);
-    theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
-                                               aTag++, aTranslatedName, *aSubShapes.get(),
-                                               false, true);
-
-    ++anIndex;
+    theResultBody->loadModifiedShapes(*anIt,
+                                      theBaseShape,
+                                      GeomAPI_Shape::VERTEX,
+                                      "Translated_Vertex");
   }
 }
index cd4f34cd33a915148c3ba1fc8ebf5da5774cd3fb..f8b1bfdb2250f0133e6a966010b7bf91d45356d7 100755 (executable)
@@ -204,26 +204,18 @@ void FeaturesPlugin_Partition::storeResult(
     return;
   }
 
-  const int aDelTag = 1;
-  /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
-  const int aSubTag = 2;
-  int aModTag = aSubTag + 10000;
-  const std::string aModName = "Modified";
-
-  aResultBody->storeModified(aBaseShape, theResultShape, aSubTag);
+  aResultBody->storeModified(aBaseShape, theResultShape);
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
   theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end());
-  int anIndex = 1;
-  for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) {
+  for (ListOfShape::const_iterator anIt = theObjects.cbegin();
+       anIt != theObjects.cend();
+       ++anIt)
+  {
     GeomShapePtr aShape = *anIt;
-    std::string aModEdgeName = aModName + "_Edge_" + std::to_string((long long)anIndex);
-    aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::EDGE,
-      aModTag, aModEdgeName, *aMapOfSubShapes.get(), false, true, true);
-    std::string aModFaceName = aModName + "_Face_" + std::to_string((long long)anIndex++);
-    aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE,
-      aModTag + 1, aModFaceName, *aMapOfSubShapes.get(), false, true, true);
-    aResultBody->loadDeletedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, aDelTag);
+    aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::EDGE, "Modified_Edge");
+    aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE, "Modified_Face");
+    aResultBody->loadDeletedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE);
   }
 
   setResult(aResultBody, theIndex);
index 3448c72c5b2b2c6f5f122f31c0d75d81ee47c483..d8d90cd6efac17b29645cd287ef53584d28358b9 100644 (file)
@@ -314,10 +314,10 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr<GeomAPI_Shape> theBa
       thePipeAlgo.generated(aV1, aV1History);
       thePipeAlgo.generated(aV2, aV2History);
       if(!aV1History.empty()) {
-        aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++);
+        aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1");
       }
       if(!aV2History.empty()) {
-        aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++);
+        aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2");
       }
     }
     case GeomAPI_Shape::FACE:
@@ -387,8 +387,8 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes,
         ListOfShape aV1History, aV2History;
         thePipeAlgo.generated(aV1, aV1History);
         thePipeAlgo.generated(aV2, aV2History);
-        aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++);
-        aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++);
+        aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1");
+        aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2");
       }
       case GeomAPI_Shape::FACE:
       case GeomAPI_Shape::SHELL: {
index ab932f01d6c21ac5993a434a9846b0253f926bda..bd1e96efc6ad30c2baa8aef8f6e833c837e72419 100644 (file)
@@ -167,29 +167,30 @@ void FeaturesPlugin_Placement::execute()
       setResult(aResultPart, aResultIndex);
     } else {
       std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-      GeomAlgoAPI_Transform aTransformAlgo(aBaseShape, aTrsf);
+      std::shared_ptr<GeomAlgoAPI_Transform> aTransformAlgo(new GeomAlgoAPI_Transform(aBaseShape,
+                                                                                      aTrsf));
 
       // Checking that the algorithm worked properly.
-      if(!aTransformAlgo.isDone()) {
+      if(!aTransformAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Transform algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aTransformAlgo.shape()->isNull()) {
+      if(aTransformAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aTransformAlgo.isValid()) {
+      if(!aTransformAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       //LoadNamingDS
-      std::shared_ptr<ModelAPI_ResultBody> aResultBody =
-        document()->createBody(data(), aResultIndex);
-      loadNamingDS(aTransformAlgo, aResultBody, aBaseShape);
+      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+      aResultBody->storeModified(aBaseShape, aTransformAlgo->shape());
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aTransformAlgo, "Placed");
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -198,19 +199,3 @@ void FeaturesPlugin_Placement::execute()
   // Remove the rest results if there were produced in the previous pass.
   removeResults(aResultIndex);
 }
-
-//============================================================================
-void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo,
-                                            std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                            std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
-  //load result
-  theResultBody->storeModified(theBaseShape, theTransformAlgo.shape());
-
-  std::string aPlacedName = "Placed";
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTransformAlgo.mapOfSubShapes();
-
-  FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody,
-                                            theBaseShape, 1, 2, 3, aPlacedName,
-                                            *aSubShapes.get());
-}
index 1b8a7b6bd0e1bcf5d27adc62b6d050ee0e62af0b..ccc9dba8bdfa76a01547fb52cba8baa228bfba6c 100644 (file)
@@ -95,11 +95,6 @@ class FeaturesPlugin_Placement : public ModelAPI_Feature
 
   /// Use plugin manager for features creation
   FeaturesPlugin_Placement();
-private:
-  /// Load Naming data structure of the feature to the document
-  void loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
 
 #endif
index e4d61f163b0066fa38a4ecd7ef87fe8dd4cc6b78..b53eca256376717e238d8c725fc31ef4ff180d0a 100644 (file)
@@ -232,7 +232,7 @@ void FeaturesPlugin_RemoveSubShapes::execute()
     aResultShape = anAttrSelectionInList->value();
   }
   // deleted and copied must be jointed to one list which keeps all the history
-  GeomAlgoAPI_MakeShapeList aMakeShapeList;
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
 
   // find all removed shapes
   std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aDeletedSubs(new GeomAlgoAPI_MakeShapeCustom);
@@ -263,11 +263,11 @@ void FeaturesPlugin_RemoveSubShapes::execute()
       }
     }
   }
-  aMakeShapeList.appendAlgo(aDeletedSubs);
+  aMakeShapeList->appendAlgo(aDeletedSubs);
 
   std::shared_ptr<GeomAlgoAPI_Copy> aCopy(new GeomAlgoAPI_Copy(aResultShape));
   aResultShape = aCopy->shape();
-  aMakeShapeList.appendAlgo(aCopy);
+  aMakeShapeList->appendAlgo(aCopy);
 
   if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
     aResultShape = GeomAlgoAPI_ShapeTools::groupSharedTopology(aResultShape);
@@ -283,15 +283,25 @@ void FeaturesPlugin_RemoveSubShapes::execute()
 
   // Store result.
   ResultBodyPtr aResultBody = document()->createBody(data());
-  aResultBody->storeModified(aBaseShape, aResultShape, 1);
-  std::set<GeomAPI_Shape::ShapeType>::iterator aTypeIter = aTypes.begin();
-  for(; aTypeIter != aTypes.end(); aTypeIter++)
-    aResultBody->loadDeletedShapes(&aMakeShapeList, aBaseShape, *aTypeIter, 1);
-  aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::FACE,
-      2, "Modified_Face", *aMakeShapeList.mapOfSubShapes().get(), true, false, true);
-  aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::EDGE,
-      3, "Modified_Edge", *aMakeShapeList.mapOfSubShapes().get(), false, false, true);
-  aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::VERTEX,
-      4, "Modified_Vertex", *aMakeShapeList.mapOfSubShapes().get());
+  aResultBody->storeModified(aBaseShape, aResultShape);
+  for (std::set<GeomAPI_Shape::ShapeType>::iterator aTypeIter = aTypes.begin();
+       aTypeIter != aTypes.end();
+       ++aTypeIter)
+  {
+    aResultBody->loadDeletedShapes(aMakeShapeList, aBaseShape, *aTypeIter);
+  }
+
+  aResultBody->loadModifiedShapes(aMakeShapeList,
+                                  aBaseShape,
+                                  GeomAPI_Shape::FACE,
+                                  "Modified_Face");
+  aResultBody->loadModifiedShapes(aMakeShapeList,
+                                  aBaseShape,
+                                  GeomAPI_Shape::EDGE,
+                                  "Modified_Edge");
+  aResultBody->loadModifiedShapes(aMakeShapeList,
+                                  aBaseShape,
+                                  GeomAPI_Shape::VERTEX,
+                                  "Modified_Vertex");
   setResult(aResultBody);
 }
index 07d2d575c109924f51fbb72a73d1174913faded6..d87346d1aee1e44fc6092ae7df22eb564980d201 100755 (executable)
@@ -134,34 +134,36 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
       aResultPart->setTrsf(*aContext, aTrsf);
       setResult(aResultPart, aResultIndex);
     } else {
-      GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, anAxis, anAngle);
+      std::shared_ptr<GeomAlgoAPI_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
+                                                                                   anAxis,
+                                                                                   anAngle));
 
-      if (!aRotationAlgo.check()) {
-        setError(aRotationAlgo.getError());
+      if (!aRotationAlgo->check()) {
+        setError(aRotationAlgo->getError());
         return;
       }
 
-      aRotationAlgo.build();
+      aRotationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aRotationAlgo.isDone()) {
+      if(!aRotationAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Rotation algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aRotationAlgo.shape()->isNull()) {
+      if(aRotationAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aRotationAlgo.isValid()) {
+      if(!aRotationAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated");
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -238,52 +240,40 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints()
        aResultPart->setTrsf(*aContext, aTrsf);
        setResult(aResultPart, aResultIndex);
     } else {
-      GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, aCenterPoint, aStartPoint, anEndPoint);
+      std::shared_ptr<GeomAlgoAPI_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
+                                                                                   aCenterPoint,
+                                                                                   aStartPoint,
+                                                                                   anEndPoint));
 
-      if (!aRotationAlgo.check()) {
-        setError(aRotationAlgo.getError());
+      if (!aRotationAlgo->check()) {
+        setError(aRotationAlgo->getError());
         return;
       }
 
-      aRotationAlgo.build();
+      aRotationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aRotationAlgo.isDone()) {
+      if(!aRotationAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Rotation algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aRotationAlgo.shape()->isNull()) {
+      if(aRotationAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error : Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aRotationAlgo.isValid()) {
+      if(!aRotationAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
+      aResultBody->storeModified(aBaseShape, aRotationAlgo->shape());
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated");
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
   }
 }
-
-//=================================================================================================
-void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
-                                           std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                           std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
-  // Store result.
-  theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
-
-  std::string aRotatedName = "Rotated";
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
-
-  FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody,
-                                            theBaseShape, 1, 2, 3, aRotatedName,
-                                            *aSubShapes.get());
-}
index ce064ca2176c484f32f38380680ed0c904dea0c8..0c8a24aeee8f54415790f672ec9c414a300b0a8c 100755 (executable)
@@ -125,10 +125,6 @@ private:
 
   ///Perform the rotation using a center and two points.
   void performTranslationByThreePoints();
-
-  void loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
 
 #endif
index 4e854c22a5f491e742f68ad57121d9b4c916382b..a60b77984353ea42910971782b0bb4ee0f9c1d57 100644 (file)
@@ -120,34 +120,36 @@ void FeaturesPlugin_Scale::performScaleByFactor()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor);
+    std::shared_ptr<GeomAlgoAPI_Scale> aScaleAlgo(
+      new GeomAlgoAPI_Scale(aBaseShape, aCenterPoint, aScaleFactor));
 
-    if (!aScaleAlgo.check()) {
-      setError(aScaleAlgo.getError());
+    if (!aScaleAlgo->check()) {
+      setError(aScaleAlgo->getError());
       return;
     }
 
-    aScaleAlgo.build();
+    aScaleAlgo->build();
 
     // Checking that the algorithm worked properly.
-    if(!aScaleAlgo.isDone()) {
+    if(!aScaleAlgo->isDone()) {
       static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
       setError(aFeatureError);
       break;
     }
-    if(aScaleAlgo.shape()->isNull()) {
+    if(aScaleAlgo->shape()->isNull()) {
       static const std::string aShapeError = "Error: Resulting shape is Null.";
       setError(aShapeError);
       break;
     }
-    if(!aScaleAlgo.isValid()) {
+    if(!aScaleAlgo->isValid()) {
       std::string aFeatureError = "Error: Resulting shape is not valid.";
       setError(aFeatureError);
       break;
     }
 
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
+    aResultBody->storeModified(aBaseShape, aScaleAlgo->shape());
+    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled");
     setResult(aResultBody, aResultIndex);
     aResultIndex++;
   }
@@ -204,35 +206,39 @@ void FeaturesPlugin_Scale::performScaleByDimensions()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint,
-                                 aScaleFactorX, aScaleFactorY, aScaleFactorZ);
-
-    if (!aScaleAlgo.check()) {
-      setError(aScaleAlgo.getError());
+    std::shared_ptr<GeomAlgoAPI_Scale> aScaleAlgo(new GeomAlgoAPI_Scale(aBaseShape,
+                                                                        aCenterPoint,
+                                                                        aScaleFactorX,
+                                                                        aScaleFactorY,
+                                                                        aScaleFactorZ));
+
+    if (!aScaleAlgo->check()) {
+      setError(aScaleAlgo->getError());
       return;
     }
 
-    aScaleAlgo.build();
+    aScaleAlgo->build();
 
     // Checking that the algorithm worked properly.
-    if(!aScaleAlgo.isDone()) {
+    if(!aScaleAlgo->isDone()) {
       static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
       setError(aFeatureError);
       break;
     }
-    if(aScaleAlgo.shape()->isNull()) {
+    if(aScaleAlgo->shape()->isNull()) {
       static const std::string aShapeError = "Error: Resulting shape is Null.";
       setError(aShapeError);
       break;
     }
-    if(!aScaleAlgo.isValid()) {
+    if(!aScaleAlgo->isValid()) {
       std::string aFeatureError = "Error: Resulting shape is not valid.";
       setError(aFeatureError);
       break;
     }
 
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
+    aResultBody->storeModified(aBaseShape, aScaleAlgo->shape());
+    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled");
     setResult(aResultBody, aResultIndex);
     aResultIndex++;
   }
@@ -240,19 +246,3 @@ void FeaturesPlugin_Scale::performScaleByDimensions()
   // Remove the rest results if there were produced in the previous pass.
   removeResults(aResultIndex);
 }
-
-//=================================================================================================
-void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
-                                        std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                        std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
-  // Store and name the result.
-  theResultBody->storeModified(theBaseShape, theScaleAlgo.shape());
-
-  // Name the faces
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theScaleAlgo.mapOfSubShapes();
-  std::string aScaledName = "Scaled";
-  FeaturesPlugin_Tools::storeModifiedShapes(theScaleAlgo, theResultBody,
-                                            theBaseShape, 1, 2, 3, aScaledName,
-                                            *aSubShapes.get());
-}
index 519dec4e4b529cbca3ce9ee92e65324b012e2c10..9700331f7b391e2c694d121c7d59d19e47d5ed07 100644 (file)
@@ -126,11 +126,6 @@ private:
 
   /// Perform symmetry using a central point and three dimensions
   void performScaleByDimensions();
-
-  /// Perform the naming
-  void loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
 
 #endif // FEATURESPLUGIN_SCALE_H_
\ No newline at end of file
index d50b74aa2088b65f7e4930cac773dc6ab1a69163..9fa897e5e31de3414252261aa3dca469556a44f1 100644 (file)
@@ -345,8 +345,8 @@ void FeaturesPlugin_Symmetry::buildResult(
   std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
   std::shared_ptr<GeomAPI_Shape> theBaseShape, int theResultIndex)
 {
-  GeomAlgoAPI_MakeShapeList anAlgoList;
-  anAlgoList.appendAlgo(theSymmetryAlgo);
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> anAlgoList(new GeomAlgoAPI_MakeShapeList());
+  anAlgoList->appendAlgo(theSymmetryAlgo);
   // Compose source shape and the result of symmetry.
   GeomShapePtr aCompound;
   if (boolean(KEEP_ORIGINAL_RESULT())->value()) {
@@ -354,7 +354,7 @@ void FeaturesPlugin_Symmetry::buildResult(
     // add a copy of a base shape otherwise selection of this base shape is bad (2592)
     std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape));
     aShapes.push_back(aCopyAlgo->shape());
-    anAlgoList.appendAlgo(aCopyAlgo);
+    anAlgoList->appendAlgo(aCopyAlgo);
 
     aShapes.push_back(theSymmetryAlgo->shape());
     aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
@@ -364,7 +364,7 @@ void FeaturesPlugin_Symmetry::buildResult(
   // Store and name the result.
   ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
   aResultBody->storeModified(theBaseShape, aCompound);
-  loadNamingDS(anAlgoList, aResultBody, theBaseShape);
+  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theBaseShape, anAlgoList, "Symmetried");
   setResult(aResultBody, theResultIndex);
 }
 
@@ -385,16 +385,3 @@ void FeaturesPlugin_Symmetry::buildResult(ResultPartPtr theOriginal,
   aResultPart->setTrsf(theOriginal, theTrsf);
   setResult(aResultPart, theResultIndex);
 }
-
-//=================================================================================================
-void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo,
-                                           std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                           std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
-  // Name the faces
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theAlgo.mapOfSubShapes();
-  std::string aReflectedName = "Symmetried";
-  FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody,
-                                            theBaseShape, 1, 2, 3, aReflectedName,
-                                            *aSubShapes.get());
-}
index a19d143cfa73448e098563a67d761957e3560310..d03cc141bcc3c9b447c566a5d60efcff3723e1de 100644 (file)
@@ -137,11 +137,6 @@ private:
   /// Perform symmetry with respect to a plane.
   void performSymmetryByPlane();
 
-  /// Perform the naming
-  void loadNamingDS(GeomAlgoAPI_MakeShapeList& theSymmetryAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
-
   /// Create new result on given shapes and the index of result
   void buildResult(std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
                    std::shared_ptr<GeomAPI_Shape> theBaseShape,
index 07709d1ed7fa2a2056346f9e0f0c28ebed31b07e..e18c6f44ee7b833348f695dcdfd612448b0241ef 100644 (file)
 
 #include <GeomAPI_ShapeIterator.h>
 
-void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
-                                               std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                               std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                               const int theFaceTag,
-                                               const int theEdgeTag,
-                                               const int theVertexTag,
-                                               const std::string theName,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes)
+//==================================================================================================
+void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
+                                              const GeomShapePtr theBaseShape,
+                                              const ListOfShape& theTools,
+                                              const GeomMakeShapePtr& theMakeShape,
+                                              const GeomShapePtr theResultShape)
+{
+  if (theBaseShape->isEqual(theResultShape)) {
+    theResultBody->store(theResultShape, false);
+    return;
+  }
+
+  theResultBody->storeModified(theBaseShape, theResultShape);
+
+  ListOfShape aShapes = theTools;
+  aShapes.push_front(theBaseShape);
+
+  for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
+  {
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
+  }
+}
+
+//==================================================================================================
+void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
+                                              const GeomShapePtr theBaseShape,
+                                              const GeomMakeShapePtr& theMakeShape,
+                                              const std::string theName)
 {
   switch(theBaseShape->shapeType()) {
     case GeomAPI_Shape::COMPOUND: {
       for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next())
       {
-        storeModifiedShapes(theAlgo,
-                            theResultBody,
-                            anIt.current(),
-                            theFaceTag,
-                            theEdgeTag,
-                            theVertexTag,
-                            theName,
-                            theSubShapes);
+        loadModifiedShapes(theResultBody,
+                           anIt.current(),
+                           theMakeShape,
+                           theName);
       }
       break;
     }
     case GeomAPI_Shape::COMPSOLID:
     case GeomAPI_Shape::SOLID:
     case GeomAPI_Shape::SHELL: {
-      theResultBody->loadAndOrientModifiedShapes(&theAlgo,
-                                theBaseShape, GeomAPI_Shape::FACE,
-                                theFaceTag, theName + "_Face", theSubShapes, false, true);
+      theResultBody->loadModifiedShapes(theMakeShape,
+                                        theBaseShape,
+                                        GeomAPI_Shape::FACE,
+                                        theName + "_Face");
     }
     case GeomAPI_Shape::FACE:
     case GeomAPI_Shape::WIRE: {
-      theResultBody->loadAndOrientModifiedShapes(&theAlgo,
-                                theBaseShape, GeomAPI_Shape::EDGE,
-                                theEdgeTag, theName + "_Edge", theSubShapes, false, true);
+      theResultBody->loadModifiedShapes(theMakeShape,
+                                        theBaseShape,
+                                        GeomAPI_Shape::EDGE,
+                                        theName + "_Edge");
     }
     case GeomAPI_Shape::EDGE: {
-      theResultBody->loadAndOrientModifiedShapes(&theAlgo,
-                              theBaseShape, GeomAPI_Shape::VERTEX,
-                              theVertexTag, theName + "_Vertex", theSubShapes, false, true);
+      theResultBody->loadModifiedShapes(theMakeShape,
+                                        theBaseShape,
+                                        GeomAPI_Shape::VERTEX,
+                                        theName + "_Vertex");
     }
   }
 }
+
+//==================================================================================================
+void FeaturesPlugin_Tools::loadDeletedShapes(ResultBodyPtr theResultBody,
+  const GeomShapePtr theBaseShape,
+  const ListOfShape& theTools,
+  const GeomMakeShapePtr& theMakeShape,
+  const GeomShapePtr theResultShapesCompound)
+{
+  ListOfShape aShapes = theTools;
+  aShapes.push_front(theBaseShape);
+
+  for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++)
+  {
+    theResultBody->loadDeletedShapes(theMakeShape,
+                                     *anIter,
+                                     GeomAPI_Shape::VERTEX,
+                                     theResultShapesCompound);
+    theResultBody->loadDeletedShapes(theMakeShape,
+                                     *anIter,
+                                     GeomAPI_Shape::EDGE,
+                                     theResultShapesCompound);
+    theResultBody->loadDeletedShapes(theMakeShape,
+                                     *anIter,
+                                     GeomAPI_Shape::FACE,
+                                     theResultShapesCompound);
+  }
+}
+
+//==================================================================================================
+void FeaturesPlugin_Tools::loadDeletedShapes(
+  std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+  const ListOfShape& theTools,
+  const GeomShapePtr theResultShapesCompound)
+{
+  for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
+       anIt != theResultBaseAlgoList.end();
+       ++anIt)
+  {
+    ResultBaseAlgo& aRCA = *anIt;
+    loadDeletedShapes(aRCA.resultBody,
+                      aRCA.baseShape,
+                      theTools,
+                      aRCA.makeShape,
+                      theResultShapesCompound);
+  }
+}
index 02a0b5e454b95a2b09a778e0ec165c77398b7805..22b269b045e915f24d6ad7f94b5766b3ba53f923 100644 (file)
 #ifndef FeaturesPlugin_Tools_H_
 #define FeaturesPlugin_Tools_H_
 
-#include <GeomAlgoAPI_Translation.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <ModelAPI_ResultBody.h>
 
-class ModelAPI_ResultBody;
+#include <vector>
 
 class FeaturesPlugin_Tools {
 public:
-  static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
-                                  std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                  std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                  const int theFaceTag,
-                                  const int theEdgeTag,
-                                  const int theVertexTag,
-                                  const std::string theName,
-                                  GeomAPI_DataMapOfShapeShape& theSubShapes);
+  struct ResultBaseAlgo {
+    ResultBodyPtr resultBody;
+    GeomShapePtr baseShape;
+    GeomMakeShapePtr makeShape;
+  };
+
+public:
+  static void loadModifiedShapes(ResultBodyPtr theResultBody,
+                                 const GeomShapePtr theBaseShape,
+                                 const ListOfShape& theTools,
+                                 const GeomMakeShapePtr& theMakeShape,
+                                 const GeomShapePtr theResultShape);
+
+  static void loadModifiedShapes(ResultBodyPtr theResultBody,
+                                 const GeomShapePtr theBaseShape,
+                                 const GeomMakeShapePtr& theMakeShape,
+                                 const std::string theName);
+
+    /// Stores deleted shapes.
+  static void loadDeletedShapes(ResultBodyPtr theResultBody,
+                                const GeomShapePtr theBaseShape,
+                                const ListOfShape& theTools,
+                                const GeomMakeShapePtr& theMakeShape,
+                                const GeomShapePtr theResultShapesCompound);
+
+  /// Stores deleted shapes.
+  static void loadDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+                                const ListOfShape& theTools,
+                                const GeomShapePtr theResultShapesCompound);
 };
 
 #endif /* FeaturesPlugin_Tools_H_ */
index 0da4b6acc7fcfa4f99de679fa38c1efd7db4e183..19ec3564ae804999dd42963d2851767990d137e9 100644 (file)
@@ -147,34 +147,39 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance()
       aResultPart->setTrsf(*aContext, aTrsf);
       setResult(aResultPart, aResultIndex);
     } else {
-      GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance);
+      std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+        new GeomAlgoAPI_Translation(aBaseShape, anAxis, aDistance));
 
-      if (!aTranslationAlgo.check()) {
-        setError(aTranslationAlgo.getError());
+      if (!aTranslationAlgo->check()) {
+        setError(aTranslationAlgo->getError());
         return;
       }
 
-      aTranslationAlgo.build();
+      aTranslationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aTranslationAlgo.isDone()) {
+      if(!aTranslationAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Translation algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aTranslationAlgo.shape()->isNull()) {
+      if(aTranslationAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aTranslationAlgo.isValid()) {
+      if(!aTranslationAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+      aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aBaseShape,
+                                               aTranslationAlgo,
+                                               "Translated");
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -229,34 +234,39 @@ void FeaturesPlugin_Translation::performTranslationByDimensions()
       aResultPart->setTrsf(*aContext, aTrsf);
       setResult(aResultPart, aResultIndex);
     } else {
-      GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aDX, aDY, aDZ);
+      std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+        new GeomAlgoAPI_Translation(aBaseShape, aDX, aDY, aDZ));
 
-      if (!aTranslationAlgo.check()) {
-        setError(aTranslationAlgo.getError());
+      if (!aTranslationAlgo->check()) {
+        setError(aTranslationAlgo->getError());
         return;
       }
 
-      aTranslationAlgo.build();
+      aTranslationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aTranslationAlgo.isDone()) {
+      if(!aTranslationAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Translation algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aTranslationAlgo.shape()->isNull()) {
+      if(aTranslationAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aTranslationAlgo.isValid()) {
+      if(!aTranslationAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+      aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aBaseShape,
+                                               aTranslationAlgo,
+                                               "Translated");
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -324,34 +334,39 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints()
       aResultPart->setTrsf(*aContext, aTrsf);
       setResult(aResultPart, aResultIndex);
     } else {
-      GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aFirstPoint, aSecondPoint);
+      std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+        new GeomAlgoAPI_Translation(aBaseShape, aFirstPoint, aSecondPoint));
 
-      if (!aTranslationAlgo.check()) {
-        setError(aTranslationAlgo.getError());
+      if (!aTranslationAlgo->check()) {
+        setError(aTranslationAlgo->getError());
         return;
       }
 
-      aTranslationAlgo.build();
+      aTranslationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aTranslationAlgo.isDone()) {
+      if(!aTranslationAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Translation algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aTranslationAlgo.shape()->isNull()) {
+      if(aTranslationAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aTranslationAlgo.isValid()) {
+      if(!aTranslationAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+      aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aBaseShape,
+                                               aTranslationAlgo,
+                                               "Translated");
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -360,19 +375,3 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints()
   // Remove the rest results if there were produced in the previous pass.
   removeResults(aResultIndex);
 }
-
-//=================================================================================================
-void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
-                                              std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                              std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
-  // Store result.
-  theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape());
-
-  std::string aTranslatedName = "Translated";
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
-
-  FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody,
-                                            theBaseShape, 1, 2, 3, aTranslatedName,
-                                            *aSubShapes.get());
-}
index 191f208ab2201124903c1d1c31d31c0422d3f4e0..624d8de393c49c8c40984baae44ef4df4de5eb73 100644 (file)
@@ -149,10 +149,6 @@ private:
 
   ///Perform the translation usind two points
   void performTranslationByTwoPoints();
-
-  void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
 
 #endif
index 775da23a3416a93956b2801ec6f296d7a5165766..9c9cfdc5aa0ef9663490b3ee2cc76e753e25d7ab 100644 (file)
@@ -121,7 +121,7 @@ void FeaturesPlugin_Union::execute()
   }
 
   // Checking that the algorithm worked properly.
-  GeomAlgoAPI_MakeShapeList aMakeShapeList;
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   GeomAPI_DataMapOfShapeShape aMapOfShapes;
   if(!anAlgo->isDone()) {
     setError("Error: Boolean algorithm failed.");
@@ -137,7 +137,7 @@ void FeaturesPlugin_Union::execute()
   }
 
   GeomShapePtr aShape = anAlgo->shape();
-  aMakeShapeList.appendAlgo(anAlgo);
+  aMakeShapeList->appendAlgo(anAlgo);
   aMapOfShapes.merge(anAlgo->mapOfSubShapes());
 
   // Store original shapes for naming.
@@ -163,30 +163,21 @@ void FeaturesPlugin_Union::execute()
     }
 
     aShape = aFillerAlgo->shape();
-    aMakeShapeList.appendAlgo(aFillerAlgo);
+    aMakeShapeList->appendAlgo(aFillerAlgo);
     aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
   }
   // workaround: make copy to name edges correctly
 
   // Store result and naming.
-  const int aModifyEdgeTag = 1;
-  const int aModifyFaceTag = 2;
-  const int aDeletedTag = 3;
-  /// sub solids will be placed at labels 4, 5 etc. if result is compound of solids
-  const int aSubsolidsTag = 4;
   const std::string aModEName = "Modified_Edge";
   const std::string aModFName = "Modified_Face";
 
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-  aResultBody->storeModified(anObjects.front(), aShape, aSubsolidsTag);
+  aResultBody->storeModified(anObjects.front(), aShape);
 
   for(ListOfShape::const_iterator anIter = anObjects.begin(); anIter != anObjects.end(); ++anIter) {
-    aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::EDGE,
-                                             aModifyEdgeTag, aModEName, aMapOfShapes,
-                                             false, true, true);
-    aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE,
-                                             aModifyFaceTag, aModFName, aMapOfShapes,
-                                             false, true, true);
+    aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::EDGE, aModEName);
+    aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aModFName);
     //aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
   }
 
index 6ed3adf8e21d25821bbb702c697d84204216a1f6..ded490e1f1656d4c0edc3f6a032ed2023a99b6a8 100644 (file)
@@ -21,6 +21,7 @@
 #include "GeomAlgoAPI_MakeShape.h"
 
 #include <BOPAlgo_Builder.hxx>
+#include <BRep_Tool.hxx>
 #include <BRepBuilderAPI_MakeShape.hxx>
 #include <BRepCheck_Analyzer.hxx>
 #include <BRepGProp.hxx>
@@ -31,7 +32,9 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
+#include <TopoDS.hxx>
 #include <TopoDS_Builder.hxx>
+#include <TopoDS_Edge.hxx>
 
 // new shape -> old shapes -> index in the old shape
 typedef NCollection_DataMap<TopoDS_Shape,
@@ -41,7 +44,7 @@ typedef
   NCollection_DataMap<int, NCollection_DataMap<TopoDS_Shape, MapNewToOld, TopTools_ShapeMapHasher> >
   HistoryMap;
 
-//=================================================================================================
+//==================================================================================================
 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
 : myBuilderType(Unknown),
   myDone(false)
@@ -49,32 +52,34 @@ GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
   myHist = 0;
 }
 
-GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape() {
+//==================================================================================================
+GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape()
+{
   if (myHist) {
     delete (HistoryMap*)myHist;
   }
 }
 
-//=================================================================================================
+//==================================================================================================
 bool GeomAlgoAPI_MakeShape::isDone() const
 {
   return myDone;
 }
 
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
+//==================================================================================================
+const GeomShapePtr GeomAlgoAPI_MakeShape::shape() const
 {
   return myShape;
 }
 
-//=================================================================================================
+//==================================================================================================
 bool GeomAlgoAPI_MakeShape::isValid() const
 {
   BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
   return (aChecker.IsValid() == Standard_True);
 }
 
-//=================================================================================================
+//==================================================================================================
 bool GeomAlgoAPI_MakeShape::hasVolume() const
 {
   bool hasVolume = false;
@@ -88,88 +93,86 @@ bool GeomAlgoAPI_MakeShape::hasVolume() const
   return hasVolume;
 }
 
-//=================================================================================================
+//==================================================================================================
 std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_MakeShape::mapOfSubShapes() const
 {
   return myMap;
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                      ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::generated(const GeomShapePtr theOldShape,
+                                      ListOfShape& theNewShapes)
 {
   TopTools_ListOfShape aList;
   if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
     BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
-    aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
+    aList = aMakeShape->Generated(theOldShape->impl<TopoDS_Shape>());
   } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
     BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
-    aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
+    aList = aBOPBuilder->Generated(theOldShape->impl<TopoDS_Shape>());
   }
   for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
-    if(anIt.Value().IsNull()) {
-      continue;
-    }
-    std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+    GeomShapePtr aShape(new GeomAPI_Shape());
     aShape->setImpl(new TopoDS_Shape(anIt.Value()));
-    theHistory.push_back(aShape);
+    if (!isValidForHistory(aShape)) continue;
+    fixOrientation(aShape);
+    theNewShapes.push_back(aShape);
   }
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                     ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::modified(const GeomShapePtr theOldShape,
+                                     ListOfShape& theNewShapes)
 {
   TopTools_ListOfShape aList;
   if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
     BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
     try {
-      aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
+      aList = aMakeShape->Modified(theOldShape->impl<TopoDS_Shape>());
     } catch(Standard_NoSuchObject) {
     }
   } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
     BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
-    aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
+    aList = aBOPBuilder->Modified(theOldShape->impl<TopoDS_Shape>());
   }
   for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
-    if(anIt.Value().IsNull()) {
-      continue;
-    }
-    std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+    GeomShapePtr aShape(new GeomAPI_Shape());
     aShape->setImpl(new TopoDS_Shape(anIt.Value()));
-    theHistory.push_back(aShape);
+    if (!isValidForHistory(aShape)) continue;
+    fixOrientation(aShape);
+    theNewShapes.push_back(aShape);
   }
 }
 
-//=================================================================================================
-bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::isDeleted(const GeomShapePtr theOldShape)
 {
   bool isDeleted = false;
   if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
     BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
-    isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+    isDeleted = aMakeShape->IsDeleted(theOldShape->impl<TopoDS_Shape>()) == Standard_True;
   } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
     BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
-    isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+    isDeleted = aBOPBuilder->IsDeleted(theOldShape->impl<TopoDS_Shape>()) == Standard_True;
   }
 
   return isDeleted;
 }
 
-//=================================================================================================
+//==================================================================================================
 void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType)
 {
   myBuilderType = theBuilderType;
 }
 
-//=================================================================================================
+//==================================================================================================
 void GeomAlgoAPI_MakeShape::setDone(const bool theFlag)
 {
   myDone = theFlag;
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::setShape(const GeomShapePtr theShape)
 {
   if(myShape.get() && myShape->isEqual(theShape)) {
     return;
@@ -187,17 +190,17 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theSha
 
     const TopoDS_Shape& aTopoDSShape = myShape->impl<TopoDS_Shape>();
     for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+      GeomShapePtr aCurrentShape(new GeomAPI_Shape());
       aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
       myMap->bind(aCurrentShape, aCurrentShape);
     }
     for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+      GeomShapePtr aCurrentShape(new GeomAPI_Shape());
       aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
       myMap->bind(aCurrentShape, aCurrentShape);
     }
     for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+      GeomShapePtr aCurrentShape(new GeomAPI_Shape());
       aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
       myMap->bind(aCurrentShape, aCurrentShape);
     }
@@ -208,8 +211,30 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theSha
   }
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::initialize() {
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::isValidForHistory(const GeomShapePtr theShape)
+{
+  if (!theShape.get()) return false;
+
+  const TopoDS_Shape& aShape_ = theShape->impl<TopoDS_Shape>();
+  if (aShape_.IsNull()) return false;
+
+  if (aShape_.ShapeType() == TopAbs_EDGE) {
+    TopoDS_Edge anEdge_ = TopoDS::Edge(aShape_);
+    if (BRep_Tool::Degenerated(anEdge_)) return false;
+  }
+
+  return true;
+}
+
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::fixOrientation(GeomShapePtr& theShape) {
+  if (myMap->isBound(theShape)) theShape = myMap->find(theShape);
+}
+
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::initialize()
+{
   switch (myBuilderType) {
     case OCCT_BRepBuilderAPI_MakeShape: {
       myDone = implPtr<BRepBuilderAPI_MakeShape>()->IsDone() == Standard_True;
@@ -233,7 +258,7 @@ void GeomAlgoAPI_MakeShape::initialize() {
 
   const TopoDS_Shape& aTopoDSShape = myShape->impl<TopoDS_Shape>();
   for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) {
-    std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+    GeomShapePtr aCurrentShape(new GeomAPI_Shape());
     aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
     myMap->bind(aCurrentShape, aCurrentShape);
   }
@@ -241,21 +266,21 @@ void GeomAlgoAPI_MakeShape::initialize() {
 }
 
 
-//=================================================================================================
+//==================================================================================================
 void GeomAlgoAPI_MakeShape::prepareNamingFaces()
 {
   long long index = 1;
   GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE);
   for(GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); anExp.more(); anExp.next()) {
-    std::shared_ptr<GeomAPI_Shape> aFace = anExp.current();
+    GeomShapePtr aFace = anExp.current();
     myCreatedFaces["Face_" + std::to_string(index++)] = aFace;
   }
 }
 
 
-//=================================================================================================
-bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){
-
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage)
+{
   // isValid() is called from this method
   if (!isValid()) {
     myError = theMessage + " :: resulting shape is not valid.";
@@ -278,8 +303,9 @@ bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){
   return true ;
 }
 
-bool GeomAlgoAPI_MakeShape::newShapesCollected(
-  std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::isNewShapesCollected(GeomShapePtr theWholeOld,
+                                                 const int theShapeType)
 {
   if (!myHist)
     return false;
@@ -290,7 +316,7 @@ bool GeomAlgoAPI_MakeShape::newShapesCollected(
 }
 
 void GeomAlgoAPI_MakeShape::collectNewShapes(
-  std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType)
+  GeomShapePtr theWholeOld, const int theShapeType)
 {
   if (!myHist)
     myHist = new HistoryMap;
@@ -339,9 +365,10 @@ static void addAllSubs(const TopoDS_Shape& theNewShape,
   }
 }
 
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::oldShapesForNew(
-  std::shared_ptr<GeomAPI_Shape> theWholeOld,
-  std::shared_ptr<GeomAPI_Shape> theNewShape, const int theShapeType)
+//==================================================================================================
+GeomShapePtr GeomAlgoAPI_MakeShape::oldShapesForNew(GeomShapePtr theWholeOld,
+                                                    GeomShapePtr theNewShape,
+                                                    const int theShapeType)
 {
   GeomShapePtr aResult(new GeomAPI_Shape);
   TopoDS_Compound aResComp;
index eb2396c96736daaa37e0b95fa6fa5f49085228b2..cb5d3f0eb701c486e85c05abf4c3335a8c17fc82 100644 (file)
@@ -52,7 +52,8 @@ public:
   /// \brief Constructor by builder and builder type.
   /// \param[in] theBuilder pointer to the builder.
   /// \param[in] theBuilderType builder type.
-  template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder,
+  template<class T> explicit GeomAlgoAPI_MakeShape(
+    T* theBuilder,
     const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
   : GeomAPI_Interface(theBuilder),
     myBuilderType(theBuilderType)
@@ -63,7 +64,8 @@ public:
   /// \brief Initializes internals.
   /// \param[in] theBuilder pointer to the builder.
   /// \param[in] theBuilderType builder type.
-  template<class T> void initialize(T* theBuilder,
+  template<class T> void initialize(
+    T* theBuilder,
     const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
   {
     setImpl(theBuilder);
@@ -75,7 +77,7 @@ public:
   GEOMALGOAPI_EXPORT bool isDone() const;
 
   /// \return a shape built by the shape construction algorithm.
-  GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
+  GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
 
   /// \return true if resulting shape is valid.
   GEOMALGOAPI_EXPORT bool isValid() const;
@@ -87,34 +89,35 @@ public:
   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
 
   /// \return the list of shapes generated from the shape \a theShape.
-  /// \param[in] theShape base shape.
-  /// \param[out] theHistory generated shapes.
-  GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                            ListOfShape& theHistory);
+  /// \param[in] theOldShape base shape.
+  /// \param[out] theNewShapes shapes generated from \a theShape. Does not cleared!
+  GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape,
+                                            ListOfShape& theNewShapes);
 
   /// \return the list of shapes modified from the shape \a theShape.
-  /// \param[in] theShape base shape.
-  /// \param[out] theHistory modified shapes. Does not cleared!
-  GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                           ListOfShape& theHistory);
+  /// \param[in] theOldShape base shape.
+  /// \param[out] theNewShapes shapes modified from \a theShape. Does not cleared!
+  GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
+                                           ListOfShape& theNewShapes);
 
   /// \return true if theShape was deleted.
-  /// \param[in] theShape base shape.
-  GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+  /// \param[in] theOldShape base shape.
+  GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape);
 
   /// \return true if the data were correct.
   GEOMALGOAPI_EXPORT virtual bool check() { return true; };
 
+  /// \brief Prepare the naming of faces.
+  GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
+
   ///  \return the list of created faces.
-  GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces()
-  {return myCreatedFaces;}
+  GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() {
+    return myCreatedFaces;
+  }
 
   /// \return the error.
   GEOMALGOAPI_EXPORT std::string getError() { return myError; }
 
-  /// \brief Prepare the naming of faces.
-  GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
-
   /// \brief Check the validity of the produced shape.
   GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
 
@@ -122,24 +125,24 @@ public:
   /// \param theWholeOld the whole old shape
   /// \param theShapeType type of the sub-shapes that is used for optimization
   /// \returns true if optimization containers are already filled
-  GEOMALGOAPI_EXPORT bool newShapesCollected(
-    std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType);
+  GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld,
+                                               const int theShapeType);
 
   /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
   /// \param theWholeOld the whole old shape
   /// \param theShapeType type of the sub-shapes that is used for optimization
   /// \returns true if optimization containers are already filled
-  GEOMALGOAPI_EXPORT void collectNewShapes(
-    std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType);
+  GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld,
+                                           const int theShapeType);
 
   /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
   /// \param theWholeOld the whole old shape
   /// \param theNewShape the whole new shape
   /// \param theShapeType type of the old sub-shapes
   /// \returns compound of all old shapes that were used for creation of the given new
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> oldShapesForNew(
-    std::shared_ptr<GeomAPI_Shape> theWholeOld,
-    std::shared_ptr<GeomAPI_Shape> theNewShape, const int theShapeType);
+  GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld,
+                                                  GeomShapePtr theNewShape,
+                                                  const int theShapeType);
 
 protected:
   /// \brief Sets builder type.
@@ -152,7 +155,13 @@ protected:
 
   /// \brief Sets result shape.
   /// \param[in] theShape new shape.
-  void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
+  void setShape(const GeomShapePtr theShape);
+
+  /// \return true if passed shape is valid for history.
+  bool isValidForHistory(const GeomShapePtr theShape);
+
+  /// Replaces \a theShape with shape from \a myMap.
+  void fixOrientation(GeomShapePtr& theShape);
 
 protected:
    /// Data map to keep correct orientation of sub-shapes.
@@ -160,7 +169,7 @@ protected:
   /// Error occurred during the execution of an algorithm.
   std::string myError;
   /// Map of created faces with their name for naming.
-  std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces;
+  std::map< std::string, GeomShapePtr > myCreatedFaces;
 
 private:
   /// \brief Initializes internals.
@@ -169,13 +178,14 @@ private:
 private:
   GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
   bool myDone; ///< Builder status.
-  std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
+  GeomShapePtr myShape; ///< Resulting shape.
 
   /// map that is used to keep the optimization structure for access to the history
   /// kind of sub-shapes -> whole old shape -> new shape -> list of old shapes that create this new
   void* myHist;
 };
 
-typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;
+typedef std::shared_ptr<GeomAlgoAPI_MakeShape> GeomMakeShapePtr;
+typedef std::list<GeomMakeShapePtr> ListOfMakeShape;
 
 #endif
index 01bf7a88a8af2c82ca0b94f1f90dabe9cfe212d4..81f16868ea9717d559fdcb3ddf3b32a0212a2902 100644 (file)
 
 #include <GeomAlgoAPI_MakeShapeCustom.h>
 
-//=================================================================================================
+//==================================================================================================
 GeomAlgoAPI_MakeShapeCustom::GeomAlgoAPI_MakeShapeCustom()
 {}
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeCustom::setResult(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::setResult(const GeomShapePtr theShape)
 {
   setShape(theShape);
 }
 
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::addModified(const std::shared_ptr<GeomAPI_Shape> theBase,
-                                              const std::shared_ptr<GeomAPI_Shape> theResult)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addModified(const GeomShapePtr theOldShape,
+                                              const GeomShapePtr theNewShape)
 {
-  return myModified.add(theBase, theResult);
+  if (!isValidForHistory(theNewShape)) return false;
+  GeomShapePtr aNewShape = theNewShape;
+  fixOrientation(aNewShape);
+  return myModified.add(theOldShape, aNewShape);
 }
 
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const std::shared_ptr<GeomAPI_Shape> theBase,
-                                               const std::shared_ptr<GeomAPI_Shape> theResult)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const GeomShapePtr theOldShape,
+                                               const GeomShapePtr theNewShape)
 {
-  return myGenerated.add(theBase, theResult);
+  if (!isValidForHistory(theNewShape)) return false;
+  GeomShapePtr aNewShape = theNewShape;
+  fixOrientation(aNewShape);
+  return myGenerated.add(theOldShape, aNewShape);
 }
 
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const GeomShapePtr theOldShape)
 {
-  return myDeleted.bind(theShape, theShape);
+  return myDeleted.bind(theOldShape, theOldShape);
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeCustom::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                            ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::generated(const GeomShapePtr theOldShape,
+                                            ListOfShape& theNewShapes)
 {
   ListOfShape aGenerated;
-  if(myGenerated.find(theShape, aGenerated)) {
-    theHistory.insert(theHistory.end(), aGenerated.begin(), aGenerated.end());
+  if(myGenerated.find(theOldShape, aGenerated)) {
+    theNewShapes.insert(theNewShapes.end(), aGenerated.begin(), aGenerated.end());
   }
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeCustom::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                           ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::modified(const GeomShapePtr theOldShape,
+                                           ListOfShape& theNewShapes)
 {
   ListOfShape aModified;
-  if(myModified.find(theShape, aModified)) {
-    theHistory.insert(theHistory.end(), aModified.begin(), aModified.end());
+  if(myModified.find(theOldShape, aModified)) {
+    theNewShapes.insert(theNewShapes.end(), aModified.begin(), aModified.end());
   }
 }
 
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const GeomShapePtr theOldShape)
 {
-  return myDeleted.isBound(theShape);
-}
\ No newline at end of file
+  return myDeleted.isBound(theOldShape);
+}
index 77bfac0e231e924f22a962e86c53b4da807bb304..6fca968ea9c7fad8d0151a2f8449b349744e7a29 100644 (file)
@@ -37,29 +37,29 @@ public:
   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeCustom();
 
   /// Sets result shape.
-  GEOMALGOAPI_EXPORT void setResult(const std::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT void setResult(const GeomShapePtr theShape);
 
   /// Adds modified shape.
-  GEOMALGOAPI_EXPORT bool addModified(const std::shared_ptr<GeomAPI_Shape> theBase,
-                                      const std::shared_ptr<GeomAPI_Shape> theResult);
+  GEOMALGOAPI_EXPORT bool addModified(const GeomShapePtr theOldShape,
+                                      const GeomShapePtr theNewShape);
 
   /// Adds generated shape.
-  GEOMALGOAPI_EXPORT bool addGenerated(const std::shared_ptr<GeomAPI_Shape> theBase,
-                                       const std::shared_ptr<GeomAPI_Shape> theResult);
+  GEOMALGOAPI_EXPORT bool addGenerated(const GeomShapePtr theOldShape,
+                                       const GeomShapePtr theNewShape);
 
   /// Adds deleted shape.
-  GEOMALGOAPI_EXPORT bool addDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT bool addDeleted(const GeomShapePtr theOldShape);
 
   /// \return the list of shapes generated from the shape theShape
-  GEOMALGOAPI_EXPORT void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                            ListOfShape& theHistory);
+  GEOMALGOAPI_EXPORT void generated(const GeomShapePtr theOldShape,
+                                    ListOfShape& theNewShapes);
 
   /// \return the list of shapes modified from the shape theShape
-  GEOMALGOAPI_EXPORT void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                           ListOfShape& theHistory);
+  GEOMALGOAPI_EXPORT void modified(const GeomShapePtr theShape,
+                                   ListOfShape& theNewShapes);
 
   /// \return whether the shape is deleted
-  GEOMALGOAPI_EXPORT bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT bool isDeleted(const GeomShapePtr theOldShape);
 
 private:
   GeomAPI_DataMapOfShapeMapOfShapes myGenerated;
index 1c615ced3505a04201f1ab6bfe933ba95f5e71c9..659399f580cfe2f6c58100510aeca32b47ecd43d 100644 (file)
 #include <NCollection_Map.hxx>
 #include <TopoDS_Shape.hxx>
 
-//=================================================================================================
+//==================================================================================================
 GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList()
 : GeomAlgoAPI_MakeShape()
 {}
 
-//=================================================================================================
+//==================================================================================================
 GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList)
 : GeomAlgoAPI_MakeShape()
 {
   init(theMakeShapeList);
 }
 
-//=================================================================================================
+//==================================================================================================
 void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList)
 {
   if(myMap.get()) {
@@ -54,9 +54,9 @@ void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList)
   }
 }
 
-//=================================================================================================
+//==================================================================================================
 void GeomAlgoAPI_MakeShapeList::appendAlgo(
-  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+  const GeomMakeShapePtr theMakeShape)
 {
   myListOfMakeShape.push_back(theMakeShape);
   if(!myMap.get()) {
@@ -65,38 +65,41 @@ void GeomAlgoAPI_MakeShapeList::appendAlgo(
   myMap->merge(theMakeShape->mapOfSubShapes());
 }
 
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShapeList::shape() const
+//==================================================================================================
+const GeomShapePtr GeomAlgoAPI_MakeShapeList::shape() const
 {
-  std::shared_ptr<GeomAPI_Shape> aShape = GeomAlgoAPI_MakeShape::shape();
+  GeomShapePtr aShape = GeomAlgoAPI_MakeShape::shape();
   if(aShape.get() && !aShape->impl<TopoDS_Shape>().IsNull()) {
     return aShape;
   } else if(!myListOfMakeShape.empty()) {
     return myListOfMakeShape.back()->shape();
   }
-  return std::shared_ptr<GeomAPI_Shape>();
+  return GeomShapePtr();
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                          ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeList::generated(const GeomShapePtr theOldShape,
+                                          ListOfShape& theNewShapes)
 {
-  result(theShape,  GeomAlgoAPI_MakeShapeList::Generated, theHistory);
+  result(theOldShape,  GeomAlgoAPI_MakeShapeList::Generated, theNewShapes);
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
-                                         ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeList::modified(const GeomShapePtr theOldShape,
+                                         ListOfShape& theNewShapes)
 {
-  result(theShape, GeomAlgoAPI_MakeShapeList::Modified, theHistory);
+  result(theOldShape, GeomAlgoAPI_MakeShapeList::Modified, theNewShapes);
 }
 
-bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeList::isDeleted(const GeomShapePtr theOldShape)
 {
-  for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin();
-      aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) {
-    std::shared_ptr<GeomAlgoAPI_MakeShape> aMakeShape = *aBuilderIt;
-    if(aMakeShape->isDeleted(theShape)) {
+  for (ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin();
+       aBuilderIt != myListOfMakeShape.end();
+       ++aBuilderIt)
+  {
+    GeomMakeShapePtr aMakeShape = *aBuilderIt;
+    if(aMakeShape->isDeleted(theOldShape)) {
       return true;
     }
   }
@@ -104,9 +107,10 @@ bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr<GeomAPI_Shape> t
   return false;
 }
 
-void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr<GeomAPI_Shape> theShape,
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeList::result(const GeomShapePtr theOldShape,
                                        OperationType theOperationType,
-                                       ListOfShape& theHistory)
+                                       ListOfShape& theNewShapes)
 {
   if(myListOfMakeShape.empty()) {
     return;
@@ -115,24 +119,30 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr<GeomAPI_Shape> theS
   NCollection_Map<TopoDS_Shape> anAlgoShapes;
   NCollection_Map<TopoDS_Shape> aResultShapesMap;
   NCollection_List<TopoDS_Shape> aResultShapesList;
-  anAlgoShapes.Add(theShape->impl<TopoDS_Shape>());
-  aResultShapesMap.Add(theShape->impl<TopoDS_Shape>());
-  aResultShapesList.Append(theShape->impl<TopoDS_Shape>());
+  anAlgoShapes.Add(theOldShape->impl<TopoDS_Shape>());
+  aResultShapesMap.Add(theOldShape->impl<TopoDS_Shape>());
+  aResultShapesList.Append(theOldShape->impl<TopoDS_Shape>());
 
   for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin();
-      aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) {
-    std::shared_ptr<GeomAlgoAPI_MakeShape> aMakeShape = *aBuilderIt;
+      aBuilderIt != myListOfMakeShape.end();
+      ++aBuilderIt)
+  {
+    GeomMakeShapePtr aMakeShape = *aBuilderIt;
     NCollection_Map<TopoDS_Shape> aTempShapes;
-    for(NCollection_Map<TopoDS_Shape>::Iterator
-        aShapeIt(anAlgoShapes); aShapeIt.More(); aShapeIt.Next()) {
+    for (NCollection_Map<TopoDS_Shape>::Iterator aShapeIt(anAlgoShapes);
+         aShapeIt.More();
+         aShapeIt.Next())
+    {
       bool hasResults = false;
       bool anArgumentIsInResult = false;
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+      GeomShapePtr aShape(new GeomAPI_Shape);
       aShape->setImpl(new TopoDS_Shape(aShapeIt.Value()));
       ListOfShape aGeneratedShapes;
       aMakeShape->generated(aShape, aGeneratedShapes);
-      for (ListOfShape::const_iterator
-        anIt = aGeneratedShapes.cbegin(); anIt != aGeneratedShapes.cend(); anIt++) {
+      for (ListOfShape::const_iterator anIt = aGeneratedShapes.cbegin();
+           anIt != aGeneratedShapes.cend();
+           ++anIt)
+      {
         const TopoDS_Shape& anItShape = (*anIt)->impl<TopoDS_Shape>();
         if (anItShape.IsSame(aShapeIt.Value())) {
           anArgumentIsInResult = true;
@@ -146,8 +156,10 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr<GeomAPI_Shape> theS
       }
       ListOfShape aModifiedShapes;
       aMakeShape->modified(aShape, aModifiedShapes);
-      for(ListOfShape::const_iterator
-          anIt = aModifiedShapes.cbegin(); anIt != aModifiedShapes.cend(); anIt++) {
+      for (ListOfShape::const_iterator anIt = aModifiedShapes.cbegin();
+           anIt != aModifiedShapes.cend();
+           ++anIt)
+      {
         const TopoDS_Shape& anItShape = (*anIt)->impl<TopoDS_Shape>();
         if (anItShape.IsSame(aShapeIt.Value())) {
           anArgumentIsInResult = true;
@@ -175,10 +187,14 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr<GeomAPI_Shape> theS
     anAlgoShapes.Unite(aTempShapes);
   }
 
-  for(NCollection_List<TopoDS_Shape>::Iterator
-      aShapeIt(aResultShapesList); aShapeIt.More(); aShapeIt.Next()) {
-    std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt(aResultShapesList);
+       aShapeIt.More();
+       aShapeIt.Next())
+  {
+    GeomShapePtr aShape(new GeomAPI_Shape());
     aShape->setImpl(new TopoDS_Shape(aShapeIt.Value()));
-    theHistory.push_back(aShape);
+    if (!isValidForHistory(aShape)) continue;
+    fixOrientation(aShape);
+    theNewShapes.push_back(aShape);
   }
 }
index e79826e89f86c2c4eaf2866ea8d422183abc2c66..3a5bdf1abb078bf06bd9385540c25adff523a316 100644 (file)
@@ -51,24 +51,24 @@ public:
 
   /// \brief Adds algo to the end of list.
   /// \param[in] theMakeShape algo to be added.
-  GEOMALGOAPI_EXPORT void appendAlgo(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
+  GEOMALGOAPI_EXPORT void appendAlgo(const GeomMakeShapePtr theMakeShape);
 
   /// \return a shape built by the shape construction algorithms
-  GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
+  GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
 
   /// \return the list of shapes generated from the shape \a theShape
-  GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+  GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theShape,
                                             ListOfShape& theHistory);
 
   /// \return the list of shapes modified from the shape \a theShape
-  GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
+  GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theShape,
                                            ListOfShape& theHistory);
 
   /// \return whether the shape is deleted
-  GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theShape);
 
 private:
-  void result(const std::shared_ptr<GeomAPI_Shape> theShape,
+  void result(const GeomShapePtr theShape,
               OperationType theOperationType,
               ListOfShape& theHistory);
 
index dbed19f4b8212a7456ae146f13af20e4d5e127fb..c17c9b8d56c3ea2cf4870d67825bb84db2679001 100755 (executable)
@@ -49,6 +49,7 @@
 #include <BRep_Tool.hxx>
 #include <BRepTools_History.hxx>
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_ShapeExplorer.h>
 #include <GeomAlgoAPI_MakeShape.h>
 #include <GeomAlgoAPI_SortListOfShapes.h>
 #include <Config_PropManager.h>
 //#include <TDF_Tool.hxx>
 //#define DEB_IMPORT 1
 
-static const int VERTICES_TAG = 1;
-static const int EDGES_TAG = 2;
-static const int FACES_TAG = 3;
-static const int DELETED_TAG = 4;
-static const int PRIMITIVES_START_TAG = 11;
+static const int INVALID_TAG            = -1;
+static const int GENERATED_VERTICES_TAG = 1;
+static const int GENERATED_EDGES_TAG    = 2;
+static const int GENERATED_FACES_TAG    = 3;
+static const int MODIFIED_VERTICES_TAG  = 4;
+static const int MODIFIED_EDGES_TAG     = 5;
+static const int MODIFIED_FACES_TAG     = 6;
+static const int DELETED_TAG            = 7;
+static const int PRIMITIVES_START_TAG   = 11;
+
+static int getGenerationTag(const TopoDS_Shape& theShape) {
+  TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+  switch (aShapeType) {
+    case TopAbs_VERTEX: return GENERATED_VERTICES_TAG;
+    case TopAbs_EDGE:   return GENERATED_EDGES_TAG;
+    case TopAbs_FACE:   return GENERATED_FACES_TAG;
+  }
+
+  return INVALID_TAG;
+}
+
+static int getModificationTag(const TopoDS_Shape& theShape) {
+  TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+  switch (aShapeType) {
+    case TopAbs_VERTEX: return MODIFIED_VERTICES_TAG;
+    case TopAbs_EDGE:   return MODIFIED_EDGES_TAG;
+    case TopAbs_FACE:   return MODIFIED_FACES_TAG;
+  }
+
+  return INVALID_TAG;
+}
+
+static TopAbs_ShapeEnum convertShapeType(const GeomAPI_Shape::ShapeType theType) {
+  switch (theType) {
+    case GeomAPI_Shape::VERTEX:    return TopAbs_VERTEX;
+    case GeomAPI_Shape::EDGE:      return TopAbs_EDGE;
+    case GeomAPI_Shape::WIRE:      return TopAbs_WIRE;
+    case GeomAPI_Shape::FACE:      return TopAbs_FACE;
+    case GeomAPI_Shape::SHELL:     return TopAbs_SHELL;
+    case GeomAPI_Shape::SOLID:     return TopAbs_SOLID;
+    case GeomAPI_Shape::COMPSOLID: return TopAbs_COMPSOLID;
+    case GeomAPI_Shape::COMPOUND:  return TopAbs_COMPOUND;
+    case GeomAPI_Shape::SHAPE:     return TopAbs_SHAPE;
+  }
+  return TopAbs_SHAPE;
+}
+
+static bool isAlreadyStored(const TNaming_Builder* theBuilder,
+                            const TopoDS_Shape& theOldShape,
+                            const TopoDS_Shape& theNewShape)
+{
+  for (TNaming_Iterator aNamingIt(theBuilder->NamedShape());
+    aNamingIt.More();
+    aNamingIt.Next())
+  {
+    if (aNamingIt.NewShape().IsSame(theNewShape)
+      && aNamingIt.OldShape().IsSame(theOldShape))
+    {
+      return true;
+    }
+  }
+
+  return false;
+}
 
 Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner)
 : ModelAPI_BodyBuilder(theOwner),
@@ -142,7 +202,7 @@ void Model_BodyBuilder::evolutionToSelection(const bool theFlag)
   evolutionToSelectionRec(aShapeLab, theFlag);
 }
 
-void Model_BodyBuilder::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+void Model_BodyBuilder::store(const GeomShapePtr& theShape,
                               const bool theIsStoreSameShapes)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
@@ -186,8 +246,8 @@ void Model_BodyBuilder::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
   }
 }
 
-void Model_BodyBuilder::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-  const std::shared_ptr<GeomAPI_Shape>& theToShape)
+void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape,
+  const GeomShapePtr& theToShape)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
@@ -232,15 +292,15 @@ TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
   return aFind->second;
 }
 
-void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape,
+                                      const GeomShapePtr& theNewShape,
+                                      const bool theIsCleanStored)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
     TDF_Label& aShapeLab = aData->shapeLab();
     // clean builders
-    if (theDecomposeSolidsTag != -2)
-      clean();
+    if (theIsCleanStored) clean();
     // store the new shape as primitive
     TNaming_Builder* aBuilder = builder(0);
     if (!theOldShape || !theNewShape)
@@ -266,7 +326,7 @@ void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theO
   }
 }
 
-void  Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void  Model_BodyBuilder::storeWithoutNaming(const GeomShapePtr& theShape)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
@@ -313,10 +373,19 @@ Model_BodyBuilder::~Model_BodyBuilder()
 void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
 {
   std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
-  //aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), theName);
-  TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), theName.c_str());
+  std::string aName = theName;
+  switch (theTag) {
+    case GENERATED_VERTICES_TAG: aName += aName.empty() ? "Generated_Vertex" : "_GV"; break;
+    case GENERATED_EDGES_TAG:    aName += aName.empty() ? "Generated_Edge"   : "_GE"; break;
+    case GENERATED_FACES_TAG:    aName += aName.empty() ? "Generated_Face"   : "_GF"; break;
+    case MODIFIED_VERTICES_TAG:  aName += aName.empty() ? "Modified_Vertex"  : "_MV"; break;
+    case MODIFIED_EDGES_TAG:     aName += aName.empty() ? "Modified_Edge"    : "_ME"; break;
+    case MODIFIED_FACES_TAG:     aName += aName.empty() ? "Modified_Face"    : "_MF"; break;
+  }
+
+  TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str());
 }
-void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
                                   const std::string& theName)
 {
   TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
@@ -328,76 +397,78 @@ void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theNewSh
   ++myPrimitiveTag;
 }
 
-void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape,
+                                  const GeomShapePtr& theNewShape,
+                                  const std::string& theName)
 {
   TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
   TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
-  builder(theTag)->Generated(anOldShape, aNewShape);
-  if(!theName.empty())
-    buildName(theTag, theName);
-  TopAbs_ShapeEnum aGenShapeType = aNewShape.ShapeType();
-  if(aGenShapeType == TopAbs_WIRE || aGenShapeType == TopAbs_SHELL) {
-    TopAbs_ShapeEnum anExplodeShapeType = aGenShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE;
-    const TDF_Label aLabel = builder(theTag)->NamedShape()->Label();
-    int aTag = 1;
-    std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
-    for(TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) {
-      TDF_Label aChildLabel = aLabel.FindChild(aTag);
-      TNaming_Builder aBuilder(aChildLabel);
-      aBuilder.Generated(anOldShape, anExp.Current());
-      TCollection_AsciiString aChildName = TCollection_AsciiString((theName + "_").c_str()) + aTag;
-      //aDoc->addNamingName(aChildLabel, aChildName.ToCString());
-      TDataStd_Name::Set(aChildLabel, aChildName.ToCString());
-      aTag++;
+  TopAbs_ShapeEnum aNewShapeType = aNewShape.ShapeType();
+  int aTag;
+  if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) {
+    // TODO: This is a workaround. New shape should be only vertex, edge or face.
+    TopAbs_ShapeEnum anExplodeShapeType = aNewShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE;
+    aTag = TopAbs_WIRE ? GENERATED_EDGES_TAG : GENERATED_FACES_TAG;
+    for (TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) {
+      builder(aTag)->Generated(anOldShape, anExp.Current());
+      buildName(aTag, theName);
     }
+  } else {
+    aTag = getGenerationTag(aNewShape);
+    if (aTag == INVALID_TAG) return;
+    builder(aTag)->Generated(anOldShape, aNewShape);
+    buildName(aTag, theName);
   }
 }
 
-
-void Model_BodyBuilder::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+void Model_BodyBuilder::modified(const GeomShapePtr& theOldShape,
+                                 const GeomShapePtr& theNewShape,
+                                 const std::string& theName)
 {
   TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
   TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
-  builder(theTag)->Modify(anOldShape, aNewShape);
-  if(!theName.empty())
-    buildName(theTag, theName);
+  int aTag = getModificationTag(aNewShape);
+  if (aTag == INVALID_TAG) return;
+  builder(aTag)->Modify(anOldShape, aNewShape);
+  buildName(aTag, theName);
 }
 
-void Model_BodyBuilder::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const int theTag)
+void Model_BodyBuilder::deleted(const GeomShapePtr& theOldShape)
 {
   TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
-  builder(theTag)->Delete(aShape);
+  builder(DELETED_TAG)->Delete(aShape);
 }
 
-void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
-  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-  const int  theKindOfShape,
-  const int  theTag,
-  const GeomShapePtr theShapes)
+void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+                                          const GeomShapePtr& theOldShape,
+                                          const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                          const GeomShapePtr& theShapesToExclude)
 {
-  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
-  TopTools_MapOfShape aView;
-  TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
+  TopTools_MapOfShape anAlreadyProcessedShapes;
   GeomShapePtr aResultShape = shape();
-  for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
-    const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
-    if (!aView.Add(aRoot)) continue;
-    std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
-    aRShape->setImpl((new TopoDS_Shape(aRoot)));
-    if (!theMS->isDeleted(aRShape)
-        || aResultShape->isSubShape(aRShape, false)
-        || (theShapes.get() && theShapes->isSubShape(aRShape, false))) {
+  for (GeomAPI_ShapeExplorer anExp(theOldShape, theShapeTypeToExplore);
+       anExp.more();
+       anExp.next())
+  {
+    GeomShapePtr anOldSubShape = anExp.current();
+    const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
+    if (!anAlreadyProcessedShapes.Add(anOldSubShape_)
+        || !theAlgo->isDeleted(anOldSubShape)
+        || aResultShape->isSubShape(anOldSubShape, false)
+        || (theShapesToExclude.get() && theShapesToExclude->isSubShape(anOldSubShape, false)))
+    {
       continue;
     }
 
-    ListOfShape aHist;
-    if (BRepTools_History::IsSupportedType(aRoot)) // to avoid crash in #2572
-      theMS->modified(aRShape, aHist);
-    if (aHist.size() == 0 || (aHist.size() == 1 && aHist.front()->isSame(aRShape)))
-      builder(theTag)->Delete(aRoot);
+    ListOfShape aNewShapes;
+    if (BRepTools_History::IsSupportedType(anOldSubShape_)) { // to avoid crash in #2572
+      theAlgo->modified(anOldSubShape, aNewShapes);
+    }
+
+    if (aNewShapes.size() == 0
+        || (aNewShapes.size() == 1 && aNewShapes.front()->isSame(anOldSubShape))) {
+      builder(DELETED_TAG)->Delete(anOldSubShape_);
+    }
   }
 }
 
@@ -457,285 +528,102 @@ TopAbs_ShapeEnum typeOfAncestor(const TopAbs_ShapeEnum theSubType) {
   return TopAbs_VERTEX; // bad case
 }
 
-void Model_BodyBuilder::loadAndOrientModifiedShapes (
-  GeomAlgoAPI_MakeShape* theMS,
-  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-  const int  theKindOfShape,
-  const int  theTag,
-  const std::string& theName,
-  GeomAPI_DataMapOfShapeShape& theSubShapes,
-  const bool theIsStoreSeparate,
-  const bool theIsStoreAsGenerated)
+void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+                                           const GeomShapePtr& theOldShape,
+                                           const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                           const std::string& theName)
 {
-  static const int THE_ANCHOR_TAG = 100000;
-
-  int anIndex = 1;
-  int aTag = theTag;
-  bool isBuilt = !theName.empty();
-  std::string aName = theName;
-  std::ostringstream aStream;
   GeomShapePtr aResultShape = shape();
-  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
-  TopTools_MapOfShape aView;
-  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
-
-  TopoDS_Shape aShapeToIterate;
-  if (theMS->newShapesCollected(theShapeIn, theKindOfShape)) {
+  GeomShapePtr aShapeToExplore = theOldShape;
+  if (theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) {
     // use optimized set of old shapes for this
-    GeomShapePtr aCompound = theMS->oldShapesForNew(theShapeIn, aResultShape, theKindOfShape);
-    if (aCompound.get())
-      aShapeToIterate = aCompound->impl<TopoDS_Shape>();
-  } else {
-    aShapeToIterate = aShapeIn;
+    GeomShapePtr aCompound = theAlgo->oldShapesForNew(theOldShape,
+                                                      aResultShape,
+                                                      theShapeTypeToExplore);
+    if (aCompound.get()) aShapeToExplore = aCompound;
   }
 
-  TopExp_Explorer aShapeExplorer (aShapeToIterate, (TopAbs_ShapeEnum)theKindOfShape);
-  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
-    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
-    if (!aView.Add(aRoot)) continue;
-
-    bool aNotInTree =
-      TNaming_Tool::NamedShape(aRoot, aData->shapeLab()).IsNull();
-    if (aNotInTree && !theIsStoreSeparate) {
-      // there is no sense to write history if old shape does not exist in the document
-      continue; // but if it is stored separately, it will be builded as a primitive
-    }
-    ListOfShape aList;
-    std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
-    aRShape->setImpl((new TopoDS_Shape(aRoot)));
-    theMS->modified(aRShape, aList);
+  TopTools_MapOfShape anAlreadyProcessedShapes;
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+  for (GeomAPI_ShapeExplorer anOldShapeExp(aShapeToExplore, theShapeTypeToExplore);
+       anOldShapeExp.more();
+       anOldShapeExp.next())
+  {
+    GeomShapePtr anOldSubShape = anOldShapeExp.current();
+    const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
 
-    if (!theIsStoreSeparate) {
-      //keepTopLevelShapes(aList, aRoot, aResultShape);
-      removeBadShapes(aList);
+    // 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;
     }
-    // sort the list of images before naming
-    GeomAlgoAPI_SortListOfShapes::sort(aList);
-
-    // to trace situation where several objects are produced by one parent (#2317)
-    int aSameParentShapes = (aShapeIn.ShapeType() == TopAbs_WIRE
-                             || aShapeIn.ShapeType() == TopAbs_SHELL
-                             || aShapeIn.ShapeType() == TopAbs_COMPOUND) ? 0 : -1;
-    std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator
-      anIt = aList.begin(), aLast = aList.end();
-    for (; anIt != aLast; anIt++) {
-      TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
-      if (theSubShapes.isBound(*anIt)) {
-        std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
-        aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
-      }
-      isBuilt = !theName.empty();
-      if(!aRoot.IsSame(aNewShape)
-         && aResultShape->isSubShape((*anIt), false)
-         && !aResultShape->isSame(*anIt)) // to avoid put of same shape on main label and sub
-      {
-        if (!theIsStoreSeparate) {
-          aSameParentShapes++;
-        } else if (aNotInTree) // check this new shape can not be represented as
-                              // a sub-shape of higher level sub-shapes
-        {
-          TopAbs_ShapeEnum aNewType = aNewShape.ShapeType();
-          TopAbs_ShapeEnum anAncestorType = typeOfAncestor(aNewType);
-          if (anAncestorType != TopAbs_VERTEX) {
-            bool aFound = false;
-            TopoDS_Shape aResultTShape = aResultShape->impl<TopoDS_Shape>();
-            TopExp_Explorer anAncestorExp(aResultTShape, anAncestorType);
-            for(; anAncestorExp.More() && !aFound; anAncestorExp.Next()) {
-              if (aResultTShape.IsSame(anAncestorExp.Current()))
-                continue;
-              TopExp_Explorer aSubExp(anAncestorExp.Current(), aNewType);
-              for(; aSubExp.More(); aSubExp.Next()) {
-                if (aNewShape.IsSame(aSubExp.Current())) {
-                  aFound = true;
-                  break;
-                }
-              }
-            }
-            if (aFound) {
-              continue; // not need to store this shape in the BRep structure
-            }
-          }
-        }
 
-        int aFoundTag = 0;
-        bool isFoundSameOld = false;
-        bool isFoundDiffOld = false;
+    // Get new shapes.
+    ListOfShape aNewShapes;
+    theAlgo->modified(anOldSubShape, aNewShapes);
 
-        // Check if new shape was already stored.
-        for (std::map<int, TNaming_Builder*>::iterator aBuildersIt = myBuilders.begin();
-             aBuildersIt != myBuilders.end();
-             ++aBuildersIt)
-        {
-          TNaming_Builder* aBuilder = aBuildersIt->second;
-          for (TNaming_Iterator aNamingIt(aBuilder->NamedShape());
-               aNamingIt.More();
-               aNamingIt.Next())
-          {
-            if (aNamingIt.NewShape().IsSame(aNewShape))
-            {
-              aNamingIt.OldShape().IsSame(aRoot) ? isFoundSameOld = true
-                                                 : isFoundDiffOld = true;
-              aFoundTag = aBuildersIt->first;
-            }
-          }
+    for (ListOfShape::const_iterator aNewShapesIt = aNewShapes.cbegin();
+         aNewShapesIt != aNewShapes.cend();
+         ++aNewShapesIt)
+    {
+      GeomShapePtr aNewShape = *aNewShapesIt;
+      const TopoDS_Shape& aNewShape_ = aNewShape->impl<TopoDS_Shape>();
+      bool isGenerated = anOldSubShape_.ShapeType() != aNewShape_.ShapeType();
 
-          if (isFoundSameOld || isFoundDiffOld) break;
-        }
+      bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape);
+      bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false);
+      if (aNewShapeIsSameAsOldShape
+          || aNewShapeIsNotInResultShape)
+      {
+        continue;
+      }
 
-        if (isFoundSameOld) {
-          // Builder already contains same old->new shapes, don't store it twice.
+      TNaming_Builder* aBuilder;
+      if (aResultShape->isSame(aNewShape)) {
+        // keep the modification evolution on the root level (2241 - history propagation issue)
+        aBuilder = builder(0);
+        TDF_Label aShapeLab = aBuilder->NamedShape()->Label();
+        Handle(TDF_Reference) aRef;
+        if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
+          // Store only in case if it does not have reference.
           continue;
         }
 
-        int aBuilderTag = aSameParentShapes > 0 ? THE_ANCHOR_TAG : aTag;
-
-        int aCurShapeType = (int)((*anIt)->shapeType());
-        bool needSuffix = false; // suffix for the name based on the shape type
-        if (aCurShapeType != theKindOfShape) {
-          // modified shape has different type => set another tag
-          // to avoid shapes of different types on the same label
-          aBuilderTag = THE_ANCHOR_TAG;
-          needSuffix = true;
-        }
-        std::string aSuffix;
-        if (needSuffix) {
-          switch (aCurShapeType) {
-            case GeomAPI_Shape::VERTEX: aSuffix = "_v_" + std::to_string(myVIndex++); break;
-            case GeomAPI_Shape::EDGE:   aSuffix = "_e_" + std::to_string(myEIndex++); break;
-            case GeomAPI_Shape::FACE:   aSuffix = "_f_" + std::to_string(myFIndex++); break;
-            default: break;
-          }
-        }
-
-        std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>> aKeepShapes, aMoveShapes;
-        if (isFoundDiffOld) {
-          // Found same new shape with different old shape.
-          if (aFoundTag >= THE_ANCHOR_TAG) {
-            // Found on separated tag.
-            aBuilderTag = aFoundTag; // Store it on the same tag.
-            isBuilt = false; // Don't change name;
-          } else {
-            // Found on previous tag.
-            if (aBuilderTag < THE_ANCHOR_TAG) {
-              // New shape shouls not be separated.
-              aBuilderTag = aFoundTag; // Store it on the same tag.
-              isBuilt = false; // Don't change name;
-            } else {
-              // New shape should be separated from others. Move shapes from found tag to new tag.
-              while (myBuilders.find(aBuilderTag) != myBuilders.end()) {
-                ++aBuilderTag;
-              }
-
-              TNaming_Builder* aFoundBuilder = myBuilders.at(aFoundTag);
-              Handle(TNaming_NamedShape) aFoundNamedShape = aFoundBuilder->NamedShape();
-              TDF_Label aFoundLabel = aFoundNamedShape->Label();
-              TNaming_Evolution anEvolution = aFoundNamedShape->Evolution();
-              for (TNaming_Iterator aNamingIt(aFoundNamedShape);
-                   aNamingIt.More();
-                   aNamingIt.Next())
-              {
-                std::pair<TopoDS_Shape, TopoDS_Shape> aShapesPair =
-                  std::make_pair(aNamingIt.OldShape(), aNamingIt.NewShape());
-                aNamingIt.NewShape().IsSame(aNewShape) ? aMoveShapes.push_back(aShapesPair)
-                                                       : aKeepShapes.push_back(aShapesPair);
-              }
-
-              aFoundNamedShape->Clear();
-              for (std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>>::iterator aKeepIt =
-                     aKeepShapes.begin();
-                   aKeepIt != aKeepShapes.end();
-                   ++aKeepIt)
-              {
-                if (anEvolution == TNaming_GENERATED) {
-                  aFoundBuilder->Generated(aKeepIt->first, aKeepIt->second);
-                } else {
-                  aFoundBuilder->Modify(aKeepIt->first, aKeepIt->second);
-                }
-              }
-            }
-          }
-        } else if (aBuilderTag == THE_ANCHOR_TAG) {
-          while (myBuilders.find(aBuilderTag) != myBuilders.end()) {
-            ++aBuilderTag;
-          }
-        }
+        // Check if new shape was already stored.
+        if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
 
-        if(theIsStoreAsGenerated) {
-          // Here we store shapes as generated, to avoid problem when one parent shape produce
-          // several child shapes. In this case naming could not determine which shape to select.
-          builder(aBuilderTag)->Generated(aRoot, aNewShape);
-          for (std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>>::iterator aMoveIt =
-               aMoveShapes.begin();
-               aMoveIt != aMoveShapes.end();
-               ++aMoveIt)
-          {
-            builder(aBuilderTag)->Generated(aMoveIt->first, aMoveIt->second);
-          }
-        } else if (aNotInTree) {
-          // not in tree -> store as primitive (stored as separated)
-          builder(aBuilderTag)->Generated(aNewShape);
-        } else if (aCurShapeType != theKindOfShape) {
-           // if different shape type is produced, make it as generated
-          builder(aBuilderTag)->Generated(aRoot, aNewShape);
-        } else {
-          builder(aBuilderTag)->Modify(aRoot, aNewShape);
-          for (std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>>::iterator aMoveIt =
-               aMoveShapes.begin();
-               aMoveIt != aMoveShapes.end();
-               ++aMoveIt) {
-            builder(aBuilderTag)->Modify(aMoveIt->first, aMoveIt->second);
-          }
+        if (!aBuilder->NamedShape().IsNull() &&
+            ((isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_GENERATED)
+              || (!isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_MODIFY)))
+        {
+          myBuilders.erase(0); // clear old builder to avoid different evolutions crash
+          aBuilder = builder(0);
         }
-        if(isBuilt) {
-          aStream.str(std::string());
-          aStream.clear();
-          aStream << theName;
-          if (theIsStoreSeparate && !isFoundDiffOld)
-             aStream << "_" << anIndex++;
+      } else {
+        int aTag = isGenerated ? getGenerationTag(aNewShape_)
+                               : getModificationTag(aNewShape_);
+        aBuilder = builder(aTag);
 
-          if (aSameParentShapes > 0) {
-            aStream.str(std::string());
-            aStream.clear();
-            aStream << aName << "_" << "divided" << "_" << myDividedIndex++;
-          }
+        // Check if new shape was already stored.
+        if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
 
-          aStream << aSuffix;
-          buildName(aBuilderTag, aStream.str());
-        }
-        if(theIsStoreSeparate && !isFoundDiffOld) {
-          aTag++;
-        }
-      } else if (aResultShape->isSame(*anIt)) {
-        // keep the modification evolution on the root level (2241 - history propagation issue)
-        TNaming_Builder* aBuilder = builder(0);
-        TDF_Label aShapeLab = aBuilder->NamedShape()->Label();
-        Handle(TDF_Reference) aRef;
-        // Store only in case if it does not have reference.
-        if (!aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
-          if (theIsStoreAsGenerated) {
-            TNaming_Builder* aBuilder = builder(0);
-            if (!aBuilder->NamedShape().IsNull() &&
-                aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) {
-              myBuilders.erase(0); // clear old builder to avoid different evolutions crash
-            }
-            builder(0)->Generated(aRoot, aNewShape);
-          } else {
-            TNaming_Builder* aBuilder = builder(0);
-            if (!aBuilder->NamedShape().IsNull() &&
-              aBuilder->NamedShape()->Evolution() != TNaming_MODIFY) {
-              myBuilders.erase(0); // clear old builder to avoid different evolutions crash
-            }
-            builder(0)->Modify(aRoot, aNewShape);
-          }
-        }
+        buildName(aTag, theName);
       }
+
+      isGenerated ? aBuilder->Generated(anOldSubShape_, aNewShape_)
+                  : aBuilder->Modify(anOldSubShape_, aNewShape_);
     }
   }
 }
 
 void Model_BodyBuilder::loadAndOrientGeneratedShapes (
   GeomAlgoAPI_MakeShape* theMS,
-  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  GeomShapePtr  theShapeIn,
   const int  theKindOfShape,
   const int  theTag,
   const std::string& theName,
@@ -751,16 +639,16 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes (
     //if (TNaming_Tool::NamedShape(aRoot, builder(theTag)->NamedShape()->Label()).IsNull())
     //  continue; // there is no sense to write history if old shape does not exist in the document
     ListOfShape aList;
-    std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+    GeomShapePtr aRShape(new GeomAPI_Shape());
     aRShape->setImpl((new TopoDS_Shape(aRoot)));
     theMS->generated(aRShape, aList);
     keepTopLevelShapes(aList, aRoot);
-    std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator
+    std::list<GeomShapePtr >::const_iterator
       anIt = aList.begin(), aLast = aList.end();
     for (; anIt != aLast; anIt++) {
       TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
       if (theSubShapes.isBound(*anIt)) {
-        std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+        GeomShapePtr aMapShape(theSubShapes.find(*anIt));
         aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
       }
       if (!aRoot.IsSame (aNewShape)) {
@@ -824,7 +712,7 @@ void loadGeneratedDangleShapes(
 }
 
 //=======================================================================
-void Model_BodyBuilder::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
+void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
   const std::string& theName, int&  theTag)
 {
   if(theShape->isNull()) return;
@@ -981,7 +869,7 @@ int findAmbiguities(const TopoDS_Shape&           theShapeIn,
 
 //=======================================================================
 void Model_BodyBuilder::loadFirstLevel(
-  std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
+  GeomShapePtr theShape, const std::string& theName, int&  theTag)
 {
   if(theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
@@ -998,17 +886,17 @@ void Model_BodyBuilder::loadFirstLevel(
       if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
         itr.Value().ShapeType() == TopAbs_COMPSOLID)
       {
-        std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+        GeomShapePtr itrShape(new GeomAPI_Shape());
         itrShape->setImpl(new TopoDS_Shape(itr.Value()));
         loadFirstLevel(itrShape, theName, theTag);
       } else {
-        std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+        GeomShapePtr itrShape(new GeomAPI_Shape());
         itrShape->setImpl(new TopoDS_Shape(itr.Value()));
         loadNextLevels(itrShape, theName, theTag);
       }
     }
   } else {
-    std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+    GeomShapePtr itrShape(new GeomAPI_Shape());
     itrShape->setImpl(new TopoDS_Shape(aShape));
     loadNextLevels(itrShape, theName, theTag);
   }
@@ -1026,7 +914,7 @@ void Model_BodyBuilder::loadFirstLevel(
 
 //=======================================================================
 void Model_BodyBuilder::loadDisconnectedEdges(
-  std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
+  GeomShapePtr theShape, const std::string& theName, int&  theTag)
 {
   if(theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
@@ -1099,7 +987,7 @@ void Model_BodyBuilder::loadDisconnectedEdges(
   }
 }
 
-void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
+void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape,
                                                  const std::string& theName, int&  theTag)
 {
   if(theShape->isNull()) return;
@@ -1140,7 +1028,7 @@ void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape>
   }
 }
 
-std::shared_ptr<GeomAPI_Shape> Model_BodyBuilder::shape()
+GeomShapePtr Model_BodyBuilder::shape()
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData && aData->isValid()) {
@@ -1153,16 +1041,16 @@ std::shared_ptr<GeomAPI_Shape> Model_BodyBuilder::shape()
     if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
       TopoDS_Shape aShape = aName->Get();
       if (!aShape.IsNull()) {
-        std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+        GeomShapePtr aRes(new GeomAPI_Shape);
         aRes->setImpl(new TopoDS_Shape(aShape));
         return aRes;
       }
     }
   }
-  return std::shared_ptr<GeomAPI_Shape>();
+  return GeomShapePtr();
 }
 
-bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+bool Model_BodyBuilder::isLatestEqual(const GeomShapePtr& theShape)
 {
   if (theShape.get()) {
     TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
index 36be6cfbb5cf89ae901524cdc7fd53e35f96e20d..0217fb3a7cb52ee8d35a677358d28797c6c44ccd 100755 (executable)
@@ -41,89 +41,89 @@ class Model_BodyBuilder : public ModelAPI_BodyBuilder
   std::map<int, TNaming_Builder*> myBuilders;
 public:
   /// Stores the shape (called by the execution method).
-  MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+  MODEL_EXPORT virtual void store(const GeomShapePtr& theShape,
                                   const bool theIsStoreSameShapes = true);
 
   /// Stores the generated shape (called by the execution method).
-  MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-                                              const std::shared_ptr<GeomAPI_Shape>& theToShape);
+  MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
+                                           const GeomShapePtr& theToShape);
 
   /// Stores the modified shape (called by the execution method).
   /// \param theOldShape shape that produces result
   /// \param theNewShape resulting shape
   /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
   ///          theNewShape is compound of solids, if zero it is not used
-  MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-                                               const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-                                          const int theDecomposeSolidsTag = 0);
+  MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
+                                          const GeomShapePtr& theNewShape,
+                                          const bool theIsCleanStored = true) override;
 
   /// Stores the shape without naming support
   /// \param theShape shape to store
-  MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape);
+  MODEL_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
 
   /// Returns the shape-result produced by this feature
-  MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+  MODEL_EXPORT virtual GeomShapePtr shape();
 
   /// 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.
-  MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+  MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
                                       const std::string& theName) override;
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
   /// construction of a prism.
-  MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-    const std::string& theName, const int theTag = 1);
+  MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
+                                      const GeomShapePtr& theNewShape,
+                                      const std::string& theName = "") override;
 
 
   /// Records the shape newShape which is a modification of the shape oldShape.
   /// As an example, consider the case of a face split or merged in a Boolean operation.
-  MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-    const std::string& theName, const int theTag = 1);
+  MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
+                                     const GeomShapePtr& theNewShape,
+                                     const std::string& theName = "") override;
 
   /// Records the shape oldShape which was deleted from the current label.
   /// As an example, consider the case of a face removed by a Boolean operation.
-  MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const int theTag = 1);
+  MODEL_EXPORT virtual void deleted(const GeomShapePtr& theOldShape) override;
 
   /// load deleted shapes
-  MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                               const GeomShapePtr theShapes = GeomShapePtr());
+  MODEL_EXPORT
+  virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+                                 const GeomShapePtr& theOldShape,
+                                 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                 const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override;
+
   /// load and orient modified shapes
-  MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
-                                                  GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                                                                          const std::string& theName,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes,
-                                               const bool theIsStoreSeparate = false,
-                                               const bool theIsStoreAsGenerated = false);
-   /// load and orient generated shapes
-  MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
-                                                  GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                                                                          const std::string& theName,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes);
+  MODEL_EXPORT
+  virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+                                  const GeomShapePtr& theOldShape,
+                                  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                  const std::string& theName = "") override;
+
+  /// load and orient generated shapes
+  MODEL_EXPORT
+  virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+                                            GeomShapePtr  theShapeIn,
+                                            const int theKindOfShape,
+                                            const int theTag,
+                                            const std::string& theName,
+                                            GeomAPI_DataMapOfShapeShape& theSubShapes);
 
   /// Loads shapes of the first level (to be used during shape import)
-  MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
-                                           const std::string& theName, int&  theTag);
+  MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
+                                           const std::string& theName,
+                                           int& theTag);
 
   /// Loads disconnected edges
-  MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
-                                                  const std::string& theName, int&  theTag);
+  MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
+                                                  const std::string& theName,
+                                                  int& theTag);
 
   /// Loads disconnected vetexes
-  MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
-                                                     const std::string& theName, int&  theTag);
+  MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
+                                                     const std::string& theName,
+                                                     int& theTag);
 
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_BodyBuilder();
@@ -134,7 +134,7 @@ public:
 
   /// Returns true if the latest modification of this body in the naming history
   // is equal to the given shape
-  MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+  MODEL_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape);
 
 protected:
   /// Default constructor accessible only by Model_Objects
@@ -148,7 +148,7 @@ protected:
 
 private:
   /// Loads shapes of the next level (to be used during shape import)
-  void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
+  void loadNextLevels(GeomShapePtr theShape,
                       const std::string& theName, int&  theTag);
 
   /// builds name for the shape kept at the specified tag
index eaee3ac1e01df37a144fb4e18d3fde829dd745fa..746bbd7921d58e984fbd898d0d05f0b0e2477de9 100644 (file)
@@ -52,17 +52,16 @@ Model_ResultBody::~Model_ResultBody()
   delete myBuilder;
 }
 
-void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
-    std::shared_ptr<GeomAPI_Shape> theShapeIn, const int  theKindOfShape, const int  theTag,
-    const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
-    const bool theIsStoreSeparate,
-    const bool theIsStoreAsGenerated,
-    const bool theSplitInSubs)
+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
+  if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs
     // optimization of getting of new shapes for specific sub-result
-    if (!theMS->newShapesCollected(theShapeIn, theKindOfShape))
-      theMS->collectNewShapes(theShapeIn, theKindOfShape);
+    if (!theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore))
+      theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore);
     std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
     for(; aSubIter != mySubs.cend(); aSubIter++) {
       // check that sub-shape was also created as modification of ShapeIn
@@ -84,14 +83,10 @@ void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
           }
         }
       }*/
-      (*aSubIter)->loadAndOrientModifiedShapes(
-        theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
-        theIsStoreAsGenerated, theSplitInSubs);
+      (*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
     }
   } else { // do for this directly
-    myBuilder->loadAndOrientModifiedShapes(
-      theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
-        theIsStoreAsGenerated);
+    myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
   }
 }
 
index 6047bc059c71ea4e56f277b0bea1c4c6e561f5eb..eda74f541740dafbc2ee62546cd848205bfddf2d 100644 (file)
@@ -50,11 +50,11 @@ public:
   MODEL_EXPORT virtual ~Model_ResultBody();
 
   /// load and orient modified shapes for sub-objects
-  MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
-    std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
-    const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
-    const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
-    const bool theSplitInSubs = false);
+  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;
 
 
   /// Returns the number of sub-elements
index 90bd71015870b9742f476b8ae146db4bf30f9818..6edfd2c001f4cb4e470fe5bb69cc6d94e49ccb7f 100755 (executable)
@@ -42,83 +42,80 @@ public:
   MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
 
   /// Stores the shape (called by the execution method).
-  virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+  virtual void store(const GeomShapePtr& theShape,
                      const bool theIsStoreSameShapes = true) = 0;
 
   /// Stores the generated shape (called by the execution method).
-  virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-                                 const std::shared_ptr<GeomAPI_Shape>& theToShape) = 0;
+  virtual void storeGenerated(const GeomShapePtr& theFromShape,
+                              const GeomShapePtr& theToShape) = 0;
 
   /// Stores the modified shape (called by the execution method).
-  virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-                            const int theDecomposeSolidsTag = 0) = 0;
+  virtual void storeModified(const GeomShapePtr& theOldShape,
+                             const GeomShapePtr& theNewShape,
+                             const bool theIsCleanStored = true) = 0;
 
   /// Stores the shape without naming support
-  virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+  virtual void storeWithoutNaming(const GeomShapePtr& theShape) = 0;
 
   /// Returns the shape-result produced by this feature
-  virtual std::shared_ptr<GeomAPI_Shape> shape() = 0;
+  virtual GeomShapePtr shape() = 0;
 
   /// 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.
-  virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+  virtual void generated(const GeomShapePtr& theNewShape,
                          const std::string& theName) = 0;
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
   /// construction of a prism.
-  virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
-    const int theTag = 1) = 0;
+  virtual void generated(const GeomShapePtr& theOldShape,
+                         const GeomShapePtr& theNewShape,
+                         const std::string& theName = "") = 0;
 
   /// Records the shape newShape which is a modification of the shape oldShape.
   /// As an example, consider the case of a face split or merged in a Boolean operation.
-  virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
-    const int theTag = 1) = 0;
+  virtual void modified(const GeomShapePtr& theOldShape,
+                        const GeomShapePtr& theNewShape,
+                        const std::string& theName = "") = 0;
 
   /// Records the shape oldShape which was deleted from the current label.
   /// As an example, consider the case of a face removed by a Boolean operation.
-  virtual void deleted(
-    const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
+  virtual void deleted(const GeomShapePtr& theOldShape) = 0;
 
   /// load deleted shapes
-  virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                               const GeomShapePtr theShapes = GeomShapePtr()) = 0;
+  virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+                                 const GeomShapePtr& theOldShape,
+                                 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                 const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0;
+
   /// load and orient modified shapes
-  virtual void loadAndOrientModifiedShapes (
-                                                  GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                                                                          const std::string& theName,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes,
-                                               const bool theIsStoreSeparate = false,
-                                               const bool theIsStoreAsGenerated = false) = 0;
+  virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+                                  const GeomShapePtr& theOldShape,
+                                  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                  const std::string& theName = "") = 0;
+
   /// load and orient generated shapes
-  virtual void loadAndOrientGeneratedShapes (
-                                                  GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                                                                          const std::string& theName,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+  virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+                                            GeomShapePtr theShapeIn,
+                                            const int theKindOfShape,
+                                            const int theTag,
+                                            const std::string& theName,
+                                            GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
 
   /// load shapes of the first level (to be used during shape import)
-  virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
-                              const std::string& theName, int&  theTag) = 0;
+  virtual void loadFirstLevel(GeomShapePtr theShape,
+                              const std::string& theName,
+                              int& theTag) = 0;
 
   /// load disconnected edges
-  virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
-                                     const std::string& theName, int&  theTag) = 0;
+  virtual void loadDisconnectedEdges(GeomShapePtr theShape,
+                                     const std::string& theName,
+                                     int& theTag) = 0;
 
   /// load disconnected vetexes
-  virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
-                                        const std::string& theName,int&  theTag) = 0;
+  virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
+                                        const std::string& theName,
+                                        int& theTag) = 0;
 
   /// Converts evolution of sub-shapes stored in naming structure to selection
   /// (theFlag = true) and back (theFlag = false)
@@ -126,7 +123,7 @@ public:
 
   /// Returns true if the latest modification of this body in the naming history
   // is equal to the given shape
-  virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+  virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
 
 protected:
   /// Returns the data manager of this object: attributes
index 9ca7a38ec05d3a2d4363f792c0ab1b100e3e30a7..c973853cdd9da51287d3f76b71ea5c7bc24bd715 100644 (file)
@@ -39,8 +39,8 @@ std::string ModelAPI_ResultBody::groupName()
   return group();
 }
 
-void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
-  const bool theIsStoreSameShapes)
+void ModelAPI_ResultBody::store(const GeomShapePtr& theShape,
+                                const bool theIsStoreSameShapes)
 {
   myBuilder->store(theShape, theIsStoreSameShapes);
   myConnect = ConnectionNotComputed;
@@ -53,8 +53,8 @@ void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
   updateSubs(theShape);
 }
 
-void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-  const std::shared_ptr<GeomAPI_Shape>& theToShape)
+void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape,
+                                         const GeomShapePtr& theToShape)
 {
   myBuilder->storeGenerated(theFromShape, theToShape);
   myConnect = ConnectionNotComputed;
@@ -67,11 +67,11 @@ void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& t
   updateSubs(theToShape);
 }
 
-void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-  const int theDecomposeSolidsTag)
+void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape,
+                                        const GeomShapePtr& theNewShape,
+                                        const bool theIsCleanStored)
 {
-  myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+  myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored);
   myConnect = ConnectionNotComputed;
 
   static Events_Loop* aLoop = Events_Loop::loop();
@@ -82,7 +82,7 @@ void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& th
   updateSubs(theNewShape);
 }
 
-void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void ModelAPI_ResultBody::storeWithoutNaming(const GeomShapePtr& theShape)
 {
   myBuilder->storeWithoutNaming(theShape);
   myConnect = ConnectionNotComputed;
@@ -93,81 +93,81 @@ void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape
   aECreator->sendUpdated(data()->owner(), aRedispEvent);
 }
 
-std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
+GeomShapePtr ModelAPI_ResultBody::shape()
 {
   return myBuilder->shape();
 }
 
-void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+void ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
                                     const std::string& theName)
 {
   myBuilder->generated(theNewShape, theName);
 }
 
-void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
-  const int theTag)
+void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
+                                    const GeomShapePtr& theNewShape,
+                                    const std::string& theName)
 {
-  myBuilder->generated(theOldShape, theNewShape, theName, theTag);
+  myBuilder->generated(theOldShape, theNewShape, theName);
 }
 
-void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
-  const int theTag)
+void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape,
+                                   const GeomShapePtr& theNewShape,
+                                   const std::string& theName)
 {
-  myBuilder->modified(theOldShape, theNewShape, theName, theTag);
+  myBuilder->modified(theOldShape, theNewShape, theName);
 }
 
 
-void ModelAPI_ResultBody::deleted(
-  const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
+void ModelAPI_ResultBody::deleted(const GeomShapePtr& theOldShape)
 {
-  myBuilder->deleted(theOldShape, theTag);
+  myBuilder->deleted(theOldShape);
 }
 
-void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
-  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-  const int  theKindOfShape,
-  const int  theTag,
-  const GeomShapePtr theShapes)
+void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+                                            const GeomShapePtr& theOldShape,
+                                            const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                            const GeomShapePtr& theShapesToExclude)
 {
-  myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag, theShapes);
+  myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
 }
 
-void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
-  std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
-  const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
-  const bool theIsStoreSeparate,
-  const bool theIsStoreAsGenerated,
-  const bool /*theSplitInSubs*/)
+void ModelAPI_ResultBody::loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+                                             const GeomShapePtr& theOldShape,
+                                             const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                             const std::string& theName)
 {
-  myBuilder->loadAndOrientModifiedShapes(
-    theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
-    theIsStoreAsGenerated);
+  myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
 }
 
 void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
-  std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape,
-  const int  theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
+                                                       GeomShapePtr theShapeIn,
+                                                       const int theKindOfShape,
+                                                       const int theTag,
+                                                       const std::string& theName,
+                                                       GeomAPI_DataMapOfShapeShape& theSubShapes)
 {
   myBuilder->loadAndOrientGeneratedShapes(
     theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
 }
 
-void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
-  const std::string& theName, int&  theTag)
+void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
+                                         const std::string& theName,
+                                         int& theTag)
 {
   myBuilder->loadFirstLevel(theShape, theName, theTag);
 }
 
-void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
-  const std::string& theName, int&  theTag)
+void ModelAPI_ResultBody::loadDisconnectedEdges(GeomShapePtr theShape,
+                                                const std::string& theName,
+                                                int& theTag)
 {
   myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
 }
 
-void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
-  const std::string& theName, int&  theTag)
+void ModelAPI_ResultBody::loadDisconnectedVertexes(GeomShapePtr theShape,
+                                                   const std::string& theName,
+                                                    int& theTag)
 {
   myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
 }
index 9bc81dfc4ab58d614cae68a5e7e32c90651912b4..4b40d7d216e590c91f86e392c1ea03ee3058eee6 100644 (file)
@@ -95,81 +95,87 @@ public:
   /// param[in] theShape shape to store.
   /// param[in] theIsStoreSameShapes if false stores reference to the same shape
   ///                                if it is already in document.
-  MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
-    const bool theIsStoreSameShapes = true);
+  MODELAPI_EXPORT virtual void store(const GeomShapePtr& theShape,
+                                     const bool theIsStoreSameShapes = true);
 
   /// Stores the generated shape (called by the execution method).
-  MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-    const std::shared_ptr<GeomAPI_Shape>& theToShape);
+  MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
+                                              const GeomShapePtr& theToShape);
 
   /// Stores the modified shape (called by the execution method).
-  MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
+  MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
+                                             const GeomShapePtr& theNewShape,
+                                             const bool theIsCleanStored = true);
 
   /// Stores the shape without naming support
-  MODELAPI_EXPORT virtual void storeWithoutNaming(
-    const std::shared_ptr<GeomAPI_Shape>& theShape);
+  MODELAPI_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
 
   /// Returns the shape-result produced by this feature
-  MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+  MODELAPI_EXPORT virtual GeomShapePtr shape();
 
   /// 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 std::shared_ptr<GeomAPI_Shape>& theNewShape,
+  MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
                                          const std::string& theName);
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
   /// construction of a prism.
-  MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
-    const int theTag = 1);
+  MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
+                                         const GeomShapePtr& theNewShape,
+                                         const std::string& theName = "");
 
   /// Records the shape newShape which is a modification of the shape oldShape.
   /// As an example, consider the case of a face split or merged in a Boolean operation.
-  MODELAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
-    const int theTag = 1);
+  MODELAPI_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
+                                        const GeomShapePtr& theNewShape,
+                                        const std::string& theName = "");
 
   /// Records the shape oldShape which was deleted from the current label.
   /// As an example, consider the case of a face removed by a Boolean operation.
-  MODELAPI_EXPORT virtual void deleted(
-    const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
+  MODELAPI_EXPORT virtual void deleted(const GeomShapePtr& theOldShape);
 
   /// load deleted shapes
-  MODELAPI_EXPORT virtual void loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
-    std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-    const int  theKindOfShape,
-    const int  theTag,
-    const GeomShapePtr theShapes = GeomShapePtr());
+  MODELAPI_EXPORT
+  virtual void loadDeletedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+                                 const GeomShapePtr& theOldShape,
+                                 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                 const GeomShapePtr& theShapesToExclude = GeomShapePtr());
 
   /// load and orient modified shapes
-  MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
-    std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
-    const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
-    const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
-    const bool theSplitInSubs = false);
+  MODELAPI_EXPORT
+  virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+                                  const GeomShapePtr& theOldShape,
+                                  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+                                  const std::string& theName = "");
 
   /// load and orient generated shapes
-  MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
-    std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape,
-    const int  theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
+  MODELAPI_EXPORT
+  virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+                                            GeomShapePtr theShapeIn,
+                                            const int theKindOfShape,
+                                            const int theTag,
+                                            const std::string& theName,
+                                            GeomAPI_DataMapOfShapeShape& theSubShapes);
 
   /// load shapes of the first level (to be used during shape import)
-  MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
-    const std::string& theName, int&  theTag);
+  MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
+                                              const std::string& theName,
+                                              int& theTag);
 
   /// load disconnected edges
-  MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
-    const std::string& theName, int&  theTag);
+  MODELAPI_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
+                                                     const std::string& theName,
+                                                     int& theTag);
 
   /// load disconnected vetexes
-  MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
-    const std::string& theName, int&  theTag);
+  MODELAPI_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
+                                                        const std::string& theName,
+                                                        int& theTag);
 
   /// Returns true if the latest modification of this body in the naming history
   // is equal to the given shape
-  MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+  MODELAPI_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
 
   /// Returns true is the topology is connected.
   MODELAPI_EXPORT virtual bool isConnectedTopology() = 0;
@@ -179,7 +185,7 @@ public:
   MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
 
   /// Updates the sub-bodies if shape of this object is compsolid or compound
-  MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
+  MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape,
     const bool theShapeChanged = true) = 0;
 
 protected: