- 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;
+ switch(myOperationType) {
+ case BOOL_CUT: {
+ aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
+ aTools,
+ GeomAlgoAPI_Boolean::BOOL_CUT));
+ aResShape = aBoolAlgo->shape();
+ break;
+ }
+ case BOOL_COMMON: {
+ aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
+ aTools,
+ GeomAlgoAPI_Boolean::BOOL_COMMON));
+ aResShape = aBoolAlgo->shape();
+ break;
+ }
+ case BOOL_FILL: {
+ std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints =
+ GeomAlgoAPI_ShapeTools::getBoundingBox(aListWithObject, 1.0);
+
+ // Resize planes.
+ ListOfShape aToolsWithPlanes = aTools;
+ for(ListOfShape::const_iterator anIt = aPlanes.cbegin();
+ anIt != aPlanes.cend();
+ ++anIt)
+ {
+ GeomShapePtr aPlane = *anIt;
+ GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints);
+ std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
+ new GeomAlgoAPI_MakeShapeCustom);
+ aMkShCustom->addModified(aPlane, aTool);
+ aMakeShapeList.appendAlgo(aMkShCustom);
+ aToolsWithPlanes.push_back(aTool);
+ }
+
+ aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes));
+ aResShape = aBoolAlgo->shape();
+ if (aResShape.get() && 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;
+ }