- const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
- const TopoDS_Shape& aTool = theTool->impl<TopoDS_Shape>();
-
- BRepAlgoAPI_Cut aCut(aShape, aTool);
- if (aCut.IsDone()) {
- boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
- aResult->setImpl(new TopoDS_Shape(aCut.Shape()));
- return aResult;
+ if(theObjects.empty() || theTools.empty()) {
+ return;
+ }
+
+ // 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.reset(new GeomAlgoAPI_MakeShape(anOperation));
+ anOperation->SetArguments(anObjects);
+ anOperation->SetTools(aTools);
+
+ // Building and getting result.
+ anOperation->Build();
+ myDone = anOperation->IsDone() == Standard_True;
+ if(!myDone) {
+ return;