+ int aResultIndex = 0;
+
+ if (data()->version().empty()) {
+ // default behaviors of Partition
+ if(aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
+ for(GeomAPI_ShapeIterator anIt(aResultShape); anIt.more(); anIt.next()) {
+ storeResult(aBaseObjects, aPlanes, anIt.current(), aMakeShapeList, aResultIndex);
+ ++aResultIndex;
+ }
+ } else {
+ storeResult(aBaseObjects, aPlanes, aResultShape, aMakeShapeList, aResultIndex);
+ ++aResultIndex;
+ }
+ }
+ else {
+ // merge hierarchies of compounds containing objects and tools
+ GeomShapePtr aFirstShape = aResultShape;
+ GeomAPI_ShapeIterator anIt;
+ if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
+ anIt = GeomAPI_ShapeIterator(aResultShape);
+ aFirstShape = anIt.current();
+ anIt.next();
+ }
+
+ GeomShapePtr aResultCompound =
+ keepUnusedSubsOfCompound(aFirstShape, anObjects, GeomAPI_ShapeHierarchy(), aMakeShapeList);
+
+ if (anIt.more()) {
+ if (aResultCompound->shapeType() != GeomAPI_Shape::COMPOUND) {
+ // put the shape into compound
+ ListOfShape aShapes;
+ aShapes.push_back(aResultCompound);
+ aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+ }
+ std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
+ for (; anIt.more(); anIt.next())
+ aBuilder->add(aResultCompound, anIt.current());
+ aMakeShapeList->appendAlgo(aBuilder);
+ }
+
+ storeResult(aBaseObjects, aPlanes, aResultCompound, aMakeShapeList, aResultIndex);
+ ++aResultIndex;
+ }
+
+ // Remove the rest results if there were produced in the previous pass.
+ removeResults(aResultIndex);