43 #ifndef HEXAHEDRALMESHTOPOLOGYKERNEL_HH 44 #define HEXAHEDRALMESHTOPOLOGYKERNEL_HH 51 #include "../Core/TopologyKernel.hh" 52 #include "HexahedralMeshIterators.hh" 90 static const unsigned char XF = 0;
91 static const unsigned char XB = 1;
92 static const unsigned char YF = 2;
93 static const unsigned char YB = 3;
94 static const unsigned char ZF = 4;
95 static const unsigned char ZB = 5;
96 static const unsigned char INVALID = 6;
98 static inline unsigned char opposite_orientation(
const unsigned char _d) {
99 return (_d % 2 == 0 ? _d + 1 : _d - 1);
109 virtual FaceHandle add_face(
const std::vector<HalfEdgeHandle>& _halfedges,
bool _topologyCheck =
false);
115 virtual CellHandle add_cell(
const std::vector<HalfFaceHandle>& _halffaces,
bool _topologyCheck =
false);
119 bool check_halfface_ordering(
const std::vector<HalfFaceHandle>& _hfs)
const;
143 CellHandle add_cell(
const std::vector<VertexHandle>& _vertices,
bool _topologyCheck =
false);
147 friend class CellSheetCellIter;
148 friend class HalfFaceSheetHalfFaceIter;
149 friend class HexVertexIter;
151 typedef class CellSheetCellIter CellSheetCellIter;
152 typedef class HalfFaceSheetHalfFaceIter HalfFaceSheetHalfFaceIter;
153 typedef class HexVertexIter HexVertexIter;
155 CellSheetCellIter csc_iter(
const CellHandle& _ref_h,
const unsigned char _orthDir,
int _max_laps = 1)
const {
156 return CellSheetCellIter(_ref_h, _orthDir,
this, _max_laps);
159 std::pair<CellSheetCellIter,CellSheetCellIter> cell_sheet_cells(
const CellHandle& _ref_h,
const unsigned char _orthDir,
int _max_laps = 1)
const {
160 CellSheetCellIter begin = csc_iter(_ref_h, _orthDir, _max_laps);
161 CellSheetCellIter end = make_end_circulator(begin);
162 return std::make_pair(begin, end);
165 HalfFaceSheetHalfFaceIter hfshf_iter(
const HalfFaceHandle& _ref_h,
int _max_laps = 1)
const {
166 return HalfFaceSheetHalfFaceIter(_ref_h,
this, _max_laps);
169 std::pair<HalfFaceSheetHalfFaceIter,HalfFaceSheetHalfFaceIter> halfface_sheet_halffaces(
const HalfFaceHandle& _ref_h,
int _max_laps = 1)
const {
170 HalfFaceSheetHalfFaceIter begin = hfshf_iter(_ref_h, _max_laps);
171 HalfFaceSheetHalfFaceIter end = make_end_circulator(begin);
172 return std::make_pair(begin, end);
175 HexVertexIter hv_iter(
const CellHandle& _ref_h,
int _max_laps = 1)
const {
176 return HexVertexIter(_ref_h,
this, _max_laps);
179 std::pair<HexVertexIter,HexVertexIter> hex_vertices(
const CellHandle& _ref_h,
int _max_laps = 1)
const {
180 HexVertexIter begin = hv_iter(_ref_h, _max_laps);
181 HexVertexIter end = make_end_circulator(begin);
182 return std::make_pair(begin, end);
189 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
191 if(orientation(_hfh, _ch) == XF)
return xback_halfface(_ch);
192 if(orientation(_hfh, _ch) == XB)
return xfront_halfface(_ch);
193 if(orientation(_hfh, _ch) == YF)
return yback_halfface(_ch);
194 if(orientation(_hfh, _ch) == YB)
return yfront_halfface(_ch);
195 if(orientation(_hfh, _ch) == ZF)
return zback_halfface(_ch);
196 if(orientation(_hfh, _ch) == ZB)
return zfront_halfface(_ch);
198 return TopologyKernel::InvalidHalfFaceHandle;
203 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
210 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
217 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
224 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
231 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
238 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
245 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
248 for(
unsigned int i = 0; i < halffaces.size(); ++i) {
249 if(halffaces[i] == _hfh)
return (
unsigned char)i;
255 static inline unsigned char orthogonal_orientation(
const unsigned char _o1,
const unsigned char _o2) {
257 if(_o1 == XF && _o2 == YF)
return ZF;
258 if(_o1 == XF && _o2 == YB)
return ZB;
259 if(_o1 == XF && _o2 == ZF)
return YB;
260 if(_o1 == XF && _o2 == ZB)
return YF;
261 if(_o1 == XB && _o2 == YF)
return ZB;
262 if(_o1 == XB && _o2 == YB)
return ZF;
263 if(_o1 == XB && _o2 == ZF)
return YF;
264 if(_o1 == XB && _o2 == ZB)
return YB;
266 if(_o1 == YF && _o2 == XF)
return ZB;
267 if(_o1 == YF && _o2 == XB)
return ZF;
268 if(_o1 == YF && _o2 == ZF)
return XF;
269 if(_o1 == YF && _o2 == ZB)
return XB;
270 if(_o1 == YB && _o2 == XF)
return ZF;
271 if(_o1 == YB && _o2 == XB)
return ZB;
272 if(_o1 == YB && _o2 == ZF)
return XB;
273 if(_o1 == YB && _o2 == ZB)
return XF;
275 if(_o1 == ZF && _o2 == YF)
return XB;
276 if(_o1 == ZF && _o2 == YB)
return XF;
277 if(_o1 == ZF && _o2 == XF)
return YF;
278 if(_o1 == ZF && _o2 == XB)
return YB;
279 if(_o1 == ZB && _o2 == YF)
return XF;
280 if(_o1 == ZB && _o2 == YB)
return XB;
281 if(_o1 == ZB && _o2 == XF)
return YB;
282 if(_o1 == ZB && _o2 == XB)
return YF;
290 if(_o == XF)
return xfront_halfface(_ch);
291 if(_o == XB)
return xback_halfface(_ch);
292 if(_o == YF)
return yfront_halfface(_ch);
293 if(_o == YB)
return yback_halfface(_ch);
294 if(_o == ZF)
return zfront_halfface(_ch);
295 if(_o == ZB)
return zback_halfface(_ch);
296 return TopologyKernel::InvalidHalfFaceHandle;
301 if(!TopologyKernel::has_face_bottom_up_incidences()) {
303 std::cerr <<
"No bottom-up incidences computed so far, could not get adjacent halfface on sheet!" << std::endl;
305 return TopologyKernel::InvalidHalfFaceHandle;
314 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
315 n_hf = TopologyKernel::opposite_halfface_handle(n_hf);
316 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
317 HalfEdgeHandle o_he = TopologyKernel::opposite_halfedge_handle(n_he);
318 if(o_he == TopologyKernel::InvalidHalfEdgeHandle)
break;
320 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
324 n_hf = TopologyKernel::opposite_halfface_handle(_hfh);
325 n_he = TopologyKernel::opposite_halfedge_handle(_heh);
330 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
331 n_hf = TopologyKernel::opposite_halfface_handle(n_hf);
332 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
333 HalfEdgeHandle o_he = TopologyKernel::opposite_halfedge_handle(n_he);
334 if(o_he == TopologyKernel::InvalidHalfEdgeHandle)
break;
336 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
337 else return TopologyKernel::opposite_halfface_handle(n_hf);
340 return TopologyKernel::InvalidHalfFaceHandle;
346 hehf_it.valid(); ++hehf_it) {
347 if(*hehf_it == _hfh)
continue;
348 if(TopologyKernel::is_boundary(*hehf_it)) {
351 if(TopologyKernel::is_boundary(TopologyKernel::opposite_halfface_handle(*hehf_it))) {
352 return TopologyKernel::opposite_halfface_handle(*hehf_it);
355 return TopologyKernel::InvalidHalfFaceHandle;
360 if(!TopologyKernel::has_face_bottom_up_incidences()) {
362 std::cerr <<
"No bottom-up incidences computed so far, could not get neighboring outside halfface!" << std::endl;
364 return TopologyKernel::InvalidHalfFaceHandle;
368 hehf_it; ++hehf_it) {
369 if(*hehf_it == _hfh)
continue;
370 if(TopologyKernel::is_boundary(*hehf_it))
return *hehf_it;
371 if(TopologyKernel::is_boundary(TopologyKernel::opposite_halfface_handle(*hehf_it)))
372 return TopologyKernel::opposite_halfface_handle(*hehf_it);
375 return TopologyKernel::InvalidHalfFaceHandle;
381 const std::vector<HalfFaceHandle>& _halffaces)
const;
const Cell & cell(const CellHandle &_cellHandle) const
Get cell with handle _cellHandle.
virtual CellHandle add_cell(const std::vector< HalfFaceHandle > &_halffaces, bool _topologyCheck=false)
Overridden function.
HalfFaceHandle adjacent_halfface_in_cell(const HalfFaceHandle &_halfFaceHandle, const HalfEdgeHandle &_halfEdgeHandle) const
Get halfface that is adjacent (w.r.t. a common halfedge) within the same cell.
A data structure basing on PolyhedralMesh with specializations for hexahedra.
virtual FaceHandle add_face(const std::vector< HalfEdgeHandle > &_halfedges, bool _topologyCheck=false)
Add face via incident edges.