]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1764: The result of partition is not stored in a folder
authordbv <dbv@opencascade.com>
Thu, 22 Sep 2016 07:27:12 +0000 (10:27 +0300)
committerdbv <dbv@opencascade.com>
Thu, 22 Sep 2016 07:27:12 +0000 (10:27 +0300)
Fixed connected topology creation in partition.

src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
src/Model/Model_ResultCompSolid.cpp
src/Model/Model_ResultCompSolid.h

index 075bd5f7b0498a51cb4d09cdc3ee42cf6252cb86..c2c9cdd1fa2b5d1e1c1a90555d9ec04478b94187 100644 (file)
@@ -22,6 +22,7 @@
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <algorithm>
 #include <map>
@@ -140,11 +141,37 @@ void FeaturesPlugin_Boolean::execute()
         ListOfShape aListWithObject;
         aListWithObject.push_back(anObject);
         GeomAlgoAPI_MakeShape aBoolAlgo;
+        GeomShapePtr aResShape;
 
         switch(aType) {
-          case BOOL_CUT:    aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_CUT); break;
-          case BOOL_COMMON: aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_COMMON); break;
-          case BOOL_FILL:   aBoolAlgo = GeomAlgoAPI_Partition(aListWithObject, aTools); break;
+          case BOOL_CUT: {
+            aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_CUT);
+            aResShape = aBoolAlgo.shape();
+            break;
+          }
+          case BOOL_COMMON: {
+            aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_COMMON);
+            aResShape = aBoolAlgo.shape();
+            break;
+          }
+          case BOOL_FILL: {
+            aBoolAlgo = GeomAlgoAPI_Partition(aListWithObject, aTools);
+            aResShape = aBoolAlgo.shape();
+            if(aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
+              int aSubResultsNb = 0;
+              GeomAPI_ShapeIterator anIt(aResShape);
+              for(; anIt.more(); anIt.next()) {
+                ++aSubResultsNb;
+              }
+              if(aSubResultsNb == 1) {
+                anIt.init(aResShape);
+                if(anIt.more()) {
+                  aResShape = anIt.current();
+                }
+              }
+            }
+            break;
+          }
         }
 
         // Checking that the algorithm worked properly.
@@ -153,7 +180,7 @@ void FeaturesPlugin_Boolean::execute()
           setError(aFeatureError);
           return;
         }
-        if(aBoolAlgo.shape()->isNull()) {
+        if(aResShape->isNull()) {
           static const std::string aShapeError = "Error: Resulting shape is Null.";
           setError(aShapeError);
           return;
@@ -164,9 +191,9 @@ void FeaturesPlugin_Boolean::execute()
           return;
         }
 
-        if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-27) {
+        if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27) {
           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-          loadNamingDS(aResultBody, anObject, aTools, aBoolAlgo.shape(), aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
+          loadNamingDS(aResultBody, anObject, aTools, aResShape, aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
index bc64bf02efff1db2fb5198822526d9740b2a004c..8eb3259c3751a7253efe5e4742ffbd46c53fa8f5 100644 (file)
@@ -324,39 +324,27 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::groupSharedTopology(const
     aGroups.Append(aGroupedShapes);
   }
 
-  if(aGroups.Size() == 1) {
-    NCollection_List<TopoDS_Shape> aGroup = aGroups.First();
+  TopoDS_Compound aCompound;
+  BRep_Builder aBuilder;
+  aBuilder.MakeCompound(aCompound);
+  ListOfShape aCompSolids, aFreeSolids;
+  for(NCollection_Vector<NCollection_List<TopoDS_Shape>>::Iterator anIt(aGroups); anIt.More(); anIt.Next()) {
+    NCollection_List<TopoDS_Shape> aGroup = anIt.Value();
     GeomShapePtr aGeomShape(new GeomAPI_Shape());
-    aGeomShape->setImpl(new TopoDS_Shape(makeCompound(aGroup)));
-    ListOfShape aCompSolids, aFreeSolids;
-    aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
-                                                        GeomAPI_Shape::COMPSOLID,
-                                                        aCompSolids,
-                                                        aFreeSolids);
-    aResult = aGeomShape;
-  } else {
-    TopoDS_Compound aCompound;
-    BRep_Builder aBuilder;
-    aBuilder.MakeCompound(aCompound);
-    ListOfShape aCompSolids, aFreeSolids;
-    for(NCollection_Vector<NCollection_List<TopoDS_Shape>>::Iterator anIt(aGroups); anIt.More(); anIt.Next()) {
-      NCollection_List<TopoDS_Shape> aGroup = anIt.Value();
-      GeomShapePtr aGeomShape(new GeomAPI_Shape());
-      if(aGroup.Size() == 1) {
-        aGeomShape->setImpl(new TopoDS_Shape(aGroup.First()));
-      } else {
-        aGeomShape->setImpl(new TopoDS_Shape(makeCompound(aGroup)));
-        aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
-                                                           GeomAPI_Shape::COMPSOLID,
-                                                           aCompSolids,
-                                                           aFreeSolids);
-      }
-      aBuilder.Add(aCompound, aGeomShape->impl<TopoDS_Shape>());
+    if(aGroup.Size() == 1) {
+      aGeomShape->setImpl(new TopoDS_Shape(aGroup.First()));
+    } else {
+      aGeomShape->setImpl(new TopoDS_Shape(makeCompound(aGroup)));
+      aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+                                                         GeomAPI_Shape::COMPSOLID,
+                                                         aCompSolids,
+                                                         aFreeSolids);
     }
+    aBuilder.Add(aCompound, aGeomShape->impl<TopoDS_Shape>());
+  }
 
-    if(!aCompound.IsNull()) {
-      aResult->setImpl(new TopoDS_Shape(aCompound));
-    }
+  if(!aCompound.IsNull()) {
+    aResult->setImpl(new TopoDS_Shape(aCompound));
   }
 
   return aResult;
index 00ca3915dcf558830a21b2eff65517d88e287793..823001cd6bff70b05f80e1537e277138da873250 100755 (executable)
@@ -30,9 +30,10 @@ Model_ResultCompSolid::~Model_ResultCompSolid()
   updateSubs(std::shared_ptr<GeomAPI_Shape>()); // erase sub-results
 }
 
-void Model_ResultCompSolid::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void Model_ResultCompSolid::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+                                  const bool theIsStoreSameShapes)
 {
-  ModelAPI_ResultCompSolid::store(theShape);
+  ModelAPI_ResultCompSolid::store(theShape, theIsStoreSameShapes);
   updateSubs(theShape);
 }
 
index 60ab44b0d2a48c6adbce3f2e54406e5da86d83e4..b7db1b82e236c71ac0f0a78bbbd8bcd55eff5383 100755 (executable)
@@ -32,7 +32,8 @@ public:
   MODEL_EXPORT virtual ~Model_ResultCompSolid();
 
   /// Stores the shape (called by the execution method). Creates sub-results for compsolid.
-  MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
+  MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+                                  const bool theIsStoreSameShapes = true);
 
   /// Stores the generated shape.  Creates sub-results for compsolid.
   MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,