]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Dump with geometrical selection
authorazv <azv@opencascade.com>
Fri, 31 Aug 2018 05:48:37 +0000 (08:48 +0300)
committerazv <azv@opencascade.com>
Fri, 31 Aug 2018 05:48:37 +0000 (08:48 +0300)
Iteratively process compsolids within other compsolids

src/GeomAPI/GeomAPI_Shape.cpp
src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.cpp

index 369ad7ef128e41cdb5157ed0364b7c1110418b81..c4f30b6d321fb8aceee45910f7ce2f4cb0da47ee 100644 (file)
@@ -567,7 +567,7 @@ bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmi
   if (aShape.IsNull())
     return false;
   Bnd_Box aBndBox;
-  BRepBndLib::Add(aShape, aBndBox);
+  BRepBndLib::Add(aShape, aBndBox, false);
   if (aBndBox.IsVoid())
     return false;
   aBndBox.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
index a1c4af701c295b4a5dcbd546ff70c62d28676ed4..73266b8cf8024e63ff5a4f997f3a5622aa18b9c2 100644 (file)
@@ -148,6 +148,38 @@ namespace ModelGeomAlgo_Shape
     }
   }
 
+  static bool findSubshapeInCompsolid(const ResultBodyPtr& theCompsolid,
+                                      const std::shared_ptr<GeomAPI_Pnt>& thePoint,
+                                      const GeomAPI_Shape::ShapeType& theShapeType,
+                                      const double theTolerance,
+                                      std::list<SubshapeOfResult>& theSelected)
+  {
+    bool isSubshapeFound = false;
+    int aNbSolids = theCompsolid->numberOfSubs();
+    for (int i = 0; i < aNbSolids; ++i) {
+      ResultPtr aSubResult = theCompsolid->subResult(i);
+
+      // process subs of compsolid
+      ResultBodyPtr aSubCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aSubResult);
+      if (aSubCompSolid && aSubCompSolid->numberOfSubs() > 0) {
+        isSubshapeFound = findSubshapeInCompsolid(aSubCompSolid,
+            thePoint, theShapeType, theTolerance, theSelected);
+      }
+      else {
+        GeomShapePtr aSubSolid = aSubResult->shape();
+        if (aSubSolid && isPointWithinBB(thePoint, aSubSolid, theTolerance)) {
+          std::list<GeomShapePtr> aSubshapes =
+              findSubShape(aSubSolid, theShapeType, thePoint, theTolerance);
+          if (!aSubshapes.empty()) {
+            appendSubshapeOfResult(theSelected, aSubResult, aSubshapes);
+            isSubshapeFound = true;
+          }
+        }
+      }
+    }
+    return isSubshapeFound;
+  }
+
   bool findSubshapeByPoint(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                            const std::shared_ptr<GeomAPI_Pnt>& thePoint,
                            const GeomAPI_Shape::ShapeType& theShapeType,
@@ -173,20 +205,8 @@ namespace ModelGeomAlgo_Shape
       if (theShapeType != GeomAPI_Shape::COMPOUND || !aSketchEdges) {
         ResultBodyPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aResIt);
         if (aCompSolid) {
-          // process solids
-          int aNbSolids = aCompSolid->numberOfSubs();
-          for (int i = 0; i < aNbSolids; ++i) {
-            ResultPtr aSubResult = aCompSolid->subResult(i);
-            GeomShapePtr aSubSolid = aSubResult->shape();
-            if (aSubSolid && isPointWithinBB(thePoint, aSubSolid, TOLERANCE)) {
-              std::list<GeomShapePtr> aSubshapes =
-                  findSubShape(aSubSolid, theShapeType, thePoint, TOLERANCE);
-              if (!aSubshapes.empty()) {
-                appendSubshapeOfResult(theSelected, aSubResult, aSubshapes);
-                isSubshapeFound = true;
-              }
-            }
-          }
+          isSubshapeFound = findSubshapeInCompsolid(aCompSolid,
+              thePoint, theShapeType, TOLERANCE, theSelected);
         }
 
         if (!isSubshapeFound) {
index b4df71cc764b4abb3940a8e281651242182428a0..304a95b97e1b0c588d953123ee8f8c8c8414dec2 100644 (file)
@@ -1033,13 +1033,10 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
   FeaturePtr aSelectedFeature;
   if (isDumpByGeom) {
     ResultPtr aRes = theAttrSelect->context();
-    if (aRes)
+    FeaturePtr aFeature = theAttrSelect->contextFeature();
+    if (aRes && !aFeature)
       aSelectedFeature = ModelAPI_Feature::feature(aRes->data()->owner());
-    else
-      aSelectedFeature = theAttrSelect->contextFeature();
-
-    if (aSelectedFeature)
-      isDumpByGeom = aSelectedFeature->isInHistory();
+    isDumpByGeom = aSelectedFeature && aSelectedFeature->isInHistory();
   }
 
   myDumpBuffer << "\"" << aShape->shapeTypeStr();