{
}
+// returns a type of shape to expolode, but if toFind==SHAPE, it will return the type
+// of the first sub-element of compoud if theSHape is compound
+static TopAbs_ShapeEnum ShapeType(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const GeomAPI_Shape::ShapeType toFind)
+{
+ if (toFind == GeomAPI_Shape::SHAPE) {
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND) {
+ TopoDS_Iterator anIter(aShape);
+ if (anIter.More()) {
+ return anIter.Value().ShapeType();
+ }
+ }
+ }
+ return (TopAbs_ShapeEnum)toFind;
+}
+
//=================================================================================================
GeomAPI_ShapeExplorer::GeomAPI_ShapeExplorer(const std::shared_ptr<GeomAPI_Shape>& theShape,
const GeomAPI_Shape::ShapeType toFind,
const GeomAPI_Shape::ShapeType toAvoid)
: GeomAPI_Interface(new TopExp_Explorer(theShape->impl<TopoDS_Shape>(),
- (TopAbs_ShapeEnum)toFind,
+ ShapeType(theShape, toFind),
(TopAbs_ShapeEnum)toAvoid))
{
}
const GeomAPI_Shape::ShapeType toAvoid)
{
MY_EXPLORER->Init(theShape->impl<TopoDS_Shape>(),
- (TopAbs_ShapeEnum)toFind,
+ ShapeType(theShape, toFind),
(TopAbs_ShapeEnum)toAvoid);
}