+ // Getting objects.
+ TopTools_ListOfShape anObjects;
+ for(ListOfShape::const_iterator anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++)
+ {
+ anObjects.Append((*anObjectsIt)->impl<TopoDS_Shape>());
+ }
+
+ // Getting tools.
+ TopTools_ListOfShape aTools;
+ for(ListOfShape::const_iterator aToolsIt = theTools.begin(); aToolsIt != theTools.end(); aToolsIt++)
+ {
+ aTools.Append((*aToolsIt)->impl<TopoDS_Shape>());
+ }
+
+ // Creating boolean operation.
+ BRepAlgoAPI_BooleanOperation* anOperation;
+ switch (theOperationType) {
+ case BOOL_CUT: {
+ anOperation = new BRepAlgoAPI_Cut();
+ break;
+ }
+ case BOOL_FUSE: {
+ anOperation = new BRepAlgoAPI_Fuse();
+ break;
+ }
+ case BOOL_COMMON: {
+ anOperation = new BRepAlgoAPI_Common();
+ break;
+ }
+ default: {
+ return;
+ }
+ }
+ myMkShape->setImpl(anOperation);
+ anOperation->SetArguments(anObjects);
+ anOperation->SetTools(aTools);
+
+ // Building and getting result.
+ anOperation->Build();
+ myDone = anOperation->IsDone() == Standard_True;
+ if(!myDone) {
+ return;
+ }
+ TopoDS_Shape aResult = anOperation->Shape();
+
+ // fill data map to keep correct orientation of sub-shapes
+ 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->setImpl(new TopoDS_Shape(aResult));
+
+}