X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_RemoveSubShapes.cpp;h=6a4bf9216791ddedee104354759b86adb747065b;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=e29d8558f59d40385e9958206919d2724e59bada;hpb=b60b14b88cd5b0973643f552b4f128cfe9bf2152;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp index e29d8558f..6a4bf9216 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp @@ -15,6 +15,7 @@ #include +#include #include #include @@ -45,7 +46,7 @@ void FeaturesPlugin_RemoveSubShapes::attributeChanged(const std::string& theID) aSubShapesAttrList->clear(); ResultPtr aContext = aShapeAttrSelection->context(); - ResultCompSolidPtr aResultCompSolid = + ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast(aContext); if(!aResultCompSolid.get()) { return; @@ -93,22 +94,40 @@ void FeaturesPlugin_RemoveSubShapes::execute() return; } - // Copy base shape. + // Get base shape. GeomShapePtr aBaseShape = aShapeAttrSelection->value(); - if(!aBaseShape.get()) { - return; - } - GeomShapePtr aResultShape = aBaseShape->emptyCopied(); - // 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(); } + GeomAlgoAPI_Copy aCopy(aResultShape); + aResultShape = aCopy.shape(); + // Store result. ResultBodyPtr aResultBody = document()->createBody(data()); - aResultBody->storeModified(aBaseShape, aResultShape); + aResultBody->storeModified(aBaseShape, aResultShape, 1); + aResultBody->loadAndOrientModifiedShapes(&aCopy, + aBaseShape, + GeomAPI_Shape::FACE, + 10000, + "Modified_Face", + *aCopy.mapOfSubShapes().get(), + true); setResult(aResultBody); }