Salome HOME
Fix regression of #17828: Polyhedron Mesh volume calculation
authoreap <eap@opencascade.com>
Tue, 18 Feb 2020 11:39:31 +0000 (14:39 +0300)
committereap <eap@opencascade.com>
Tue, 18 Feb 2020 11:39:31 +0000 (14:39 +0300)
src/SMDS/SMDS_VolumeTool.cxx

index 21accdc9da2d9f4dbe4ef2af020b3992526e26ee..fbb4f8b00e9b4f6bf972803c47bd31665488d98f 100644 (file)
@@ -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 
   {