X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VolumeTool.cxx;h=2148a15a52da5c147a2ab99a85f08513daefc240;hb=b88c2f1bf765500c9471890be4cc2ce309b5bb97;hp=f7857c3eb486e19b45656d8bcc51ad081bbeca1f;hpb=0003e6b4fcc95a0aec695ceef8371dee28baf417;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index f7857c3eb..2148a15a5 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 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 @@ -32,19 +32,17 @@ #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" -#include "SMDS_VtkVolume.hxx" #include "SMDS_Mesh.hxx" -#include "utilities.h" +#include #include #include #include +#include #include #include -using namespace std; - namespace { // ====================================================== @@ -361,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(); } + double* data() { return &x; } inline XYZ operator-( const XYZ& other ); inline XYZ operator+( const XYZ& other ); inline XYZ Crossed( const XYZ& other ); @@ -506,7 +505,7 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume, myNbFaces = theVolume->NbFaces(); if ( myVolume->IsPoly() ) { - myPolyedre = dynamic_cast( myVolume ); + myPolyedre = SMDS_Mesh::DownCast( myVolume ); myPolyFacetOri.resize( myNbFaces, 0 ); } @@ -522,10 +521,7 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume, } else { - int iNode = 0; - SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); - while ( nodeIt->more() ) - myVolumeNodes[ iNode++ ] = static_cast( nodeIt->next() ); + myVolumeNodes.assign( myVolume->begin_nodes(), myVolume->end_nodes() ); } // check validity @@ -714,6 +710,7 @@ double SMDS_VolumeTool::GetSize() const 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 ); @@ -724,7 +721,7 @@ double SMDS_VolumeTool::GetSize() const area = area + p1.Crossed( p2 ); p1 = p2; } - V += p1.Dot( area ); + V += ( p1 - origin ).Dot( area ); } V /= 6; } @@ -954,8 +951,8 @@ const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex ) const //purpose : Return a set of face nodes. //======================================================================= -bool SMDS_VolumeTool::GetFaceNodes (int faceIndex, - set& theFaceNodes ) const +bool SMDS_VolumeTool::GetFaceNodes (int faceIndex, + std::set& theFaceNodes ) const { if ( !setFace( faceIndex )) return false; @@ -1060,7 +1057,7 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) const { ori = ( -minProj < maxProj ? -1 : +1 ); double convexity = std::min( -minProj, maxProj ) / std::max( -minProj, maxProj ); - convexity2face.insert( make_pair( convexity, iF * ori )); + convexity2face.insert( std::make_pair( convexity, iF * ori )); } } if ( faceMostConvex < 0 ) // none facet has nodes on the same side @@ -1089,7 +1086,7 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) const // compare orientation of links of the facet with myFwdLinks ori = 0; setFace( faceIndex ); - vector< NLink > links( myCurFace.myNbNodes ), links2; + std::vector< NLink > links( myCurFace.myNbNodes ), links2; for ( int i = 0; i < myCurFace.myNbNodes && !ori; ++i ) { NLink link( myCurFace.myNodes[i], myCurFace.myNodes[i+1] ); @@ -1147,7 +1144,8 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) const bool SMDS_VolumeTool::projectNodesToNormal( int faceIndex, double& minProj, - double& maxProj ) const + double& maxProj, + double* normalXYZ ) const { minProj = std::numeric_limits::max(); maxProj = std::numeric_limits::min(); @@ -1155,6 +1153,9 @@ bool SMDS_VolumeTool::projectNodesToNormal( int faceIndex, 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 ) { @@ -1210,7 +1211,7 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub } double size = cross.Magnitude(); - if ( size <= numeric_limits::min() ) + if ( size <= std::numeric_limits::min() ) return false; X = cross.x / size; @@ -1382,7 +1383,7 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1, } else { d2 = 0; } - vector::const_iterator i; + std::vector::const_iterator i; for (int iface = 0; iface < myNbFaces; iface++) { from = to; @@ -1429,8 +1430,8 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]); } - int minInd = min( theNode1Index, theNode2Index ); - int maxInd = max( theNode1Index, theNode2Index ); + int minInd = std::min( theNode1Index, theNode2Index ); + int maxInd = std::max( theNode1Index, theNode2Index ); if ( minInd < 0 || maxInd > (int)myVolumeNodes.size() - 1 || maxInd == minInd ) return false; @@ -1565,7 +1566,7 @@ int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const */ //================================================================================ -int SMDS_VolumeTool::GetAllExistingFaces(vector & faces) const +int SMDS_VolumeTool::GetAllExistingFaces(std::vector & faces) const { faces.clear(); SaveFacet savedFacet( myCurFace ); @@ -1606,7 +1607,7 @@ int SMDS_VolumeTool::GetAllExistingFaces(vector & faces */ //================================================================================ -int SMDS_VolumeTool::GetAllExistingEdges(vector & edges) const +int SMDS_VolumeTool::GetAllExistingEdges(std::vector & edges) const { edges.clear(); edges.reserve( myVolumeNodes.size() * 2 ); @@ -1683,7 +1684,7 @@ double SMDS_VolumeTool::MaxLinearSize2() const //================================================================================ /*! - * \brief fast check that only one volume is build on the face nodes + * \brief Fast quickly check that only one volume is built on the face nodes * This check is valid for conformal meshes only */ //================================================================================ @@ -1717,7 +1718,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV // int nb = myCurFace.myNbNodes; // if ( myVolume->GetEntityType() != vol->GetEntityType() ) // nb -= ( GetCenterNodeIndex(0) > 0 ); - // set faceNodes( nodes, nodes + nb ); + // std::set faceNodes( nodes, nodes + nb ); // if ( SMDS_VolumeTool( vol ).GetFaceIndex( faceNodes ) < 0 ) // continue; // } @@ -1731,7 +1732,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV //================================================================================ /*! - * \brief Thorough check that only one volume is build on the face nodes + * \brief Thorough check that only one volume is built on the face nodes */ //================================================================================ @@ -1747,7 +1748,7 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth // evaluate nb of face nodes shared by other volumes int maxNbShared = -1; - typedef map< const SMDS_MeshElement*, int > TElemIntMap; + typedef std::map< const SMDS_MeshElement*, int > TElemIntMap; TElemIntMap volNbShared; TElemIntMap::iterator vNbIt; for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) { @@ -1756,7 +1757,7 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth while ( eIt->more() ) { const SMDS_MeshElement* elem = eIt->next(); if ( elem != myVolume ) { - vNbIt = volNbShared.insert( make_pair( elem, 0 )).first; + vNbIt = volNbShared.insert( std::make_pair( elem, 0 )).first; (*vNbIt).second++; if ( vNbIt->second > maxNbShared ) maxNbShared = vNbIt->second; @@ -1855,7 +1856,7 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth //purpose : Return index of a face formed by theFaceNodes //======================================================================= -int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodes, +int SMDS_VolumeTool::GetFaceIndex( const std::set& theFaceNodes, const int theFaceIndexHint ) const { if ( theFaceIndexHint >= 0 ) @@ -1898,12 +1899,12 @@ int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodes //purpose : Return index of a face formed by theFaceNodes //======================================================================= -/*int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodesIndices ) +/*int SMDS_VolumeTool::GetFaceIndex( const std::set& theFaceNodesIndices ) { for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { const int* nodes = GetFaceNodesIndices( iFace ); int nbFaceNodes = NbFaceNodes( iFace ); - set nodeSet; + std::set nodeSet; for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) nodeSet.insert( nodes[ iNode ] ); if ( theFaceNodesIndices == nodeSet ) @@ -1932,7 +1933,7 @@ bool SMDS_VolumeTool::setFace( int faceIndex ) const if (myVolume->IsPoly()) { - if (!myPolyedre) { + if ( !myPolyedre ) { MESSAGE("Warning: bad volumic element"); return false; }