- // Copy sub-shapes from list to new shape.
- for(int anIndex = 0; anIndex < aSubShapesAttrList->size(); ++anIndex) {
- AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
- GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
- GeomAlgoAPI_ShapeBuilder::add(aResultShape, aShapeToAdd);
+ GeomShapePtr aResultShape;
+ int aSubsNb = aSubShapesAttrList->size();
+ if(aSubsNb > 1) {
+ if(!aBaseShape.get()) {
+ return;
+ }
+ aResultShape = aBaseShape->emptyCopied();
+
+ // Copy sub-shapes from list to new shape.
+ for(int anIndex = 0; anIndex < aSubsNb; ++anIndex) {
+ AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
+ GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
+ GeomAlgoAPI_ShapeBuilder::add(aResultShape, aShapeToAdd);
+ }
+ } else if(aSubsNb == 1) {
+ AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(0);
+ aResultShape = anAttrSelectionInList->value();