+
+ int aResultIndex = 0;
+
+ if(isCombine) {
+ // Create single result.
+ //if(!aTools.empty()) {
+ // // This is a workaround for naming. Passing compound of objects as argument instead each object separately.
+ // std::shared_ptr<GeomAPI_Shape> aCompoud = GeomAlgoAPI_CompoundBuilder::compound(anObjects);
+ // anObjects.clear();
+ // anObjects.push_back(aCompoud);
+ //}
+ std::shared_ptr<GeomAlgoAPI_Partition> aPartitionAlgo(new GeomAlgoAPI_Partition(anObjects, aTools));
+
+ // Checking that the algorithm worked properly.
+ if (!aPartitionAlgo->isDone()) {
+ static const std::string aFeatureError = "Error: Partition algorithm failed.";
+ setError(aFeatureError);
+ return;
+ }
+ if (aPartitionAlgo->shape()->isNull()) {
+ static const std::string aShapeError = "Error: Resulting shape is Null.";
+ setError(aShapeError);
+ return;
+ }
+ if (!aPartitionAlgo->isValid()) {
+ std::string aFeatureError = "Error: Resulting shape is not valid.";
+ setError(aFeatureError);
+ return;
+ }
+
+ if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo->shape()) > 1.e-7) {
+ std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
+ aMakeShapeList.appendAlgo(aPartitionAlgo);
+ GeomAPI_DataMapOfShapeShape& aMapOfShapes = *aPartitionAlgo->mapOfSubShapes().get();
+ std::shared_ptr<GeomAPI_Shape> aBaseShape = anObjects.front();
+ anObjects.pop_front();
+ aToolsForNaming.insert(aToolsForNaming.end(), anObjects.begin(), anObjects.end());
+ loadNamingDS(aResultBody, aBaseShape, aToolsForNaming, aPartitionAlgo->shape(), aMakeShapeList, aMapOfShapes);
+ setResult(aResultBody, aResultIndex);
+ aResultIndex++;
+ }
+ } else {
+ // Create result for each object.
+ for (ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) {
+ std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
+ ListOfShape aListWithObject; aListWithObject.push_back(anObject);
+ std::shared_ptr<GeomAlgoAPI_Partition> aPartitionAlgo(new GeomAlgoAPI_Partition(aListWithObject, aTools));
+
+ // Checking that the algorithm worked properly.
+ if (!aPartitionAlgo->isDone()) {
+ static const std::string aFeatureError = "Error: Partition algorithm failed.";
+ setError(aFeatureError);
+ return;
+ }
+ if (aPartitionAlgo->shape()->isNull()) {
+ static const std::string aShapeError = "Error: Resulting shape is Null.";
+ setError(aShapeError);
+ return;
+ }
+ if (!aPartitionAlgo->isValid()) {
+ std::string aFeatureError = "Error: Resulting shape is not valid.";
+ setError(aFeatureError);
+ return;
+ }
+
+ if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo->shape()) > 1.e-7) {
+ std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
+ GeomAlgoAPI_MakeShapeList aMakeShapeListCopy = aMakeShapeList;
+ aMakeShapeListCopy.appendAlgo(aPartitionAlgo);
+ GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo->mapOfSubShapes().get();
+ loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo->shape(), aMakeShapeListCopy, aMapOfShapes);
+ setResult(aResultBody, aResultIndex);
+ aResultIndex++;
+ }
+ }
+ }
+
+ // remove the rest results if there were produced in the previous pass
+ removeResults(aResultIndex);