if (aShape.IsNull())
return aSubs;
- for (TopExp_Explorer anExp(aShape, (TopAbs_ShapeEnum)theSubShapeType);
- anExp.More(); anExp.Next()) {
+ // process multi-level compounds
+ if (shapeType() == COMPOUND && theSubShapeType == COMPOUND) {
+ for (TopoDS_Iterator anIt(aShape); anIt.More(); anIt.Next()) {
+ const TopoDS_Shape& aCurrent = anIt.Value();
+ if (aCurrent.ShapeType() == TopAbs_COMPOUND) {
+ GeomShapePtr aSub(new GeomAPI_Shape);
+ aSub->setImpl(new TopoDS_Shape(aCurrent));
+ aSubs.push_back(aSub);
+ }
+ }
+ // add self
GeomShapePtr aSub(new GeomAPI_Shape);
- aSub->setImpl(new TopoDS_Shape(anExp.Current()));
+ aSub->setImpl(new TopoDS_Shape(aShape));
aSubs.push_back(aSub);
}
+ else {
+ for (TopExp_Explorer anExp(aShape, (TopAbs_ShapeEnum)theSubShapeType);
+ anExp.More(); anExp.Next()) {
+ GeomShapePtr aSub(new GeomAPI_Shape);
+ aSub->setImpl(new TopoDS_Shape(anExp.Current()));
+ aSubs.push_back(aSub);
+ }
+ }
return aSubs;
}
GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeTypeByStr(std::string theType)
{
std::transform(theType.begin(), theType.end(), theType.begin(), ::toupper);
- if (theType == "COMPOUND")
+ if (theType == "COMPOUND" || theType == "COMPOUNDS")
return COMPOUND;
- if (theType == "COMPSOLID")
+ if (theType == "COMPSOLID" || theType == "COMPSOLIDS")
return COMPSOLID;
- if (theType == "SOLID")
+ if (theType == "SOLID" || theType == "SOLIDS")
return SOLID;
- if (theType == "SHELL")
+ if (theType == "SHELL" || theType == "SHELLS")
return SHELL;
- if (theType == "FACE")
+ if (theType == "FACE" || theType == "FACES")
return FACE;
- if (theType == "WIRE")
+ if (theType == "WIRE" || theType == "WIRES")
return WIRE;
- if (theType == "EDGE")
+ if (theType == "EDGE" || theType == "EDGES")
return EDGE;
- if (theType == "VERTEX")
+ if (theType == "VERTEX" || theType == "VERTICES")
return VERTEX;
return SHAPE; // default
}