From: dbv Date: Mon, 5 Dec 2016 15:43:20 +0000 (+0300) Subject: Issue #1916: Fatal error when create sketch on body Remove subshapes X-Git-Tag: V_2.6.0~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ebc5236aba00c21e854d6705d1cbbc6599e1bf36;p=modules%2Fshaper.git Issue #1916: Fatal error when create sketch on body Remove subshapes Fixed --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp index 222880d87..7279cf446 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp @@ -15,6 +15,7 @@ #include +#include #include #include @@ -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; + } + GeomShapePtr 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); }