SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FieldVIterator.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 #ifndef CORE_DATATYPES_FIELDVITERATOR_H
32 #define CORE_DATATYPES_FIELDVITERATOR_H 1
33 
35 
36 namespace SCIRun {
37 
38 
39 /// Base type for FieldVIterator types.
40 template <class T>
42 {
43  public:
45  index_(i) {}
46 
47  /// Field Iterators need to be able to increment.
48  inline
49  T operator ++() { return ++index_; }
50  T operator --() { return --index_; }
51 
52  bool operator ==(const FieldVIteratorBase &a) const
53  { return this->index_ == a.index_; }
54  bool operator !=(const FieldVIteratorBase &a) const
55  { return this->index_ != a.index_; }
56 
57  inline T operator*() const { return this->index_; }
58 
59  typedef std::bidirectional_iterator_tag iterator_category;
60  typedef T difference_type;
61 
62 protected:
63  T index_;
64 private:
65  /// Hide this in private to prevent it from being called.
68 };
69 
70 
71 /// Distinct type for node FieldIterator.
72 template <class T>
73 struct VNodeIterator : public FieldVIteratorBase<T> {
75  FieldVIteratorBase<T>(0) {}
76  VNodeIterator(T iter) :
77  FieldVIteratorBase<T>(iter) {}
78 
79  /// Required interface for an FieldIterator.
80  inline
81  VNodeIndex<T> operator*() const { return VNodeIndex<T>(this->index_); }
82 
86 
87  template <class U> friend U operator+(const VNodeIndex<U> &a, const VNodeIndex<U> &b);
88 };
89 
90 /// Distinct type for lagrangian node FieldIterator.
91 template <class T>
92 struct VENodeIterator : public FieldVIteratorBase<T> {
94  FieldVIteratorBase<T>(0) {}
95  VENodeIterator(T iter) :
96  FieldVIteratorBase<T>(iter) {}
97 
98  /// Required interface for an FieldIterator.
99  inline
100  VENodeIndex<T> operator*() const { return VENodeIndex<T>(this->index_); }
101 };
102 
103 /// Distinct type for edge Iterator.
104 template <class T>
105 struct VEdgeIterator : public FieldVIteratorBase<T> {
107  FieldVIteratorBase<T>(0) {}
108  VEdgeIterator(T index) :
109  FieldVIteratorBase<T>(index) {}
110 
111  /// Required interface for an FieldIterator.
112  inline
113  VEdgeIndex<T> operator*() const { return VEdgeIndex<T>(this->index_); }
114 
118 };
119 
120 /// Distinct type for face Iterator.
121 template <class T>
122 struct VFaceIterator : public FieldVIteratorBase<T> {
124  FieldVIteratorBase<T>(0) {}
125  VFaceIterator(T index) :
126  FieldVIteratorBase<T>(index) {}
127 
128  /// Required interface for an FieldIterator.
129  inline
130  VFaceIndex<T> operator*() const { return VFaceIndex<T>(this->index_); }
131 
132  template <class U> friend U operator+(const VFaceIndex<U> &a, const VFaceIndex<U> &b);
133 };
134 
135 /// Distinct type for cell Iterator.
136 template <class T>
137 struct VCellIterator : public FieldVIteratorBase<T> {
139  FieldVIteratorBase<T>(0) {}
140  VCellIterator(T index) :
141  FieldVIteratorBase<T>(index) {}
142 
143  /// Required interface for an FieldIterator.
144  inline
145  VCellIndex<T> operator*() const { return VCellIndex<T>(this->index_); }
146 };
147 
148 /// Distinct type for cell Iterator.
149 template <class T>
150 struct VElemIterator : public FieldVIteratorBase<T> {
152  FieldVIteratorBase<T>(0) {}
153  VElemIterator(T index) :
154  FieldVIteratorBase<T>(index) {}
155 
156  /// Required interface for an FieldIterator.
157  inline
158  VElemIndex<T> operator*() const { return VElemIndex<T>(this->index_); }
159 };
160 
161 /// Distinct type for cell Iterator.
162 template <class T>
163 struct VDElemIterator : public FieldVIteratorBase<T> {
165  FieldVIteratorBase<T>(0) {}
166  VDElemIterator(T index) :
167  FieldVIteratorBase<T>(index) {}
168 
169  /// Required interface for an FieldIterator.
170  inline
171  VDElemIndex<T> operator*() const { return VDElemIndex<T>(this->index_); }
172 };
173 
174 template <class T>
175 T operator+(const VNodeIndex<T> &a, const VNodeIndex<T> &b)
176 { return a.index_ + b.index_; }
177 
178 template <class T>
179 T operator+(const VFaceIndex<T> &a, const VFaceIndex<T> &b)
180 { return a.index_ + b.index_; }
181 
182 }
183 
184 #endif
friend U operator+(const VFaceIndex< U > &a, const VFaceIndex< U > &b)
VEdgeIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:113
T operator+(const VNodeIndex< T > &a, const VNodeIndex< T > &b)
Definition: FieldVIterator.h:175
VEdgeIndex< T > * pointer
Definition: FieldVIterator.h:116
VDElemIterator()
Definition: FieldVIterator.h:164
Distinct type for cell Iterator.
Definition: FieldVIterator.h:163
VNodeIterator()
Definition: FieldVIterator.h:74
VNodeIterator(T iter)
Definition: FieldVIterator.h:76
Distinct type for elem index.
Definition: FieldVIndex.h:228
VCellIterator()
Definition: FieldVIterator.h:138
VEdgeIterator()
Definition: FieldVIterator.h:106
VNodeIndex< T > & reference
Definition: FieldVIterator.h:85
FieldVIteratorBase(T i)
Definition: FieldVIterator.h:44
bool operator==(const FieldVIteratorBase &a) const
Definition: FieldVIterator.h:52
VNodeIndex< T > * pointer
Definition: FieldVIterator.h:84
Distinct type for cell Iterator.
Definition: FieldVIterator.h:150
Distinct type for face index.
Definition: FieldVIndex.h:210
VEdgeIndex< T > & reference
Definition: FieldVIterator.h:117
T operator*() const
Definition: FieldVIterator.h:57
Distinct type for edge index.
Definition: FieldVIndex.h:200
Distinct type for lagrangian node FieldIterator.
Definition: FieldVIterator.h:92
T operator--()
Definition: FieldVIterator.h:50
Distinct type for elem index.
Definition: FieldVIndex.h:237
VElemIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:158
friend U operator+(const VNodeIndex< U > &a, const VNodeIndex< U > &b)
VFaceIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:130
Distinct type for node index.
Definition: FieldVIndex.h:181
VENodeIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:100
VDElemIterator(T index)
Definition: FieldVIterator.h:166
Distinct type for additional lagrangian node.
Definition: FieldVIndex.h:190
VENodeIterator(T iter)
Definition: FieldVIterator.h:95
VDElemIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:171
Distinct type for edge Iterator.
Definition: FieldVIterator.h:105
VENodeIterator()
Definition: FieldVIterator.h:93
VEdgeIterator(T index)
Definition: FieldVIterator.h:108
VFaceIterator()
Definition: FieldVIterator.h:123
Base type for FieldVIterator types.
Definition: FieldVIterator.h:41
T index_
Definition: FieldVIndex.h:67
VCellIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:145
VNodeIndex< T > value_type
Definition: FieldVIterator.h:83
Distinct type for cell index.
Definition: FieldVIndex.h:219
VElemIterator(T index)
Definition: FieldVIterator.h:153
VNodeIndex< T > operator*() const
Required interface for an FieldIterator.
Definition: FieldVIterator.h:81
T index_
Definition: FieldVIterator.h:63
bool operator!=(const FieldVIteratorBase &a) const
Definition: FieldVIterator.h:54
Distinct type for cell Iterator.
Definition: FieldVIterator.h:137
VElemIterator()
Definition: FieldVIterator.h:151
std::bidirectional_iterator_tag iterator_category
Definition: FieldVIterator.h:59
T difference_type
Definition: FieldVIterator.h:60
Distinct type for node FieldIterator.
Definition: FieldVIterator.h:73
VFaceIterator(T index)
Definition: FieldVIterator.h:125
Distinct type for face Iterator.
Definition: FieldVIterator.h:122
T operator++()
Field Iterators need to be able to increment.
Definition: FieldVIterator.h:49
VEdgeIndex< T > value_type
Definition: FieldVIterator.h:115
VCellIterator(T index)
Definition: FieldVIterator.h:140