X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VolumeTool.cxx;h=582af506b9b4cf1b5b4db29d7a5de2a45be8551b;hb=1fb3ff621ac19da15742a5e8b9253b594977d14a;hp=dca32c2580a6ff6ecb91d4724797cb3325c546ae;hpb=a17b36970bc61da1d664453c615754997c925b18;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index dca32c258..582af506b 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,10 +32,9 @@ #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" -#include "SMDS_VtkVolume.hxx" #include "SMDS_Mesh.hxx" -#include "utilities.h" +#include #include #include @@ -43,8 +42,6 @@ #include #include -using namespace std; - namespace { // ====================================================== @@ -425,11 +422,13 @@ struct SMDS_VolumeTool::SaveFacet SaveFacet( SMDS_VolumeTool::Facet& facet ): myToRestore( facet ) { mySaved = facet; + mySaved.myNodes.swap( facet.myNodes ); } ~SaveFacet() { if ( myToRestore.myIndex != mySaved.myIndex ) myToRestore = mySaved; + myToRestore.myNodes.swap( mySaved.myNodes ); } }; @@ -469,8 +468,9 @@ SMDS_VolumeTool::~SMDS_VolumeTool() //purpose : Set volume to iterate on //======================================================================= -bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume, - const bool ignoreCentralNodes) +bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume, + const bool ignoreCentralNodes, + const std::vector* otherNodes) { // reset fields myVolume = 0; @@ -503,16 +503,24 @@ 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 ); } // set nodes - int iNode = 0; myVolumeNodes.resize( myVolume->NbNodes() ); - SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); - while ( nodeIt->more() ) - myVolumeNodes[ iNode++ ] = static_cast( nodeIt->next() ); + if ( otherNodes ) + { + if ( otherNodes->size() != myVolumeNodes.size() ) + return ( myVolume = 0 ); + for ( size_t i = 0; i < otherNodes->size(); ++i ) + if ( ! ( myVolumeNodes[i] = (*otherNodes)[0] )) + return ( myVolume = 0 ); + } + else + { + myVolumeNodes.assign( myVolume->begin_nodes(), myVolume->end_nodes() ); + } // check validity if ( !setFace(0) ) @@ -940,8 +948,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; @@ -1046,7 +1054,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 @@ -1075,7 +1083,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] ); @@ -1196,7 +1204,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; @@ -1368,7 +1376,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; @@ -1415,8 +1423,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; @@ -1551,7 +1559,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 ); @@ -1592,7 +1600,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 ); @@ -1669,7 +1677,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 */ //================================================================================ @@ -1703,7 +1711,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; // } @@ -1717,7 +1725,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 */ //================================================================================ @@ -1733,7 +1741,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++ ) { @@ -1742,7 +1750,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; @@ -1841,7 +1849,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 ) @@ -1884,12 +1892,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 ) @@ -1918,7 +1926,7 @@ bool SMDS_VolumeTool::setFace( int faceIndex ) const if (myVolume->IsPoly()) { - if (!myPolyedre) { + if ( !myPolyedre ) { MESSAGE("Warning: bad volumic element"); return false; }