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