X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VolumeTool.cxx;h=bd207f84ef6d9ddad4fafa3207c4ec579bc45788;hp=2148a15a52da5c147a2ab99a85f08513daefc240;hb=499f29d24922cec66e41b41a0039a954993bc6df;hpb=b88c2f1bf765500c9471890be4cc2ce309b5bb97 diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index 2148a15a5..bd207f84e 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 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 @@ -706,11 +706,12 @@ double SMDS_VolumeTool::GetSize() const if ( !myPolyedre ) return 0.; + SaveFacet savedFacet( myCurFace ); + // split a polyhedron into tetrahedrons - SaveFacet savedFacet( myCurFace ); + bool oriOk = true; 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 ); @@ -721,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 { @@ -965,7 +969,7 @@ bool SMDS_VolumeTool::GetFaceNodes (int faceIndex, namespace { - struct NLink : public std::pair + struct NLink : public std::pair { int myOri; NLink(const SMDS_MeshNode* n1=0, const SMDS_MeshNode* n2=0, int ori=1 ) @@ -1203,11 +1207,13 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub XYZ aVec13( p3 - p1 ); XYZ cross = aVec12.Crossed( aVec13 ); - if ( myCurFace.myNbNodes >3*iQuad ) { - XYZ p4 ( myCurFace.myNodes[3*iQuad] ); + for ( int i = 3*iQuad; i < myCurFace.myNbNodes; i += iQuad ) + { + XYZ p4 ( myCurFace.myNodes[i] ); XYZ aVec14( p4 - p1 ); XYZ cross2 = aVec13.Crossed( aVec14 ); cross = cross + cross2; + aVec13 = aVec14; } double size = cross.Magnitude(); @@ -1322,7 +1328,7 @@ int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const case 15: if ( faceIndex == 0 || faceIndex == 1 ) ind = 1 - faceIndex; - break; + break; case 8: case 12: if ( faceIndex <= 1 ) // top or bottom @@ -1482,10 +1488,10 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, case QUAD_TETRA: { switch ( minInd ) { - case 0: if( maxInd==4 || maxInd==6 || maxInd==7 ) return true; - case 1: if( maxInd==4 || maxInd==5 || maxInd==8 ) return true; - case 2: if( maxInd==5 || maxInd==6 || maxInd==9 ) return true; - case 3: if( maxInd==7 || maxInd==8 || maxInd==9 ) return true; + case 0: return ( maxInd==4 || maxInd==6 || maxInd==7 ); + case 1: return ( maxInd==4 || maxInd==5 || maxInd==8 ); + case 2: return ( maxInd==5 || maxInd==6 || maxInd==9 ); + case 3: return ( maxInd==7 || maxInd==8 || maxInd==9 ); default:; } break; @@ -1493,14 +1499,14 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, case QUAD_HEXA: { switch ( minInd ) { - case 0: if( maxInd==8 || maxInd==11 || maxInd==16 ) return true; - case 1: if( maxInd==8 || maxInd==9 || maxInd==17 ) return true; - case 2: if( maxInd==9 || maxInd==10 || maxInd==18 ) return true; - case 3: if( maxInd==10 || maxInd==11 || maxInd==19 ) return true; - case 4: if( maxInd==12 || maxInd==15 || maxInd==16 ) return true; - case 5: if( maxInd==12 || maxInd==13 || maxInd==17 ) return true; - case 6: if( maxInd==13 || maxInd==14 || maxInd==18 ) return true; - case 7: if( maxInd==14 || maxInd==15 || maxInd==19 ) return true; + case 0: return ( maxInd==8 || maxInd==11 || maxInd==16 ); + case 1: return ( maxInd==8 || maxInd==9 || maxInd==17 ); + case 2: return ( maxInd==9 || maxInd==10 || maxInd==18 ); + case 3: return ( maxInd==10 || maxInd==11 || maxInd==19 ); + case 4: return ( maxInd==12 || maxInd==15 || maxInd==16 ); + case 5: return ( maxInd==12 || maxInd==13 || maxInd==17 ); + case 6: return ( maxInd==13 || maxInd==14 || maxInd==18 ); + case 7: return ( maxInd==14 || maxInd==15 || maxInd==19 ); default:; } break; @@ -1508,11 +1514,11 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, case QUAD_PYRAM: { switch ( minInd ) { - case 0: if( maxInd==5 || maxInd==8 || maxInd==9 ) return true; - case 1: if( maxInd==5 || maxInd==6 || maxInd==10 ) return true; - case 2: if( maxInd==6 || maxInd==7 || maxInd==11 ) return true; - case 3: if( maxInd==7 || maxInd==8 || maxInd==12 ) return true; - case 4: if( maxInd==9 || maxInd==10 || maxInd==11 || maxInd==12 ) return true; + case 0: return ( maxInd==5 || maxInd==8 || maxInd==9 ); + case 1: return ( maxInd==5 || maxInd==6 || maxInd==10 ); + case 2: return ( maxInd==6 || maxInd==7 || maxInd==11 ); + case 3: return ( maxInd==7 || maxInd==8 || maxInd==12 ); + case 4: return ( maxInd==9 || maxInd==10 || maxInd==11 || maxInd==12 ); default:; } break; @@ -1520,12 +1526,12 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, case QUAD_PENTA: { switch ( minInd ) { - case 0: if( maxInd==6 || maxInd==8 || maxInd==12 ) return true; - case 1: if( maxInd==6 || maxInd==7 || maxInd==13 ) return true; - case 2: if( maxInd==7 || maxInd==8 || maxInd==14 ) return true; - case 3: if( maxInd==9 || maxInd==11 || maxInd==12 ) return true; - case 4: if( maxInd==9 || maxInd==10 || maxInd==13 ) return true; - case 5: if( maxInd==10 || maxInd==11 || maxInd==14 ) return true; + case 0: return ( maxInd==6 || maxInd==8 || maxInd==12 ); + case 1: return ( maxInd==6 || maxInd==7 || maxInd==13 ); + case 2: return ( maxInd==7 || maxInd==8 || maxInd==14 ); + case 3: return ( maxInd==9 || maxInd==11 || maxInd==12 ); + case 4: return ( maxInd==9 || maxInd==10 || maxInd==13 ); + case 5: return ( maxInd==10 || maxInd==11 || maxInd==14 ); default:; } break; @@ -2204,7 +2210,7 @@ const SMDS_MeshVolume* SMDS_VolumeTool::Element() const //purpose : return element ID //======================================================================= -int SMDS_VolumeTool::ID() const +smIdType SMDS_VolumeTool::ID() const { return myVolume ? myVolume->GetID() : 0; }