#include<GeomAPI_Shape.h>
#include <TopoDS_Shape.hxx>
+#include <TopoDS_Iterator.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <BRepTools.hxx>
return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND;
}
+bool GeomAPI_Shape::isCompoundOfSolids() const
+{
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ if (aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND)
+ return false;
+ bool isAtLeastOne = false;
+ for(TopoDS_Iterator aSubs(aShape); aSubs.More(); aSubs.Next()) {
+ if (aSubs.Value().IsNull() || aSubs.Value().ShapeType() != TopAbs_SOLID)
+ return false;
+ isAtLeastOne = true;
+ }
+ return isAtLeastOne;
+}
+
bool GeomAPI_Shape::isSolid() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
/// Returns whether the shape is a face
virtual bool isFace() const;
- /// Returns whether the shape is a face
+ /// Returns whether the shape is a compound
virtual bool isCompound() const;
+ /// Returns whether the shape is a compound of solids
+ virtual bool isCompoundOfSolids() const;
+
/// Returns whether the shape is a solid
virtual bool isSolid() const;
aValid = theShape->isVertex();
break;
case Solid:
- aValid = theShape->isSolid();
+ aValid = theShape->isSolid() || theShape->isCompoundOfSolids();
break;
case Face:
aValid = theShape->isFace();
updateFocus();
}
+#include <TopoDS_Iterator.hxx>
+
//********************************************************************
bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
const ResultPtr& theResult) const
// 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) {
+ for(TopoDS_Iterator aSubs(aTopoShape); aSubs.More(); aSubs.Next()) {
+ if (!aSubs.Value().IsNull()) {
+ TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
+ if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
+ aShapeType = TopAbs_COMPOUND;
+ break;
+ }
+ if (aShapeType == TopAbs_COMPOUND) {
+ aShapeType = aSubType;
+ } else if (aShapeType != aSubType) { // compound of shapes of different types
+ aShapeType = TopAbs_COMPOUND;
+ break;
+ }
+ }
+ }
+ }
}
QIntList aShapeTypes = getShapeTypes();