From: azv Date: Fri, 31 Aug 2018 05:48:37 +0000 (+0300) Subject: Dump with geometrical selection X-Git-Tag: V9_2_0a1~79 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=69be57369aecc178f4eda88cfee33278925b8902;p=modules%2Fshaper.git Dump with geometrical selection Iteratively process compsolids within other compsolids --- diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 369ad7ef1..c4f30b6d3 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -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); diff --git a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp index a1c4af701..73266b8cf 100644 --- a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp +++ b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp @@ -148,6 +148,38 @@ namespace ModelGeomAlgo_Shape } } + static bool findSubshapeInCompsolid(const ResultBodyPtr& theCompsolid, + const std::shared_ptr& thePoint, + const GeomAPI_Shape::ShapeType& theShapeType, + const double theTolerance, + std::list& 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(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 aSubshapes = + findSubShape(aSubSolid, theShapeType, thePoint, theTolerance); + if (!aSubshapes.empty()) { + appendSubshapeOfResult(theSelected, aSubResult, aSubshapes); + isSubshapeFound = true; + } + } + } + } + return isSubshapeFound; + } + bool findSubshapeByPoint(const std::shared_ptr& theFeature, const std::shared_ptr& 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(*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 aSubshapes = - findSubShape(aSubSolid, theShapeType, thePoint, TOLERANCE); - if (!aSubshapes.empty()) { - appendSubshapeOfResult(theSelected, aSubResult, aSubshapes); - isSubshapeFound = true; - } - } - } + isSubshapeFound = findSubshapeInCompsolid(aCompSolid, + thePoint, theShapeType, TOLERANCE, theSelected); } if (!isSubshapeFound) { diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index b4df71cc7..304a95b97 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -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();