From: azv Date: Mon, 6 May 2019 10:05:44 +0000 (+0300) Subject: Fix incorrect geometric selection of a compound, which is sub-shape of another compound. X-Git-Tag: VEDF2019Lot4~139^2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b1bd3e5f7e88bd6697356c34fc189d466903b3d4;p=modules%2Fshaper.git Fix incorrect geometric selection of a compound, which is sub-shape of another compound. --- diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 7036f5537..3b0709eac 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -390,12 +390,29 @@ GeomAPI_Shape::subShapes(ShapeType theSubShapeType) const 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; } diff --git a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp index e635ebf8b..16723a035 100644 --- a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp +++ b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp @@ -130,6 +130,19 @@ namespace ModelGeomAlgo_Shape 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(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); } @@ -138,13 +151,8 @@ namespace ModelGeomAlgo_Shape const std::list& theSubshape) { for (std::list::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,