SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FieldIterator.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 
31 ///
32 ///@file FieldIterator.h
33 ///@brief Some convenient simple iterators for fields.
34 ///
35 ///@author
36 /// Marty Cole
37 /// Department of Computer Science
38 /// University of Utah
39 ///@date January 2001
40 ///
41 
42 #ifndef Datatypes_FieldIterator_h
43 #define Datatypes_FieldIterator_h
44 
46 
47 #include <iterator>
48 
49 namespace SCIRun {
50 
51 
52 /// Base type for FieldIterator types.
53 template <class T>
56  index_(i) {}
57 
58  /// Field Iterators need to be able to increment.
59  inline
60  T operator ++() { return ++index_; }
61  T operator --() { return --index_; }
62 
63  bool operator ==(const FieldIteratorBase &a) const
64  { return index_ == a.index_; }
65  bool operator !=(const FieldIteratorBase &a) const
66  { return index_ != a.index_; }
67 
68  inline T operator*() { return index_; }
69 
70  typedef std::bidirectional_iterator_tag iterator_category;
71  typedef T difference_type;
72 
73 protected:
74  T index_;
75 #ifdef __digital__
76 public:
77 #else
78 private:
79 #endif
80  /// Hide this in private to prevent it from being called.
82  FieldIteratorBase<T> tmp(*this); ++index_; return tmp; }
84  FieldIteratorBase<T> tmp(*this); --index_; return tmp; }
85 };
86 
87 /// Distinct type for node FieldIterator.
88 template <class T>
89 struct NodeIterator : public FieldIteratorBase<T> {
91  FieldIteratorBase<T>(0) {}
92  NodeIterator(T iter) :
93  FieldIteratorBase<T>(iter) {}
94 
95  /// Required interface for an FieldIterator.
96  inline
101 };
102 
103 /// Distinct type for edge Iterator.
104 template <class T>
105 struct EdgeIterator : public FieldIteratorBase<T> {
107  FieldIteratorBase<T>(0) {}
108  EdgeIterator(T index) :
109  FieldIteratorBase<T>(index) {}
110 
111  /// Required interface for an FieldIterator.
112  inline
117 };
118 
119 /// Distinct type for face Iterator.
120 template <class T>
121 struct FaceIterator : public FieldIteratorBase<T> {
123  FieldIteratorBase<T>(0) {}
124  FaceIterator(T index) :
125  FieldIteratorBase<T>(index) {}
126 
127  /// Required interface for an FieldIterator.
128  inline
130 };
131 
132 /// Distinct type for cell Iterator.
133 template <class T>
134 struct CellIterator : public FieldIteratorBase<T> {
136  FieldIteratorBase<T>(0) {}
137  CellIterator(T index) :
138  FieldIteratorBase<T>(index) {}
139 
140  /// Required interface for an FieldIterator.
141  inline
143 };
144 
145 
146 }
147 
148 #endif // Datatypes_FieldIterator_h
T operator++()
Field Iterators need to be able to increment.
Definition: FieldIterator.h:60
bool operator!=(const FieldIteratorBase &a) const
Definition: FieldIterator.h:65
Distinct type for node FieldIterator.
Definition: FieldIterator.h:89
Distinct type for face Iterator.
Definition: FieldIterator.h:121
CellIndex< T > operator*()
Required interface for an FieldIterator.
Definition: FieldIterator.h:142
std::bidirectional_iterator_tag iterator_category
Definition: FieldIterator.h:70
T operator--()
Definition: FieldIterator.h:61
T index_
Definition: FieldIterator.h:74
EdgeIterator()
Definition: FieldIterator.h:106
CellIterator()
Definition: FieldIterator.h:135
EdgeIndex< T > operator*()
Required interface for an FieldIterator.
Definition: FieldIterator.h:113
Distinct type for cell Iterator.
Definition: FieldIterator.h:134
FieldIteratorBase(T i)
Definition: FieldIterator.h:55
Distinct type for cell index.
Definition: FieldIndex.h:99
Distinct type for node index.
Definition: FieldIndex.h:72
EdgeIterator(T index)
Definition: FieldIterator.h:108
Base type for FieldIterator types.
Definition: FieldIterator.h:54
EdgeIndex< T > & reference
Definition: FieldIterator.h:116
T operator*()
Definition: FieldIterator.h:68
FaceIterator()
Definition: FieldIterator.h:122
NodeIndex< T > value_type
Definition: FieldIterator.h:98
Distinct type for face index.
Definition: FieldIndex.h:90
FaceIterator(T index)
Definition: FieldIterator.h:124
NodeIndex< T > operator*()
Required interface for an FieldIterator.
Definition: FieldIterator.h:97
EdgeIndex< T > value_type
Definition: FieldIterator.h:114
Distinct type for edge Iterator.
Definition: FieldIterator.h:105
bool operator==(const FieldIteratorBase &a) const
Definition: FieldIterator.h:63
T difference_type
Definition: FieldIterator.h:71
NodeIndex< T > & reference
Definition: FieldIterator.h:100
FaceIndex< T > operator*()
Required interface for an FieldIterator.
Definition: FieldIterator.h:129
Distinct type for edge index.
Definition: FieldIndex.h:81
NodeIterator()
Definition: FieldIterator.h:90
NodeIterator(T iter)
Definition: FieldIterator.h:92
NodeIndex< T > * pointer
Definition: FieldIterator.h:99
CellIterator(T index)
Definition: FieldIterator.h:137
EdgeIndex< T > * pointer
Definition: FieldIterator.h:115