45 #include "HexahedralMeshIterators.hh" 46 #include "HexahedralMeshTopologyKernel.hh" 55 CellSheetCellIter::CellSheetCellIter(
const CellHandle& _ref_h,
57 BaseIter(_mesh, _ref_h, _max_laps) {
59 if(!_mesh->has_face_bottom_up_incidences()) {
61 std::cerr <<
"This iterator needs bottom-up incidences!" << std::endl;
63 BaseIter::valid(
false);
68 std::vector<HalfFaceHandle> halffaces = _mesh->
cell(_ref_h).halffaces();
69 for(std::vector<HalfFaceHandle>::const_iterator hf_it = halffaces.begin();
70 hf_it != halffaces.end(); ++hf_it) {
72 if(_mesh->orientation(*hf_it, _ref_h) != _orthDir &&
73 _mesh->orientation(*hf_it, _ref_h) != _mesh->opposite_orientation(_orthDir)) {
74 CellHandle ch = _mesh->
incident_cell(_mesh->opposite_halfface_handle(*hf_it));
75 if(ch != TopologyKernel::InvalidCellHandle) {
76 neighb_sheet_cell_hs_.push_back(ch);
82 std::sort(neighb_sheet_cell_hs_.begin(), neighb_sheet_cell_hs_.end());
83 neighb_sheet_cell_hs_.resize(std::unique(neighb_sheet_cell_hs_.begin(), neighb_sheet_cell_hs_.end()) - neighb_sheet_cell_hs_.begin());
86 BaseIter::valid(neighb_sheet_cell_hs_.size() > 0);
87 if(BaseIter::valid()) {
88 BaseIter::cur_handle(neighb_sheet_cell_hs_[cur_index_]);
93 CellSheetCellIter& CellSheetCellIter::operator--() {
95 if (cur_index_ == 0) {
96 cur_index_ = neighb_sheet_cell_hs_.size() - 1;
99 BaseIter::valid(
false);
104 BaseIter::cur_handle(neighb_sheet_cell_hs_[cur_index_]);
110 CellSheetCellIter& CellSheetCellIter::operator++() {
113 if(cur_index_ == neighb_sheet_cell_hs_.size()) {
116 if (lap_ >= max_laps_)
117 BaseIter::valid(
false);
120 BaseIter::cur_handle(neighb_sheet_cell_hs_[cur_index_]);
130 HalfFaceSheetHalfFaceIter::HalfFaceSheetHalfFaceIter(
const HalfFaceHandle& _ref_h,
132 BaseIter(_mesh, _ref_h, _max_laps) {
134 if(!_mesh->has_face_bottom_up_incidences()) {
136 std::cerr <<
"This iterator needs bottom-up incidences!" << std::endl;
138 BaseIter::valid(
false);
153 if(_mesh->is_boundary(_ref_h)) {
155 std::cerr <<
"HalfFaceSheetHalfFaceIter: HalfFace is boundary!" << std::endl;
157 BaseIter::valid(
false);
162 unsigned char orientation = _mesh->orientation(_ref_h, ch);
164 std::set<HalfEdgeHandle> hes;
165 hes.insert(hes_v.begin(), hes_v.end());
167 for(CellSheetCellIter csc_it = _mesh->csc_iter(ch, orientation);
168 csc_it.valid(); ++csc_it) {
170 std::vector<HalfFaceHandle> hfs = _mesh->
cell(*csc_it).halffaces();
171 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
172 hf_it != hfs.end(); ++hf_it) {
174 std::vector<HalfEdgeHandle> hf_hes = _mesh->
halfface(*hf_it).halfedges();
175 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hf_hes.begin();
176 he_it != hf_hes.end(); ++he_it) {
178 if(hes.count(*he_it) > 0) {
180 adjacent_halffaces_.push_back(*hf_it);
181 common_edges_.push_back(_mesh->
edge_handle(*he_it));
189 BaseIter::valid(adjacent_halffaces_.size() > 0);
190 if(BaseIter::valid()) {
191 BaseIter::cur_handle(adjacent_halffaces_[cur_index_]);
196 HalfFaceSheetHalfFaceIter& HalfFaceSheetHalfFaceIter::operator--() {
198 if (cur_index_ == 0) {
199 cur_index_ = adjacent_halffaces_.size() - 1;
202 BaseIter::valid(
false);
207 BaseIter::cur_handle(adjacent_halffaces_[cur_index_]);
213 HalfFaceSheetHalfFaceIter& HalfFaceSheetHalfFaceIter::operator++() {
216 if(cur_index_ == adjacent_halffaces_.size()) {
219 if (lap_ >= max_laps_)
220 BaseIter::valid(
false);
223 BaseIter::cur_handle(adjacent_halffaces_[cur_index_]);
233 HexVertexIter::HexVertexIter(
const CellHandle& _ref_h,
235 BaseIter(_mesh, _ref_h, _max_laps) {
237 assert(_ref_h.is_valid());
238 assert(_mesh->
cell(_ref_h).halffaces().size() == 6);
241 HalfFaceHandle curHF = *_mesh->
cell(_ref_h).halffaces().begin();
242 assert(curHF.is_valid());
245 assert(_mesh->
halfface(curHF).halfedges().size() == 4);
246 HalfEdgeHandle curHE = *_mesh->
halfface(curHF).halfedges().begin();
247 assert(curHE.is_valid());
249 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
253 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
257 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
261 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
265 curHE = _mesh->opposite_halfedge_handle(curHE);
269 curHE = _mesh->opposite_halfedge_handle(curHE);
271 vertices_.push_back(_mesh->
halfedge(curHE).to_vertex());
275 vertices_.push_back(_mesh->
halfedge(curHE).to_vertex());
279 vertices_.push_back(_mesh->
halfedge(curHE).to_vertex());
281 vertices_.push_back(_mesh->
halfedge(curHE).from_vertex());
284 BaseIter::valid(vertices_.size() > 0);
285 if(BaseIter::valid()) {
286 BaseIter::cur_handle(vertices_[cur_index_]);
291 HexVertexIter& HexVertexIter::operator--() {
293 if (cur_index_ == 0) {
294 cur_index_ = vertices_.size() - 1;
297 BaseIter::valid(
false);
302 BaseIter::cur_handle(vertices_[cur_index_]);
308 HexVertexIter& HexVertexIter::operator++() {
311 if(cur_index_ == vertices_.size()) {
314 if (lap_ >= max_laps_)
315 BaseIter::valid(
false);
318 BaseIter::cur_handle(vertices_[cur_index_]);
const Cell & cell(const CellHandle &_cellHandle) const
Get cell with handle _cellHandle.
Face opposite_halfface(const HalfFaceHandle &_halfFaceHandle) const
Get opposite halfface that corresponds to halfface with handle _halfFaceHandle.
static EdgeHandle edge_handle(const HalfEdgeHandle &_h)
Handle conversion.
A data structure basing on PolyhedralMesh with specializations for hexahedra.
Face halfface(const HalfFaceHandle &_halfFaceHandle) const
Get face that corresponds to halfface with handle _halfFaceHandle.
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.
HalfEdgeHandle prev_halfedge_in_halfface(const HalfEdgeHandle &_heh, const HalfFaceHandle &_hfh) const
Get previous halfedge within a halfface.
CellHandle incident_cell(const HalfFaceHandle &_halfFaceHandle) const
Get cell that is incident to the given halfface.
Edge halfedge(const HalfEdgeHandle &_halfEdgeHandle) const
Get edge that corresponds to halfedge with handle _halfEdgeHandle.
HalfEdgeHandle next_halfedge_in_halfface(const HalfEdgeHandle &_heh, const HalfFaceHandle &_hfh) const
Get next halfedge within a halfface.