Developer Documentation
Loading...
Searching...
No Matches
TetrahedralMeshTopologyKernel.hh
1#pragma once
2/*===========================================================================*\
3 * *
4 * OpenVolumeMesh *
5 * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
6 * www.openvolumemesh.org *
7 * *
8 *---------------------------------------------------------------------------*
9 * This file is part of OpenVolumeMesh. *
10 * *
11 * OpenVolumeMesh is free software: you can redistribute it and/or modify *
12 * it under the terms of the GNU Lesser General Public License as *
13 * published by the Free Software Foundation, either version 3 of *
14 * the License, or (at your option) any later version with the *
15 * following exceptions: *
16 * *
17 * If other files instantiate templates or use macros *
18 * or inline functions from this file, or you compile this file and *
19 * link it with other files to produce an executable, this file does *
20 * not by itself cause the resulting executable to be covered by the *
21 * GNU Lesser General Public License. This exception does not however *
22 * invalidate any other reasons why the executable file might be *
23 * covered by the GNU Lesser General Public License. *
24 * *
25 * OpenVolumeMesh is distributed in the hope that it will be useful, *
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28 * GNU Lesser General Public License for more details. *
29 * *
30 * You should have received a copy of the GNU LesserGeneral Public *
31 * License along with OpenVolumeMesh. If not, *
32 * see <http://www.gnu.org/licenses/>. *
33 * *
34\*===========================================================================*/
35
36
37#ifndef NDEBUG
38#include <iostream>
39#endif
40#include <set>
41
42#include <OpenVolumeMesh/Core/TopologyKernel.hh>
43#include <OpenVolumeMesh/Mesh/TetrahedralMeshIterators.hh>
44#include <OpenVolumeMesh/Config/Export.hh>
45
46namespace OpenVolumeMesh {
47
56public:
57
59 ~TetrahedralMeshTopologyKernel() override = default;
60
61 FaceHandle add_face(std::vector<HalfEdgeHandle> _halfedges, bool _topologyCheck = false) override;
62
63 FaceHandle add_face(const std::vector<VertexHandle>& _vertices) override;
64
65 CellHandle add_cell(std::vector<HalfFaceHandle> _halffaces, bool _topologyCheck = false) override;
66
67 CellHandle add_cell(const std::vector<VertexHandle>& _vertices, bool _topologyCheck = false);
68
69 CellHandle add_cell(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3, bool _topologyCheck = false);
70
71 HalfFaceHandle add_halfface(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck = false);
72 HalfFaceHandle add_halfface(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, bool _topologyCheck = false);
73
74 HalfEdgeHandle add_halfedge(VertexHandle _fromVertex, VertexHandle _toVertex);
75
79 std::vector<VertexHandle> get_cell_vertices(CellHandle ch) const;
80
82 std::vector<VertexHandle> get_cell_vertices(CellHandle ch, VertexHandle vh) const;
83
88 std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh) const;
89
93 std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const;
94
97 VertexHandle halfface_opposite_vertex(HalfFaceHandle hfh) const;
98
100 HalfFaceHandle vertex_opposite_halfface(CellHandle ch, VertexHandle vh) const;
101
102
103 VertexHandle collapse_edge(HalfEdgeHandle _heh);
104protected:
105 void split_edge(HalfEdgeHandle _heh, VertexHandle _vh);
106 void split_face(FaceHandle _fh, VertexHandle _vh);
107
108public:
109
110
111 // ======================= Specialized Iterators =============================
112
113 friend class TetVertexIter;
114
115 typedef class TetVertexIter TetVertexIter;
116
121 TetVertexIter tv_iter(CellHandle _ref_h, int _max_laps = 1) const {
122 return TetVertexIter(_ref_h, this, _max_laps);
123 }
124
125 std::pair<TetVertexIter,TetVertexIter> tet_vertices(CellHandle _ref_h, int _max_laps = 1) const {
126 TetVertexIter begin = tv_iter(_ref_h, _max_laps);
127 TetVertexIter end = make_end_circulator(begin);
128 return std::make_pair(begin, end);
129 }
130
131private:
132 // void replaceHalfFace(CellHandle ch, HalfFaceHandle hf_del, HalfFaceHandle hf_ins);
133 // void replaceHalfEdge(HalfFaceHandle hfh, HalfEdgeHandle he_del, HalfEdgeHandle he_ins);
134
135 template <typename PropIterator, typename Handle>
136 void swapPropertyElements(PropIterator begin, PropIterator end, Handle source, Handle destination)
137 {
138 PropIterator p_iter = begin;
139 for (; p_iter != end; ++p_iter)
140 (*p_iter)->swap_elements(source, destination);
141 }
142};
143
144} // Namespace OpenVolumeMesh
145
Iterate over all vertices of a tetrahedron in a specific order.
A data structure based on PolyhedralMesh with specializations for tetrahedra.
TetVertexIter tv_iter(CellHandle _ref_h, int _max_laps=1) const