1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkVertexListIterator.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16   Copyright 2008 Sandia Corporation.
17   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18   the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
20 /**
21  * @class   vtkVertexListIterator
22  * @brief   Iterates all vertices in a graph.
23  *
24  *
25  * vtkVertexListIterator iterates through all vertices in a graph.
26  * Create an instance of this and call graph->GetVertices(it) to initialize
27  * this iterator. You may alternately call SetGraph() to initialize the
28  * iterator.
29  *
30  * @sa
31  * vtkGraph
32  */
33 
34 #ifndef vtkVertexListIterator_h
35 #define vtkVertexListIterator_h
36 
37 #include "vtkCommonDataModelModule.h" // For export macro
38 #include "vtkObject.h"
39 
40 #include "vtkGraph.h" // For edge type definitions
41 
42 class vtkGraphEdge;
43 
44 class VTKCOMMONDATAMODEL_EXPORT vtkVertexListIterator : public vtkObject
45 {
46 public:
47   static vtkVertexListIterator* New();
48   vtkTypeMacro(vtkVertexListIterator, vtkObject);
49   void PrintSelf(ostream& os, vtkIndent indent) override;
50 
51   /**
52    * Setup the iterator with a graph.
53    */
54   virtual void SetGraph(vtkGraph* graph);
55 
56   ///@{
57   /**
58    * Get the graph associated with this iterator.
59    */
60   vtkGetObjectMacro(Graph, vtkGraph);
61   ///@}
62 
63   ///@{
64   /**
65    * Returns the next edge in the graph.
66    */
Next()67   vtkIdType Next()
68   {
69     vtkIdType v = this->Current;
70     ++this->Current;
71     return v;
72   }
73   ///@}
74 
75   /**
76    * Whether this iterator has more edges.
77    */
HasNext()78   bool HasNext() { return this->Current != this->End; }
79 
80 protected:
81   vtkVertexListIterator();
82   ~vtkVertexListIterator() override;
83 
84   vtkGraph* Graph;
85   vtkIdType Current;
86   vtkIdType End;
87 
88 private:
89   vtkVertexListIterator(const vtkVertexListIterator&) = delete;
90   void operator=(const vtkVertexListIterator&) = delete;
91 };
92 
93 #endif
94