- bool aValid = true;
- if (theShape.IsNull()) {
- aValid = true; // do not check the shape type if the shape is empty
- // extrusion uses a sketch object selectected in Object browser
+ bool aValid = false;
+
+ GeomShapePtr aShape = theShape;
+
+ QIntList aShapeTypes = getShapeTypes();
+ if (aShapeTypes.empty()) {
+ aValid = true;
+ return aValid;
+ }
+ // when the SHAPE type is provided by XML, the hole result shape can be selected.
+ if (!aShape.get() && aShapeTypes.contains(TopAbs_SHAPE)) {
+ aValid = true;
+ return aValid;
+ }
+
+ if (!aShape.get() && theResult.get()) {
+ if (theResult.get())
+ aShape = theResult->shape();
+ }
+ TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+ if (aShape.get()) {
+ // Check that the selection corresponds to selection type
+ TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+ aShapeType = aTopoShape.ShapeType();
+ // for compounds check sub-shapes: it may be compound of needed type:
+ // Booleans may produce compounds of Solids
+ if (aShapeType == TopAbs_COMPOUND) {
+ aShapeType = ModuleBase_Tools::getCompoundSubType(aTopoShape);
+ }