From 2878984da99dd40782dca1e259b4ae48c5bc595f Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 19 Apr 2019 10:43:38 +0300 Subject: [PATCH] Fix for the issue #2914 : Wrong volume computed on ENISTAT --- src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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(); } -- 2.39.2