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;
}
aSR.myResult = theResult;
aSR.mySubshape = theSubshape;
aSR.myCenterType = theCenterType;
+ // compound subshapes from other compounds should be processed as whole results
+ if (aSR.mySubshape->shapeType() == GeomAPI_Shape::COMPOUND &&
+ !theResult->shape()->isEqual(theSubshape)) {
+ ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+ for (int i = 0; aResult && i < aResult->numberOfSubs(); ++i) {
+ ResultBodyPtr aSub = aResult->subResult(i);
+ if (aSub->shape()->isEqual(theSubshape)) {
+ aSR.myResult = aSub;
+ aSR.mySubshape = GeomShapePtr();
+ break;
+ }
+ }
+ }
theList.push_back(aSR);
}
const std::list<GeomShapePtr>& theSubshape)
{
for (std::list<GeomShapePtr>::const_iterator anIt = theSubshape.begin();
- anIt != theSubshape.end(); ++anIt) {
- SubshapeOfResult aSR;
- aSR.myResult = theResult;
- aSR.mySubshape = *anIt;
- aSR.myCenterType = (int)ModelAPI_AttributeSelection::NOT_CENTER;
- theList.push_back(aSR);
- }
+ anIt != theSubshape.end(); ++anIt)
+ appendSubshapeOfResult(theList, theResult, *anIt);
}
static bool findSubshapeInCompsolid(const ResultBodyPtr& theCompsolid,