Salome HOME
Issue #904 - Fatal error aftre delete sketch from dataset used in extrusion in part
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Boolean.cpp
index 0a3305bcde991df10043552c0915703f31ceaa26..e3f7141be58badd160677bedb8483fb010c03bc3 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "GeomAlgoAPI_Boolean.h"
 
+#include <GeomAlgoAPI_DFLoader.h>
+
 #include <BRepAlgoAPI_BooleanOperation.hxx>
 #include <BRepAlgoAPI_Common.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
@@ -51,10 +53,7 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeCommon(const ListOfShape
 GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const ListOfShape& theObjects,
                                          const ListOfShape& theTools,
                                          const OperationType theOperationType)
-: myDone(false),
-  myShape(new GeomAPI_Shape()),
-  myMap(new GeomAPI_DataMapOfShapeShape()),
-  myMkShape(new GeomAlgoAPI_MakeShape())
+: myDone(false)
 {
   build(theObjects, theTools, theOperationType);
 }
@@ -102,7 +101,7 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
       return;
     }
   }
-  myMkShape->setImpl(anOperation);
+  myMkShape.reset(new GeomAlgoAPI_MakeShape(anOperation));
   anOperation->SetArguments(anObjects);
   anOperation->SetTools(aTools);
 
@@ -114,12 +113,18 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
   }
   TopoDS_Shape aResult = anOperation->Shape();
 
+  if(aResult.ShapeType() == TopAbs_COMPOUND) {
+    aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+  }
+
   // fill data map to keep correct orientation of sub-shapes
+  myMap.reset(new GeomAPI_DataMapOfShapeShape());
   for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
     std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
     aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
     myMap->bind(aCurrentShape, aCurrentShape);
   }
+  myShape.reset(new GeomAPI_Shape());
   myShape->setImpl(new TopoDS_Shape(aResult));
 
 }