Salome HOME
Issue #2419: Fill ends in error "Resulting shape is not valid."
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Partition.cpp
index ea35d97f539d867d5bf13cc7e4328c044553d883..e8199f58c57393908eb190be80bb2d728b98d12b 100644 (file)
@@ -136,7 +136,16 @@ void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects,
   for (ListOfShape::const_iterator
        aToolsIt = theTools.begin(); aToolsIt != theTools.end(); aToolsIt++) {
     const TopoDS_Shape& aShape = (*aToolsIt)->impl<TopoDS_Shape>();
-    anOperation->AddTool(aShape);
+    // #2419: decompose compounds to get the valid result
+    TopTools_ListOfShape aSimpleShapes;
+    prepareShapes(aShape, aSimpleShapes);
+    TopTools_ListIteratorOfListOfShape aSimpleIter(aSimpleShapes);
+    for (; aSimpleIter.More(); aSimpleIter.Next()) {
+      const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
+      if (ShapesMap.Add(aSimpleSh)) {
+        anOperation->AddTool(aSimpleSh);
+      }
+    }
   }
 
   // Building and getting result.