X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VolumeTool.cxx;h=9e144a620aaae174eef73eaa48e66d836edb02bd;hb=eda06d81d6e5947fa63a55261bab6c407ee02ed4;hp=c0c506d9cc13ba79e607cbf392d6f612bd1cd4e2;hpb=7a65c9fad427b1ccba6b9ccae612296e5092a324;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index c0c506d9c..9e144a620 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -425,11 +425,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 +471,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; @@ -508,11 +511,22 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume, } // 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 + { + int iNode = 0; + SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); + while ( nodeIt->more() ) + myVolumeNodes[ iNode++ ] = static_cast( nodeIt->next() ); + } // check validity if ( !setFace(0) ) @@ -843,7 +857,7 @@ bool SMDS_VolumeTool::GetBaryCenter(double & X, double & Y, double & Z) const if ( !myVolume ) return false; - for ( int i = 0; i < myVolumeNodes.size(); i++ ) { + for ( size_t i = 0; i < myVolumeNodes.size(); i++ ) { X += myVolumeNodes[ i ]->X(); Y += myVolumeNodes[ i ]->Y(); Z += myVolumeNodes[ i ]->Z(); @@ -1390,7 +1404,7 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1, // find nodes indices int i1 = -1, i2 = -1, nbFound = 0; - for ( int i = 0; i < myVolumeNodes.size() && nbFound < 2; i++ ) + for ( size_t i = 0; i < myVolumeNodes.size() && nbFound < 2; i++ ) { if ( myVolumeNodes[ i ] == theNode1 ) i1 = i, ++nbFound; @@ -1418,7 +1432,7 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, int minInd = min( theNode1Index, theNode2Index ); int maxInd = max( theNode1Index, theNode2Index ); - if ( minInd < 0 || maxInd > myVolumeNodes.size() - 1 || maxInd == minInd ) + if ( minInd < 0 || maxInd > (int)myVolumeNodes.size() - 1 || maxInd == minInd ) return false; VolumeType type = GetVolumeType(); @@ -1535,7 +1549,7 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index, int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const { if ( myVolume ) { - for ( int i = 0; i < myVolumeNodes.size(); i++ ) { + for ( size_t i = 0; i < myVolumeNodes.size(); i++ ) { if ( myVolumeNodes[ i ] == theNode ) return i; } @@ -1596,8 +1610,8 @@ int SMDS_VolumeTool::GetAllExistingEdges(vector & edges { edges.clear(); edges.reserve( myVolumeNodes.size() * 2 ); - for ( int i = 0; i < myVolumeNodes.size()-1; ++i ) { - for ( int j = i + 1; j < myVolumeNodes.size(); ++j ) { + for ( size_t i = 0; i < myVolumeNodes.size()-1; ++i ) { + for ( size_t j = i + 1; j < myVolumeNodes.size(); ++j ) { if ( IsLinked( i, j )) { const SMDS_MeshElement* edge = SMDS_Mesh::FindEdge( myVolumeNodes[i], myVolumeNodes[j] ); @@ -1669,7 +1683,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 +1731,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 */ //================================================================================