]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
- virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
authoreap <eap@opencascade.com>
Thu, 16 May 2013 16:08:00 +0000 (16:08 +0000)
committereap <eap@opencascade.com>
Thu, 16 May 2013 16:08:00 +0000 (16:08 +0000)
+  virtual SMDS_NodeIteratorPtr nodeIterator() const;
+  virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
+  virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;

src/SMDS/SMDS_MeshElement.cxx
src/SMDS/SMDS_MeshElement.hxx

index b3478e3f553dc56c7f51cfea40256c899fe4b020..708f5c1a8845e2ac32ea5e750182da6c0a9c282c 100644 (file)
@@ -161,34 +161,69 @@ class SMDS_MeshElement_MyIterator:public SMDS_ElemIterator
   }     
 };
 
-SMDS_ElemIteratorPtr SMDS_MeshElement::
-        elementsIterator(SMDSAbs_ElementType type) const
+SMDS_ElemIteratorPtr
+SMDS_MeshElement::elementsIterator(SMDSAbs_ElementType type) const
 {
-        /** @todo Check that iterator in the child classes return elements
-        in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
-        and SMDS_VolumeOfFaces */
-        
-        if(type==GetType())
-          return SMDS_ElemIteratorPtr(new SMDS_MeshElement_MyIterator(this));
-        else 
-        {
-          MESSAGE("Iterator not implemented");
-          return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
-        }
+  /** @todo Check that iterator in the child classes return elements
+      in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
+      and SMDS_VolumeOfFaces */
+  if(type==GetType())
+    return SMDS_ElemIteratorPtr(new SMDS_MeshElement_MyIterator(this));
+  else
+  {
+    MESSAGE("Iterator not implemented");
+    return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
+  }
 }
 
 //! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
-SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIteratorToUNV() const
+SMDS_NodeIteratorPtr SMDS_MeshElement::nodesIteratorToUNV() const
 {
-  MESSAGE("Iterator not implemented");
-  return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
+  return nodeIterator();
 }
 
 //! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
+SMDS_NodeIteratorPtr SMDS_MeshElement::interlacedNodesIterator() const
+{
+  return nodeIterator();
+}
+
+namespace
+{
+  //=======================================================================
+  //class : _MyNodeIteratorFromElemIterator
+  //=======================================================================
+  class _MyNodeIteratorFromElemIterator : public SMDS_NodeIterator
+  {
+    SMDS_ElemIteratorPtr myItr;
+  public:
+    _MyNodeIteratorFromElemIterator(SMDS_ElemIteratorPtr elemItr):myItr( elemItr ) {}
+    bool                 more() { return myItr->more(); }
+    const SMDS_MeshNode* next() { return static_cast< const SMDS_MeshNode*>( myItr->next() ); }
+  };
+  //=======================================================================
+  //class : _MyElemIteratorFromNodeIterator
+  //=======================================================================
+  class _MyElemIteratorFromNodeIterator : public SMDS_ElemIterator
+  {
+    SMDS_NodeIteratorPtr myItr;
+  public:
+    _MyElemIteratorFromNodeIterator(SMDS_NodeIteratorPtr nodeItr): myItr( nodeItr ) {}
+    bool more()                    { return myItr->more(); }
+    const SMDS_MeshElement* next() { return myItr->next(); }
+  };
+}
+
 SMDS_ElemIteratorPtr SMDS_MeshElement::interlacedNodesElemIterator() const
 {
-  MESSAGE("Iterator not implemented");
-  return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
+  return SMDS_ElemIteratorPtr
+    ( new _MyElemIteratorFromNodeIterator( interlacedNodesIterator() ));
+}
+
+SMDS_NodeIteratorPtr SMDS_MeshElement::nodeIterator() const
+{
+  return SMDS_NodeIteratorPtr
+    ( new _MyNodeIteratorFromElemIterator( nodesIterator() ));
 }
 
 bool operator<(const SMDS_MeshElement& e1, const SMDS_MeshElement& e2)
index ccb4373a92b5d6c542b0303f0d10f89009e66d7f..a8a3ad4224f038efcf96ad34d21b539b19eb4c58 100644 (file)
@@ -65,9 +65,12 @@ public:
   SMDS_ElemIteratorPtr edgesIterator() const;
   SMDS_ElemIteratorPtr facesIterator() const;
   virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
-  virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
   virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
 
+  virtual SMDS_NodeIteratorPtr nodeIterator() const;
+  virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
+  virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;
+
   // std-like iteration on nodes
   typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_ElemIteratorPtr > iterator;
   iterator begin_nodes() const { return iterator( nodesIterator() ); }