From 7dad29749c7f1e3ccbc7c3fc061ecfaab80b3044 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 29 Dec 2006 14:27:54 +0000 Subject: [PATCH] NPAL14335 (EDF 344 SMESH : "ERROR : Iterator not implemented " when loading a script) add optional SMDSAbs_ElementType arg to GetInverseElementIterator() --- src/SMDS/SMDS_MeshNode.cxx | 20 ++++++++++++++++---- src/SMDS/SMDS_MeshNode.hxx | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 1d968dcbb..e4b551912 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -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 diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index 884e1280d..f2b0e003d 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -56,7 +56,7 @@ class SMDS_WNT_EXPORT SMDS_MeshNode:public SMDS_MeshElement void RemoveInverseElement(const SMDS_MeshElement * parent); void ClearInverseElements(); bool emptyInverseElements(); - SMDS_ElemIteratorPtr GetInverseElementIterator() const; + SMDS_ElemIteratorPtr GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const; void SetPosition(const SMDS_PositionPtr& aPos); const SMDS_PositionPtr& GetPosition() const; SMDSAbs_ElementType GetType() const;