Salome HOME
projects
/
modules
/
smesh.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
#17828 [CEA 17805] Polyhedron Mesh volume calculation and volume orientation criterion
[modules/smesh.git]
/
src
/
SMDS
/
SMDS_VolumeTool.cxx
diff --git
a/src/SMDS/SMDS_VolumeTool.cxx
b/src/SMDS/SMDS_VolumeTool.cxx
index 6de1ac68e4efc8fed87c1b479ba58b5e261ec452..2148a15a52da5c147a2ab99a85f08513daefc240 100644
(file)
--- a/
src/SMDS/SMDS_VolumeTool.cxx
+++ b/
src/SMDS/SMDS_VolumeTool.cxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2007-201
6
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-201
9
CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-39,6
+39,7
@@
#include <map>
#include <limits>
#include <cmath>
#include <map>
#include <limits>
#include <cmath>
+#include <cstring>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <algorithm>
@@
-358,6
+359,7
@@
struct XYZ {
XYZ( double X, double Y, double Z ) { x = X; y = Y; z = Z; }
XYZ( const XYZ& other ) { x = other.x; y = other.y; z = other.z; }
XYZ( const SMDS_MeshNode* n ) { x = n->X(); y = n->Y(); z = n->Z(); }
XYZ( double X, double Y, double Z ) { x = X; y = Y; z = Z; }
XYZ( const XYZ& other ) { x = other.x; y = other.y; z = other.z; }
XYZ( const SMDS_MeshNode* n ) { x = n->X(); y = n->Y(); z = n->Z(); }
+ double* data() { return &x; }
inline XYZ operator-( const XYZ& other );
inline XYZ operator+( const XYZ& other );
inline XYZ Crossed( const XYZ& other );
inline XYZ operator-( const XYZ& other );
inline XYZ operator+( const XYZ& other );
inline XYZ Crossed( const XYZ& other );
@@
-708,6
+710,7
@@
double SMDS_VolumeTool::GetSize() const
SaveFacet savedFacet( myCurFace );
SMDS_VolumeTool* me = const_cast< SMDS_VolumeTool* > ( this );
SaveFacet savedFacet( myCurFace );
SMDS_VolumeTool* me = const_cast< SMDS_VolumeTool* > ( this );
+ XYZ origin( 1 + 1e-6, 22 + 2e-6, 333 + 3e-6 ); // for invalid poly: avoid lying on a facet plane
for ( int f = 0; f < NbFaces(); ++f )
{
me->setFace( f );
for ( int f = 0; f < NbFaces(); ++f )
{
me->setFace( f );
@@
-718,7
+721,7
@@
double SMDS_VolumeTool::GetSize() const
area = area + p1.Crossed( p2 );
p1 = p2;
}
area = area + p1.Crossed( p2 );
p1 = p2;
}
- V +=
p1
.Dot( area );
+ V +=
( p1 - origin )
.Dot( area );
}
V /= 6;
}
}
V /= 6;
}
@@
-1141,7
+1144,8
@@
bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) const
bool SMDS_VolumeTool::projectNodesToNormal( int faceIndex,
double& minProj,
bool SMDS_VolumeTool::projectNodesToNormal( int faceIndex,
double& minProj,
- double& maxProj ) const
+ double& maxProj,
+ double* normalXYZ ) const
{
minProj = std::numeric_limits<double>::max();
maxProj = std::numeric_limits<double>::min();
{
minProj = std::numeric_limits<double>::max();
maxProj = std::numeric_limits<double>::min();
@@
-1149,6
+1153,9
@@
bool SMDS_VolumeTool::projectNodesToNormal( int faceIndex,
XYZ normal;
if ( !GetFaceNormal( faceIndex, normal.x, normal.y, normal.z ))
return false;
XYZ normal;
if ( !GetFaceNormal( faceIndex, normal.x, normal.y, normal.z ))
return false;
+ if ( normalXYZ )
+ memcpy( normalXYZ, normal.data(), 3*sizeof(double));
+
XYZ p0 ( myCurFace.myNodes[0] );
for ( size_t i = 0; i < myVolumeNodes.size(); ++i )
{
XYZ p0 ( myCurFace.myNodes[0] );
for ( size_t i = 0; i < myVolumeNodes.size(); ++i )
{