From: mpv Date: Fri, 19 Apr 2019 07:43:38 +0000 (+0300) Subject: Fix for the issue #2914 : Wrong volume computed on ENISTAT X-Git-Tag: VEDF2019Lot4~151 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2878984da99dd40782dca1e259b4ae48c5bc595f;p=modules%2Fshaper.git Fix for the issue #2914 : Wrong volume computed on ENISTAT --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index 301717b15..357f79216 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -113,7 +113,6 @@ static GProp_GProps props(const TopoDS_Shape& theShape) //================================================================================================== double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr theShape) { - GProp_GProps aGProps; if(!theShape.get()) { return 0.0; } @@ -122,10 +121,19 @@ double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr theSh return 0.0; } const Standard_Real anEps = 1.e-6; - if (aShape.ShapeType() <= TopAbs_SOLID) - BRepGProp::VolumeProperties(aShape, aGProps, anEps); - else - BRepGProp::SurfaceProperties(aShape, aGProps, anEps); + TopExp_Explorer anExp(aShape, TopAbs_SOLID); + if (anExp.More()) { // return volume if there is at least one solid + double aVolume = 0.0; + for (; anExp.More(); anExp.Next()) { + GProp_GProps aGProps; + BRepGProp::VolumeProperties(anExp.Current(), aGProps, anEps); + aVolume += aGProps.Mass(); + } + return aVolume; + } + // return surfaces area + GProp_GProps aGProps; + BRepGProp::SurfaceProperties(aShape, aGProps, anEps); return aGProps.Mass(); }