Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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$ *
38  * $Date$ *
39  * $LastChangedBy$ *
40  * *
41 \*===========================================================================*/
42 
43 #ifndef HEXAHEDRALMESHITERATORS_HH
44 #define HEXAHEDRALMESHITERATORS_HH
45 
46 #include "../Core/Iterators.hh"
47 
48 namespace OpenVolumeMesh {
49 
51 
52 
53 class CellSheetCellIter : public BaseCirculator<CellHandle, CellHandle> {
54 private:
56 public:
57  CellSheetCellIter(const CellHandle& _ref_h, const unsigned char _orthDir,
58  const HexahedralMeshTopologyKernel* _mesh, int _max_laps = 1);
59 
60  // Post increment/decrement operator
61  CellSheetCellIter operator++(int) {
62  CellSheetCellIter cpy = *this;
63  ++(*this);
64  return cpy;
65  }
66  CellSheetCellIter operator--(int) {
67  CellSheetCellIter cpy = *this;
68  --(*this);
69  return cpy;
70  }
71  CellSheetCellIter operator+(int _n) {
72  CellSheetCellIter cpy = *this;
73  for(int i = 0; i < _n; ++i) {
74  ++cpy;
75  }
76  return cpy;
77  }
78  CellSheetCellIter operator-(int _n) {
79  CellSheetCellIter cpy = *this;
80  for(int i = 0; i < _n; ++i) {
81  --cpy;
82  }
83  return cpy;
84  }
85  CellSheetCellIter& operator+=(int _n) {
86  for(int i = 0; i < _n; ++i) {
87  ++(*this);
88  }
89  return *this;
90  }
91  CellSheetCellIter& operator-=(int _n) {
92  for(int i = 0; i < _n; ++i) {
93  --(*this);
94  }
95  return *this;
96  }
97 
98  CellSheetCellIter& operator++();
99  CellSheetCellIter& operator--();
100 
101 private:
102  std::vector<CellHandle> neighb_sheet_cell_hs_;
103  size_t cur_index_;
104 };
105 
106 
107 class HalfFaceSheetHalfFaceIter : public BaseCirculator<HalfFaceHandle,HalfFaceHandle> {
108 private:
110 public:
112  const HexahedralMeshTopologyKernel* _mesh, int _max_laps = 1);
113 
114  // Post increment/decrement operator
115  HalfFaceSheetHalfFaceIter operator++(int) {
116  HalfFaceSheetHalfFaceIter cpy = *this;
117  ++(*this);
118  return cpy;
119  }
120  HalfFaceSheetHalfFaceIter operator--(int) {
121  HalfFaceSheetHalfFaceIter cpy = *this;
122  --(*this);
123  return cpy;
124  }
125  HalfFaceSheetHalfFaceIter operator+(int _n) {
126  HalfFaceSheetHalfFaceIter cpy = *this;
127  for(int i = 0; i < _n; ++i) {
128  ++cpy;
129  }
130  return cpy;
131  }
132  HalfFaceSheetHalfFaceIter operator-(int _n) {
133  HalfFaceSheetHalfFaceIter cpy = *this;
134  for(int i = 0; i < _n; ++i) {
135  --cpy;
136  }
137  return cpy;
138  }
139  HalfFaceSheetHalfFaceIter& operator+=(int _n) {
140  for(int i = 0; i < _n; ++i) {
141  ++(*this);
142  }
143  return *this;
144  }
145  HalfFaceSheetHalfFaceIter& operator-=(int _n) {
146  for(int i = 0; i < _n; ++i) {
147  --(*this);
148  }
149  return *this;
150  }
151 
152  HalfFaceSheetHalfFaceIter& operator++();
153  HalfFaceSheetHalfFaceIter& operator--();
154 
155  const EdgeHandle& common_edge() const { return common_edges_[cur_index_]; }
156 
157 private:
158  std::vector<HalfFaceHandle> adjacent_halffaces_;
159  std::vector<EdgeHandle> common_edges_;
160  size_t cur_index_;
161 };
162 
177 class HexVertexIter : public BaseCirculator<CellHandle,
178  VertexHandle> {
179 private:
180  typedef BaseCirculator<CellHandle,
182 public:
183  HexVertexIter(const CellHandle& _ref_h,
184  const HexahedralMeshTopologyKernel* _mesh,
185  int _max_laps = 1);
186 
187  // Post increment/decrement operator
188  HexVertexIter operator++(int) {
189  HexVertexIter cpy = *this;
190  ++(*this);
191  return cpy;
192  }
193  HexVertexIter operator--(int) {
194  HexVertexIter cpy = *this;
195  --(*this);
196  return cpy;
197  }
198  HexVertexIter operator+(int _n) {
199  HexVertexIter cpy = *this;
200  for(int i = 0; i < _n; ++i) {
201  ++cpy;
202  }
203  return cpy;
204  }
205  HexVertexIter operator-(int _n) {
206  HexVertexIter cpy = *this;
207  for(int i = 0; i < _n; ++i) {
208  --cpy;
209  }
210  return cpy;
211  }
212  HexVertexIter& operator+=(int _n) {
213  for(int i = 0; i < _n; ++i) {
214  ++(*this);
215  }
216  return *this;
217  }
218  HexVertexIter& operator-=(int _n) {
219  for(int i = 0; i < _n; ++i) {
220  --(*this);
221  }
222  return *this;
223  }
224 
225  HexVertexIter& operator++();
226  HexVertexIter& operator--();
227 
228 private:
229  std::vector<VertexHandle> vertices_;
230  size_t cur_index_;
231 };
232 
233 } // Namespace OpenVolumeMesh
234 
235 #endif /* HEXAHEDRALMESHITERATORS_HH */
Iterate over all vertices of a hexahedron in a specific order.
A data structure basing on PolyhedralMesh with specializations for hexahedra.