Salome HOME
Make SHAPER STUDY fields exported in SMESH into MED file
[modules/shaper.git] / src / ModelGeomAlgo / ModelGeomAlgo_Shape.cpp
index 73266b8cf8024e63ff5a4f997f3a5622aa18b9c2..2f81c1f3891aae552165d7a04672495d5f0ba7d4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <GeomAPI_Shape.h>
@@ -85,7 +84,7 @@ namespace ModelGeomAlgo_Shape
     return aFoundSubs;
   }
 
-  // Find circular/elliptical edge, which center/focus coincide with the given point
+  // Find circular/elliptic edge, which center/focus coincide with the given point
   static GeomShapePtr findEdgeByCenter(const GeomShapePtr& theBaseShape,
                                        const GeomPointPtr& theCenter,
                                        const double theTolerance,
@@ -131,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 && 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);
   }
 
@@ -139,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,
@@ -161,7 +168,8 @@ namespace ModelGeomAlgo_Shape
 
       // process subs of compsolid
       ResultBodyPtr aSubCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aSubResult);
-      if (aSubCompSolid && aSubCompSolid->numberOfSubs() > 0) {
+      if (theShapeType != GeomAPI_Shape::COMPSOLID &&
+          aSubCompSolid && aSubCompSolid->numberOfSubs() > 0) {
         isSubshapeFound = findSubshapeInCompsolid(aSubCompSolid,
             thePoint, theShapeType, theTolerance, theSelected);
       }