OpenVolumeMesh
 All Classes Functions Variables Typedefs 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: 216 $ *
38  * $Date: 2012-07-18 10:27:26 +0200 (Wed, 18 Jul 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 
195 class HexVertexIter : public BaseIterator<CellHandle,
196  VertexHandle> {
197 private:
198  typedef BaseIterator<CellHandle,
200 public:
201  HexVertexIter(const CellHandle& _ref_h,
202  const HexahedralMeshTopologyKernel* _mesh);
203  HexVertexIter& operator=(const HexVertexIter& _c) {
204  BaseIter::operator=(_c);
205  vertices_ = _c.vertices_;
206  cur_it_ = vertices_.begin();
207  return *this;
208  }
209 
210  // Post increment/decrement operator
211  HexVertexIter operator++(int) {
212  HexVertexIter cpy = *this;
213  ++(*this);
214  return cpy;
215  }
216  HexVertexIter operator--(int) {
217  HexVertexIter cpy = *this;
218  --(*this);
219  return cpy;
220  }
221  HexVertexIter operator+(int _n) {
222  HexVertexIter cpy = *this;
223  for(int i = 0; i < _n; ++i) {
224  ++cpy;
225  }
226  return cpy;
227  }
228  HexVertexIter operator-(int _n) {
229  HexVertexIter cpy = *this;
230  for(int i = 0; i < _n; ++i) {
231  --cpy;
232  }
233  return cpy;
234  }
235  HexVertexIter& operator+=(int _n) {
236  for(int i = 0; i < _n; ++i) {
237  ++(*this);
238  }
239  return *this;
240  }
241  HexVertexIter& operator-=(int _n) {
242  for(int i = 0; i < _n; ++i) {
243  --(*this);
244  }
245  return *this;
246  }
247 
248  HexVertexIter& operator++();
249  HexVertexIter& operator--();
250 
251 private:
252  std::vector<VertexHandle> vertices_;
253  std::vector<VertexHandle>::const_iterator cur_it_;
254 };
255 
256 } // Namespace OpenVolumeMesh
257 
258 #endif /* HEXAHEDRALMESHITERATORS_HH */