]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix incorrect geometric selection of a compound, which is sub-shape of another compound.
authorazv <azv@opencascade.com>
Mon, 6 May 2019 10:05:44 +0000 (13:05 +0300)
committervsv <vsv@opencascade.com>
Mon, 3 Jun 2019 10:32:02 +0000 (13:32 +0300)
src/GeomAPI/GeomAPI_Shape.cpp
src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp

index 7036f55378ede29acbbcf26dc3c9ae31e06c9320..3b0709eac3e91cd144dc81583b24ab0e6f947fe6 100644 (file)
@@ -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;
 }
 
index e635ebf8b957291ea8fb397f9975fe20c4240789..16723a035f99a7d578cdc981d78feee15031fc49 100644 (file)
@@ -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<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);
   }
 
@@ -138,13 +151,8 @@ namespace ModelGeomAlgo_Shape
       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,