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
76 std::vector<VertexHandle> get_cell_vertices(CellHandle ch) const;
77 std::vector<VertexHandle> get_cell_vertices(CellHandle ch, VertexHandle vh) const;
78 std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh) const;
79 std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const;
80
81 VertexHandle halfface_opposite_vertex(HalfFaceHandle hfh) const;
82
83
84 VertexHandle collapse_edge(HalfEdgeHandle _heh);
85protected:
86 void split_edge(HalfEdgeHandle _heh, VertexHandle _vh);
87 void split_face(FaceHandle _fh, VertexHandle _vh);
88
89public:
90
91
92 // ======================= Specialized Iterators =============================
93
94 friend class TetVertexIter;
95
96 typedef class TetVertexIter TetVertexIter;
97
98 TetVertexIter tv_iter(CellHandle _ref_h, int _max_laps = 1) const {
99 return TetVertexIter(_ref_h, this, _max_laps);
100 }
101
102 std::pair<TetVertexIter,TetVertexIter> tet_vertices(CellHandle _ref_h, int _max_laps = 1) const {
103 TetVertexIter begin = tv_iter(_ref_h, _max_laps);
104 TetVertexIter end = make_end_circulator(begin);
105 return std::make_pair(begin, end);
106 }
107
108private:
109 // void replaceHalfFace(CellHandle ch, HalfFaceHandle hf_del, HalfFaceHandle hf_ins);
110 // void replaceHalfEdge(HalfFaceHandle hfh, HalfEdgeHandle he_del, HalfEdgeHandle he_ins);
111
112 template <typename PropIterator, typename Handle>
113 void swapPropertyElements(PropIterator begin, PropIterator end, Handle source, Handle destination)
114 {
115 PropIterator p_iter = begin;
116 for (; p_iter != end; ++p_iter)
117 (*p_iter)->swap_elements(source, destination);
118 }
119};
120
121} // Namespace OpenVolumeMesh
122
A data structure based on PolyhedralMesh with specializations for tetrahedra.