From 3e0873e7ffbfa17c1d211ae38bb1a7bda9d31595 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 18 Feb 2020 14:39:31 +0300 Subject: [PATCH] Fix regression of #17828: Polyhedron Mesh volume calculation --- src/SMDS/SMDS_VolumeTool.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index 21accdc9d..fbb4f8b00 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -708,19 +708,9 @@ double SMDS_VolumeTool::GetSize() const SaveFacet savedFacet( myCurFace ); - // get an origin not lying in plane of any facet - int faceIndex = std::max( myCurFace.myIndex, 0 ); - setFace( faceIndex ); - double minProj, maxProj; - XYZ normal, origin; - projectNodesToNormal( faceIndex, minProj, maxProj, normal.data()); - GetFaceBaryCenter( faceIndex, origin.x, origin.y, origin.z ); - origin.x += normal.x * ( maxProj - minProj ) * 1e-1; - origin.y += normal.y * ( maxProj - minProj ) * 1e-2; - origin.z += normal.z * ( maxProj - minProj ) * 1e-3; - // split a polyhedron into tetrahedrons + bool oriOk = true; SMDS_VolumeTool* me = const_cast< SMDS_VolumeTool* > ( this ); for ( int f = 0; f < NbFaces(); ++f ) { @@ -732,9 +722,12 @@ double SMDS_VolumeTool::GetSize() const area = area + p1.Crossed( p2 ); p1 = p2; } - V += ( p1 - origin ).Dot( area ); + V += p1.Dot( area ); + oriOk = oriOk && IsFaceExternal( f ); } V /= 6; + if ( !oriOk && V > 0 ) + V *= -1; } else { -- 2.39.2