Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HexahedralMeshIterators.hh
1 /*===========================================================================*\
2  * *
3  * OpenVolumeMesh *
4  * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
5  * www.openvolumemesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenVolumeMesh. *
9  * *
10  * OpenVolumeMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenVolumeMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenVolumeMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision: 178 $ *
38  * $Date: 2012-04-26 12:04:23 +0200 (Do, 26 Apr 2012) $ *
39  * $LastChangedBy: kremer $ *
40  * *
41 \*===========================================================================*/
42 
43 #ifndef HEXAHEDRALMESHITERATORS_HH
44 #define HEXAHEDRALMESHITERATORS_HH
45 
46 #include "../Core/Iterators.hh"
47 
48 namespace OpenVolumeMesh {
49 
50 class HexahedralMeshTopologyKernel;
51 
52 
53 class CellSheetCellIter : public BaseIterator<CellHandle,
54  CellHandle> {
55 private:
56  typedef BaseIterator<CellHandle,
58 public:
59  CellSheetCellIter(const CellHandle& _ref_h, const unsigned char _orthDir,
60  const HexahedralMeshTopologyKernel* _mesh);
61 
62  CellSheetCellIter& operator=(const CellSheetCellIter& _c) {
63  BaseIter::operator=(_c);
64  neighb_sheet_cell_hs_ = _c.neighb_sheet_cell_hs_;
65  cur_it_ = neighb_sheet_cell_hs_.begin();
66  return *this;
67  }
68 
69  // Post increment/decrement operator
70  CellSheetCellIter operator++(int) {
71  CellSheetCellIter cpy = *this;
72  ++(*this);
73  return cpy;
74  }
75  CellSheetCellIter operator--(int) {
76  CellSheetCellIter cpy = *this;
77  --(*this);
78  return cpy;
79  }
80  CellSheetCellIter operator+(int _n) {
81  CellSheetCellIter cpy = *this;
82  for(int i = 0; i < _n; ++i) {
83  ++cpy;
84  }
85  return cpy;
86  }
87  CellSheetCellIter operator-(int _n) {
88  CellSheetCellIter cpy = *this;
89  for(int i = 0; i < _n; ++i) {
90  --cpy;
91  }
92  return cpy;
93  }
94  CellSheetCellIter& operator+=(int _n) {
95  for(int i = 0; i < _n; ++i) {
96  ++(*this);
97  }
98  return *this;
99  }
100  CellSheetCellIter& operator-=(int _n) {
101  for(int i = 0; i < _n; ++i) {
102  --(*this);
103  }
104  return *this;
105  }
106 
107  CellSheetCellIter& operator++();
108  CellSheetCellIter& operator--();
109 
110 private:
111  std::set<CellHandle> neighb_sheet_cell_hs_;
112  std::set<CellHandle>::const_iterator cur_it_;
113 };
114 
115 
116 class HalfFaceSheetHalfFaceIter : public BaseIterator<HalfFaceHandle,
117  HalfFaceHandle> {
118 private:
121 public:
123  const HexahedralMeshTopologyKernel* _mesh);
125  BaseIter::operator=(_c);
126  adjacent_halffaces_ = _c.adjacent_halffaces_;
127  cur_it_ = adjacent_halffaces_.begin();
128  return *this;
129  }
130 
131  // Post increment/decrement operator
132  HalfFaceSheetHalfFaceIter operator++(int) {
133  HalfFaceSheetHalfFaceIter cpy = *this;
134  ++(*this);
135  return cpy;
136  }
137  HalfFaceSheetHalfFaceIter operator--(int) {
138  HalfFaceSheetHalfFaceIter cpy = *this;
139  --(*this);
140  return cpy;
141  }
142  HalfFaceSheetHalfFaceIter operator+(int _n) {
143  HalfFaceSheetHalfFaceIter cpy = *this;
144  for(int i = 0; i < _n; ++i) {
145  ++cpy;
146  }
147  return cpy;
148  }
149  HalfFaceSheetHalfFaceIter operator-(int _n) {
150  HalfFaceSheetHalfFaceIter cpy = *this;
151  for(int i = 0; i < _n; ++i) {
152  --cpy;
153  }
154  return cpy;
155  }
156  HalfFaceSheetHalfFaceIter& operator+=(int _n) {
157  for(int i = 0; i < _n; ++i) {
158  ++(*this);
159  }
160  return *this;
161  }
162  HalfFaceSheetHalfFaceIter& operator-=(int _n) {
163  for(int i = 0; i < _n; ++i) {
164  --(*this);
165  }
166  return *this;
167  }
168 
169  HalfFaceSheetHalfFaceIter& operator++();
170  HalfFaceSheetHalfFaceIter& operator--();
171 
172  const EdgeHandle& common_edge() const { return *edge_it_; }
173 
174 private:
175  std::vector<HalfFaceHandle> adjacent_halffaces_;
176  std::vector<HalfFaceHandle>::const_iterator cur_it_;
177  std::vector<EdgeHandle> common_edges_;
178  std::vector<EdgeHandle>::const_iterator edge_it_;
179 };
180 
181 
182 class OutsideNeighborHalfFaceIter : public BaseIterator<HalfFaceHandle,
183  HalfFaceHandle> {
184 private:
187 public:
189  const HexahedralMeshTopologyKernel* _mesh);
191  BaseIter::operator=(_c);
192  neighbor_halffaces_ = _c.neighbor_halffaces_;
193  cur_it_ = neighbor_halffaces_.begin();
194  return *this;
195  }
196 
197  // Post increment/decrement operator
198  OutsideNeighborHalfFaceIter operator++(int) {
199  OutsideNeighborHalfFaceIter cpy = *this;
200  ++(*this);
201  return cpy;
202  }
203  OutsideNeighborHalfFaceIter operator--(int) {
204  OutsideNeighborHalfFaceIter cpy = *this;
205  --(*this);
206  return cpy;
207  }
208  OutsideNeighborHalfFaceIter operator+(int _n) {
209  OutsideNeighborHalfFaceIter cpy = *this;
210  for(int i = 0; i < _n; ++i) {
211  ++cpy;
212  }
213  return cpy;
214  }
215  OutsideNeighborHalfFaceIter operator-(int _n) {
216  OutsideNeighborHalfFaceIter cpy = *this;
217  for(int i = 0; i < _n; ++i) {
218  --cpy;
219  }
220  return cpy;
221  }
222  OutsideNeighborHalfFaceIter& operator+=(int _n) {
223  for(int i = 0; i < _n; ++i) {
224  ++(*this);
225  }
226  return *this;
227  }
228  OutsideNeighborHalfFaceIter& operator-=(int _n) {
229  for(int i = 0; i < _n; ++i) {
230  --(*this);
231  }
232  return *this;
233  }
234 
235  const EdgeHandle& common_edge() const { return *edge_it_; }
236 
237  OutsideNeighborHalfFaceIter& operator++();
238  OutsideNeighborHalfFaceIter& operator--();
239 
240 private:
241  std::vector<HalfFaceHandle> neighbor_halffaces_;
242  std::vector<EdgeHandle> common_edges_;
243  std::vector<HalfFaceHandle>::const_iterator cur_it_;
244  std::vector<EdgeHandle>::const_iterator edge_it_;
245 };
246 
261 class HexVertexIter : public BaseIterator<CellHandle,
262  VertexHandle> {
263 private:
264  typedef BaseIterator<CellHandle,
266 public:
267  HexVertexIter(const CellHandle& _ref_h,
268  const HexahedralMeshTopologyKernel* _mesh);
269  HexVertexIter& operator=(const HexVertexIter& _c) {
270  BaseIter::operator=(_c);
271  vertices_ = _c.vertices_;
272  cur_it_ = vertices_.begin();
273  return *this;
274  }
275 
276  // Post increment/decrement operator
277  HexVertexIter operator++(int) {
278  HexVertexIter cpy = *this;
279  ++(*this);
280  return cpy;
281  }
282  HexVertexIter operator--(int) {
283  HexVertexIter cpy = *this;
284  --(*this);
285  return cpy;
286  }
287  HexVertexIter operator+(int _n) {
288  HexVertexIter cpy = *this;
289  for(int i = 0; i < _n; ++i) {
290  ++cpy;
291  }
292  return cpy;
293  }
294  HexVertexIter operator-(int _n) {
295  HexVertexIter cpy = *this;
296  for(int i = 0; i < _n; ++i) {
297  --cpy;
298  }
299  return cpy;
300  }
301  HexVertexIter& operator+=(int _n) {
302  for(int i = 0; i < _n; ++i) {
303  ++(*this);
304  }
305  return *this;
306  }
307  HexVertexIter& operator-=(int _n) {
308  for(int i = 0; i < _n; ++i) {
309  --(*this);
310  }
311  return *this;
312  }
313 
314  HexVertexIter& operator++();
315  HexVertexIter& operator--();
316 
317 private:
318  std::vector<VertexHandle> vertices_;
319  std::vector<VertexHandle>::const_iterator cur_it_;
320 };
321 
322 } // Namespace OpenVolumeMesh
323 
324 #endif /* HEXAHEDRALMESHITERATORS_HH */