38#include <OpenVolumeMesh/Mesh/HexahedralMeshIterators.hh>
39#include <OpenVolumeMesh/Mesh/HexahedralMeshTopologyKernel.hh>
41namespace OpenVolumeMesh {
48CellSheetCellIter::CellSheetCellIter(
const CellHandle& _ref_h,
50BaseIter(_mesh, _ref_h, _max_laps) {
52 if(!_mesh->has_face_bottom_up_incidences()) {
54 std::cerr <<
"This iterator needs bottom-up incidences!" << std::endl;
56 BaseIter::valid(
false);
61 std::vector<HalfFaceHandle> halffaces = _mesh->
cell(_ref_h).halffaces();
62 for(std::vector<HalfFaceHandle>::const_iterator hf_it = halffaces.begin();
63 hf_it != halffaces.end(); ++hf_it) {
65 if(_mesh->orientation(*hf_it, _ref_h) != _orthDir &&
66 _mesh->orientation(*hf_it, _ref_h) != _mesh->opposite_orientation(_orthDir)) {
67 CellHandle ch = _mesh->
incident_cell(_mesh->opposite_halfface_handle(*hf_it));
68 if(ch != TopologyKernel::InvalidCellHandle) {
69 neighb_sheet_cell_hs_.push_back(ch);
75 std::sort(neighb_sheet_cell_hs_.begin(), neighb_sheet_cell_hs_.end());
76 neighb_sheet_cell_hs_.resize(std::unique(neighb_sheet_cell_hs_.begin(), neighb_sheet_cell_hs_.end()) - neighb_sheet_cell_hs_.begin());
79 BaseIter::valid(neighb_sheet_cell_hs_.size() > 0);
80 if(BaseIter::valid()) {
81 BaseIter::cur_handle(neighb_sheet_cell_hs_[cur_index_]);
86CellSheetCellIter& CellSheetCellIter::operator--() {
88 if (cur_index_ == 0) {
89 cur_index_ = neighb_sheet_cell_hs_.size() - 1;
92 BaseIter::valid(
false);
97 BaseIter::cur_handle(neighb_sheet_cell_hs_[cur_index_]);
103CellSheetCellIter& CellSheetCellIter::operator++() {
106 if(cur_index_ == neighb_sheet_cell_hs_.size()) {
109 if (lap_ >= max_laps_)
110 BaseIter::valid(
false);
113 BaseIter::cur_handle(neighb_sheet_cell_hs_[cur_index_]);
123HalfFaceSheetHalfFaceIter::HalfFaceSheetHalfFaceIter(
const HalfFaceHandle& _ref_h,
125BaseIter(_mesh, _ref_h, _max_laps) {
127 if(!_mesh->has_face_bottom_up_incidences()) {
129 std::cerr <<
"This iterator needs bottom-up incidences!" << std::endl;
131 BaseIter::valid(
false);
146 if(_mesh->is_boundary(_ref_h)) {
148 std::cerr <<
"HalfFaceSheetHalfFaceIter: HalfFace is boundary!" << std::endl;
150 BaseIter::valid(
false);
155 unsigned char orientation = _mesh->orientation(_ref_h, ch);
157 std::set<HalfEdgeHandle> hes;
158 hes.insert(hes_v.begin(), hes_v.end());
160 for(CellSheetCellIter csc_it = _mesh->csc_iter(ch, orientation);
161 csc_it.valid(); ++csc_it) {
163 std::vector<HalfFaceHandle> hfs = _mesh->
cell(*csc_it).halffaces();
164 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
165 hf_it != hfs.end(); ++hf_it) {
167 std::vector<HalfEdgeHandle> hf_hes = _mesh->
halfface(*hf_it).halfedges();
168 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hf_hes.begin();
169 he_it != hf_hes.end(); ++he_it) {
171 if(hes.count(*he_it) > 0) {
173 adjacent_halffaces_.push_back(*hf_it);
174 common_edges_.push_back(_mesh->
edge_handle(*he_it));
182 BaseIter::valid(adjacent_halffaces_.size() > 0);
183 if(BaseIter::valid()) {
184 BaseIter::cur_handle(adjacent_halffaces_[cur_index_]);
189HalfFaceSheetHalfFaceIter& HalfFaceSheetHalfFaceIter::operator--() {
191 if (cur_index_ == 0) {
192 cur_index_ = adjacent_halffaces_.size() - 1;
195 BaseIter::valid(
false);
200 BaseIter::cur_handle(adjacent_halffaces_[cur_index_]);
206HalfFaceSheetHalfFaceIter& HalfFaceSheetHalfFaceIter::operator++() {
209 if(cur_index_ == adjacent_halffaces_.size()) {
212 if (lap_ >= max_laps_)
213 BaseIter::valid(
false);
216 BaseIter::cur_handle(adjacent_halffaces_[cur_index_]);
226HexVertexIter::HexVertexIter(
const CellHandle& _ref_h,
228BaseIter(_mesh, _ref_h, _max_laps) {
230 assert(_ref_h.is_valid());
233 assert(cell.halffaces().size() == 6);
236 HalfFaceHandle curHF = *cell.halffaces().begin();
237 assert(curHF.is_valid());
240 assert(_mesh->
halfface(curHF).halfedges().size() == 4);
241 HalfEdgeHandle curHE = *_mesh->
halfface(curHF).halfedges().begin();
242 assert(curHE.is_valid());
244 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
248 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
252 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
256 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
260 curHE = _mesh->opposite_halfedge_handle(curHE);
264 curHE = _mesh->opposite_halfedge_handle(curHE);
266 vertices_.push_back(_mesh->
halfedge(curHE).to_vertex());
270 vertices_.push_back(_mesh->
halfedge(curHE).to_vertex());
274 vertices_.push_back(_mesh->
halfedge(curHE).to_vertex());
276 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
279 BaseIter::valid(vertices_.size() > 0);
280 if(BaseIter::valid()) {
281 BaseIter::cur_handle(vertices_[cur_index_]);
286HexVertexIter& HexVertexIter::operator--() {
288 if (cur_index_ == 0) {
289 cur_index_ = vertices_.size() - 1;
292 BaseIter::valid(
false);
297 BaseIter::cur_handle(vertices_[cur_index_]);
303HexVertexIter& HexVertexIter::operator++() {
306 if(cur_index_ == vertices_.size()) {
309 if (lap_ >= max_laps_)
310 BaseIter::valid(
false);
313 BaseIter::cur_handle(vertices_[cur_index_]);
A data structure basing on PolyhedralMesh with specializations for hexahedra.
Face opposite_halfface(HalfFaceHandle _halfFaceHandle) const
Get opposite halfface that corresponds to halfface with handle _halfFaceHandle.
CellHandle incident_cell(HalfFaceHandle _halfFaceHandle) const
Get cell that is incident to the given halfface.
const Cell & cell(CellHandle _cellHandle) const
Get cell with handle _cellHandle.
HalfEdgeHandle prev_halfedge_in_halfface(HalfEdgeHandle _heh, HalfFaceHandle _hfh) const
Get previous halfedge within a halfface.
HalfEdgeHandle next_halfedge_in_halfface(HalfEdgeHandle _heh, HalfFaceHandle _hfh) const
Get next halfedge within a halfface.
static EdgeHandle edge_handle(HalfEdgeHandle _h)
Handle conversion.
Face halfface(HalfFaceHandle _halfFaceHandle) const
Get face that corresponds to halfface with handle _halfFaceHandle.
Edge halfedge(HalfEdgeHandle _halfEdgeHandle) const
Get edge that corresponds to halfedge with handle _halfEdgeHandle.
HalfFaceHandle adjacent_halfface_in_cell(HalfFaceHandle _halfFaceHandle, HalfEdgeHandle _halfEdgeHandle) const
Get halfface that is adjacent (w.r.t. a common halfedge) within the same cell. It correctly handles s...