X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FFeaturesPlugin%2FFeaturesPlugin_RemoveSubShapes.cpp;h=6a4bf9216791ddedee104354759b86adb747065b;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=84541fcd10f55d375a68ffb9e0b750e89f46f0da;hpb=a8cfbfb436c27ff96edd5c808e9a452c35cef207;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp index 84541fcd1..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,8 @@ void FeaturesPlugin_RemoveSubShapes::attributeChanged(const std::string& theID) aSubShapesAttrList->clear(); ResultPtr aContext = aShapeAttrSelection->context(); - ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast(aContext); + ResultCompSolidPtr aResultCompSolid = + std::dynamic_pointer_cast(aContext); if(!aResultCompSolid.get()) { return; } @@ -92,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); }