- GeomAPI_Shape::ShapeType aShapeType = aBaseShape->shapeType();
- if(aShapeType != GeomAPI_Shape::WIRE
- && aShapeType != GeomAPI_Shape::SHELL
- && aShapeType != GeomAPI_Shape::COMPSOLID
- && aShapeType != GeomAPI_Shape::COMPOUND) {
- return;
+ else if (theID == SUBSHAPES_TO_KEEP_ID())
+ {
+ aSubShapesToRemoveAttrList->clear();
+
+ if (!aBaseShape.get()) {
+ return;
+ }
+
+ int anIndex;
+ // optimization: collect selection attribute values into a map
+ const int aSubsToKeepNb = aSubShapesToKeepAttrList->size();
+ GeomAPI_DataMapOfShapeShape aSubShapesToKeep;
+ for(anIndex = 0; anIndex < aSubsToKeepNb; ++anIndex) {
+ AttributeSelectionPtr anAttrSelectionInList = aSubShapesToKeepAttrList->value(anIndex);
+ GeomShapePtr aSubShapeToKeep = anAttrSelectionInList->value();
+ if (aSubShapeToKeep.get())
+ aSubShapesToKeep.bind(aSubShapeToKeep, aSubShapeToKeep);
+ }
+
+ std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+ ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+ for (; anIt != aSubShapes.cend(); ++anIt)
+ {
+ GeomShapePtr aSubShape = *anIt;
+ if (aSubShapesToKeep.isBound(aSubShape))
+ continue;
+
+ if(!isHasSubs) {
+ aSubShapesToRemoveAttrList->append(aContext, aSubShape);
+ }
+ else {
+ std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
+ for (; aSubsIt != anAllSubs.end(); aSubsIt++) {
+ ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
+ if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
+ aSubShapesToRemoveAttrList->append(aSub, aSubShape);
+ break;
+ }
+ }
+ }
+ }