Developer Documentation
Loading...
Searching...
No Matches
TetrahedralMeshIterators.cc
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#include <set>
36
37#include <OpenVolumeMesh/Mesh/TetrahedralMeshIterators.hh>
38#include <OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.hh>
39#include <OpenVolumeMesh/Core/Iterators.hh>
40
41namespace OpenVolumeMesh {
42
43//================================================================================================
44// TetVertexIter
45//================================================================================================
46
47
48TetVertexIter::TetVertexIter(CellHandle _ref_h,
49 const TetrahedralMeshTopologyKernel* _mesh, int _max_laps) :
50BaseIter(_mesh, _ref_h, _max_laps) {
51
52 assert(_ref_h.is_valid());
53
54 assert(_mesh->valence(_ref_h) == 4);
55
56 const auto& cell_vhs = _mesh->get_cell_vertices(_ref_h);
57 vertices_[0] = cell_vhs[0];
58 vertices_[1] = cell_vhs[1];
59 vertices_[2] = cell_vhs[2];
60 vertices_[3] = cell_vhs[3];
61
62 cur_index_ = 0;
63 BaseIter::cur_handle(vertices_[cur_index_]);
64}
65
66
67TetVertexIter& TetVertexIter::operator--() {
68
69 if (cur_index_ == 0) {
70 cur_index_ = vertices_.size() - 1;
71 --lap_;
72 if (lap_ < 0)
73 BaseIter::valid(false);
74 } else {
75 --cur_index_;
76 }
77
78 BaseIter::cur_handle(vertices_[cur_index_]);
79
80 return *this;
81}
82
83
84TetVertexIter& TetVertexIter::operator++() {
85
86 ++cur_index_;
87 if(cur_index_ == vertices_.size()) {
88 cur_index_ = 0;
89 ++lap_;
90 if (lap_ >= max_laps_)
91 BaseIter::valid(false);
92 }
93
94 BaseIter::cur_handle(vertices_[cur_index_]);
95
96 return *this;
97}
98
99} // Namespace OpenVolumeMesh