- int aResultIndex = 0;
- ListOfMakeShape aListOfMakeShape;
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aDataMapOfShapes;
-
- switch(aType) {
- case GeomAlgoAPI_Boolean::BOOL_CUT:
- case GeomAlgoAPI_Boolean::BOOL_COMMON:{
- // Cut each object with all tools
- for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) {
- std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
- ListOfShape aListWithObject;
- aListWithObject.push_back(anObject);
- GeomAlgoAPI_Boolean aBoolAlgo(aListWithObject, aTools, aType);
-
- // Checking that the algorithm worked properly.
- if(!aBoolAlgo.isDone()) {
- static const std::string aFeatureError = "Boolean algorithm failed";
- setError(aFeatureError);
- return;
- }
- if(aBoolAlgo.shape()->isNull()) {
- static const std::string aShapeError = "Resulting shape is Null";
- setError(aShapeError);
- return;
- }
- if(!aBoolAlgo.isValid()) {
- std::string aFeatureError = "Warning: resulting shape is not valid";
- setError(aFeatureError);
- return;
- }
-
- if(GeomAlgoAPI_ShapeProps::volume(aBoolAlgo.shape()) > 1.e-7) {
- std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList = std::shared_ptr<GeomAlgoAPI_MakeShapeList>(
- new GeomAlgoAPI_MakeShapeList(aListOfMakeShape));
-
- LoadNamingDS(aResultBody, anObject, aTools, aBoolAlgo);
- setResult(aResultBody, aResultIndex);
- aResultIndex++;
- }
- }
- break;
- }
- case GeomAlgoAPI_Boolean::BOOL_FUSE: {
- // Fuse all objects and all tools.
- GeomAlgoAPI_Boolean aBoolAlgo(anObjects, aTools, aType);
-
- // Checking that the algorithm worked properly.
- if(!aBoolAlgo.isDone()) {
- static const std::string aFeatureError = "Boolean algorithm failed";
- setError(aFeatureError);
- return;
- }
- if(aBoolAlgo.shape()->isNull()) {
- static const std::string aShapeError = "Resulting shape is Null";
- setError(aShapeError);
- return;
- }
- if(!aBoolAlgo.isValid()) {
- std::string aFeatureError = "Warning: resulting shape is not valid";
- setError(aFeatureError);
- return;
- }
-
- std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList = std::shared_ptr<GeomAlgoAPI_MakeShapeList>(
- new GeomAlgoAPI_MakeShapeList(aListOfMakeShape));
-
- LoadNamingDS(aResultBody, anObjects.front(), aTools, aBoolAlgo);
- setResult(aResultBody, aResultIndex);
- aResultIndex++;
- break;
- }
- default: {
- std::string anOperationError = "Error: wrong type of operation";
- setError(anOperationError);
- return;
- }