X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshNode.cxx;h=587aee90a86284144296f898755b476f326607d5;hb=aa6cf88a1bf90d4e8ceb4db0b7eb3f13f7d320a6;hp=06ab12173d871505c7ab482c4937e6796ea01b2c;hpb=090aff07266d376ae028ae43434bdea7c0a0f9bb;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 06ab12173..587aee90a 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com #ifdef _MSC_VER #pragma warning(disable:4786) @@ -88,16 +88,28 @@ const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const return myPosition; } +//======================================================================= +/*! + * \brief Iterator on list of elements + */ +//======================================================================= + class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator { NCollection_List::Iterator myIterator; + SMDSAbs_ElementType myType; public: - SMDS_MeshNode_MyInvIterator(const NCollection_List& s): - myIterator(s) + SMDS_MeshNode_MyInvIterator(const NCollection_List& s, + SMDSAbs_ElementType type): + myIterator(s), myType(type) {} bool more() { + if ( myType != SMDSAbs_All ) { + while ( myIterator.More() && myIterator.Value()->GetType() != myType) + myIterator.Next(); + } return myIterator.More() != Standard_False; } @@ -110,9 +122,9 @@ class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator }; SMDS_ElemIteratorPtr SMDS_MeshNode:: - GetInverseElementIterator() const + GetInverseElementIterator(SMDSAbs_ElementType type) const { - return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(myInverseElements)); + return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(myInverseElements,type)); } // Same as GetInverseElementIterator but the create iterator only return @@ -228,6 +240,24 @@ bool SMDS_MeshNode::emptyInverseElements() return myInverseElements.IsEmpty() != Standard_False; } +//================================================================================ +/*! + * \brief Count inverse elements of given type + */ +//================================================================================ + +int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const +{ + if ( type == SMDSAbs_All ) + return myInverseElements.Extent(); + int nb = 0; + NCollection_List::Iterator it( myInverseElements ); + for ( ; it.More(); it.Next() ) + if ( it.Value()->GetType() == type ) + nb++; + return nb; +} + /////////////////////////////////////////////////////////////////////////////// /// To be used with STL set ///////////////////////////////////////////////////////////////////////////////