43 #ifndef HEXAHEDRALMESHTOPOLOGYKERNEL_HH
44 #define HEXAHEDRALMESHTOPOLOGYKERNEL_HH
48 #include "../Core/TopologyKernel.hh"
49 #include "HexahedralMeshIterators.hh"
51 namespace OpenVolumeMesh {
87 static const unsigned char XF = 0;
88 static const unsigned char XB = 1;
89 static const unsigned char YF = 2;
90 static const unsigned char YB = 3;
91 static const unsigned char ZF = 4;
92 static const unsigned char ZB = 5;
93 static const unsigned char INVALID = 6;
95 static inline unsigned char opposite_orientation(
const unsigned char _d) {
96 return (_d % 2 == 0 ? _d + 1 : _d - 1);
106 virtual FaceHandle add_face(
const std::vector<HalfEdgeHandle>& _halfedges,
bool _topologyCheck =
false);
112 virtual CellHandle add_cell(
const std::vector<HalfFaceHandle>& _halffaces,
bool _topologyCheck =
false);
116 bool check_halfface_ordering(
const std::vector<HalfFaceHandle>& _hfs)
const;
143 friend class CellSheetCellIter;
144 friend class HalfFaceSheetHalfFaceIter;
145 friend class HexVertexIter;
147 typedef class CellSheetCellIter CellSheetCellIter;
148 typedef class HalfFaceSheetHalfFaceIter HalfFaceSheetHalfFaceIter;
149 typedef class HexVertexIter HexVertexIter;
151 CellSheetCellIter csc_iter(
const CellHandle& _ref_h,
const unsigned char _orthDir)
const {
152 return CellSheetCellIter(_ref_h, _orthDir,
this);
155 HalfFaceSheetHalfFaceIter hfshf_iter(
const HalfFaceHandle& _ref_h)
const {
156 return HalfFaceSheetHalfFaceIter(_ref_h,
this);
159 HexVertexIter hv_iter(
const CellHandle& _ref_h)
const {
160 return HexVertexIter(_ref_h,
this);
167 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
169 if(orientation(_hfh, _ch) == XF)
return xback_halfface(_ch);
170 if(orientation(_hfh, _ch) == XB)
return xfront_halfface(_ch);
171 if(orientation(_hfh, _ch) == YF)
return yback_halfface(_ch);
172 if(orientation(_hfh, _ch) == YB)
return yfront_halfface(_ch);
173 if(orientation(_hfh, _ch) == ZF)
return zback_halfface(_ch);
174 if(orientation(_hfh, _ch) == ZB)
return zfront_halfface(_ch);
176 return TopologyKernel::InvalidHalfFaceHandle;
181 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
188 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
195 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
202 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
209 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
216 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
223 assert((
unsigned int)_ch.idx() < TopologyKernel::cells_.size());
226 for(
unsigned int i = 0; i < halffaces.size(); ++i) {
227 if(halffaces[i] == _hfh)
return (
unsigned char)i;
233 static inline unsigned char orthogonal_orientation(
const unsigned char _o1,
const unsigned char _o2) {
235 if(_o1 == XF && _o2 == YF)
return ZF;
236 if(_o1 == XF && _o2 == YB)
return ZB;
237 if(_o1 == XF && _o2 == ZF)
return YB;
238 if(_o1 == XF && _o2 == ZB)
return YF;
239 if(_o1 == XB && _o2 == YF)
return ZB;
240 if(_o1 == XB && _o2 == YB)
return ZF;
241 if(_o1 == XB && _o2 == ZF)
return YF;
242 if(_o1 == XB && _o2 == ZB)
return YB;
244 if(_o1 == YF && _o2 == XF)
return ZB;
245 if(_o1 == YF && _o2 == XB)
return ZF;
246 if(_o1 == YF && _o2 == ZF)
return XF;
247 if(_o1 == YF && _o2 == ZB)
return XB;
248 if(_o1 == YB && _o2 == XF)
return ZF;
249 if(_o1 == YB && _o2 == XB)
return ZB;
250 if(_o1 == YB && _o2 == ZF)
return XB;
251 if(_o1 == YB && _o2 == ZB)
return XF;
253 if(_o1 == ZF && _o2 == YF)
return XB;
254 if(_o1 == ZF && _o2 == YB)
return XF;
255 if(_o1 == ZF && _o2 == XF)
return YF;
256 if(_o1 == ZF && _o2 == XB)
return YB;
257 if(_o1 == ZB && _o2 == YF)
return XF;
258 if(_o1 == ZB && _o2 == YB)
return XB;
259 if(_o1 == ZB && _o2 == XF)
return YB;
260 if(_o1 == ZB && _o2 == XB)
return YF;
268 if(_o == XF)
return xfront_halfface(_ch);
269 if(_o == XB)
return xback_halfface(_ch);
270 if(_o == YF)
return yfront_halfface(_ch);
271 if(_o == YB)
return yback_halfface(_ch);
272 if(_o == ZF)
return zfront_halfface(_ch);
273 if(_o == ZB)
return zback_halfface(_ch);
274 return TopologyKernel::InvalidHalfFaceHandle;
279 if(!TopologyKernel::has_face_bottom_up_incidences()) {
280 std::cerr <<
"No bottom-up incidences computed so far, could not get adjacent halfface on sheet!" << std::endl;
281 return TopologyKernel::InvalidHalfFaceHandle;
290 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
291 n_hf = TopologyKernel::opposite_halfface_handle(n_hf);
292 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
293 HalfEdgeHandle o_he = TopologyKernel::opposite_halfedge_handle(n_he);
294 if(o_he == TopologyKernel::InvalidHalfEdgeHandle)
break;
296 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
300 n_hf = TopologyKernel::opposite_halfface_handle(_hfh);
301 n_he = TopologyKernel::opposite_halfedge_handle(_heh);
306 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
307 n_hf = TopologyKernel::opposite_halfface_handle(n_hf);
308 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
309 HalfEdgeHandle o_he = TopologyKernel::opposite_halfedge_handle(n_he);
310 if(o_he == TopologyKernel::InvalidHalfEdgeHandle)
break;
312 if(n_hf == TopologyKernel::InvalidHalfFaceHandle)
break;
313 else return TopologyKernel::opposite_halfface_handle(n_hf);
316 return TopologyKernel::InvalidHalfFaceHandle;
322 hehf_it.valid(); ++hehf_it) {
323 if(*hehf_it == _hfh)
continue;
324 if(TopologyKernel::is_boundary(*hehf_it)) {
327 if(TopologyKernel::is_boundary(TopologyKernel::opposite_halfface_handle(*hehf_it))) {
328 return TopologyKernel::opposite_halfface_handle(*hehf_it);
331 return TopologyKernel::InvalidHalfFaceHandle;
336 if(!TopologyKernel::has_face_bottom_up_incidences()) {
337 std::cerr <<
"No bottom-up incidences computed so far, could not get neighboring outside halfface!" << std::endl;
338 return TopologyKernel::InvalidHalfFaceHandle;
342 hehf_it; ++hehf_it) {
343 if(*hehf_it == _hfh)
continue;
344 if(TopologyKernel::is_boundary(*hehf_it))
return *hehf_it;
345 if(TopologyKernel::is_boundary(TopologyKernel::opposite_halfface_handle(*hehf_it)))
346 return TopologyKernel::opposite_halfface_handle(*hehf_it);
349 return TopologyKernel::InvalidHalfFaceHandle;
355 const std::vector<HalfFaceHandle>& _halffaces)
const;