Developer Documentation
TetrahedralMeshTopologyKernel.hh
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 /*===========================================================================*\
36  * *
37  * $Revision$ *
38  * $Date$ *
39  * $LastChangedBy$ *
40  * *
41 \*===========================================================================*/
42 
43 #ifndef TETRAHEDRALMESHTOPOLOGYKERNEL_HH
44 #define TETRAHEDRALMESHTOPOLOGYKERNEL_HH
45 
46 #ifndef NDEBUG
47 #include <iostream>
48 #endif
49 #include <set>
50 
51 #include "../Core/TopologyKernel.hh"
52 #include "TetrahedralMeshIterators.hh"
53 
54 namespace OpenVolumeMesh {
55 
64 public:
65 
67  ~TetrahedralMeshTopologyKernel() override = default;
68 
69  FaceHandle add_face(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck = false) override;
70 
71  FaceHandle add_face(const std::vector<VertexHandle>& _vertices) override;
72 
73  CellHandle add_cell(const std::vector<HalfFaceHandle>& _halffaces, bool _topologyCheck = false) override;
74 
75  CellHandle add_cell(const std::vector<VertexHandle>& _vertices, bool _topologyCheck = false);
76 
77  CellHandle add_cell(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3, bool _topologyCheck = false);
78 
79  HalfFaceHandle add_halfface(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck = false);
80  HalfFaceHandle add_halfface(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, bool _topologyCheck = false);
81 
82  HalfEdgeHandle add_halfedge(const VertexHandle& _fromVertex, const VertexHandle& _toVertex);
83 
84  std::vector<VertexHandle> get_cell_vertices(CellHandle ch) const;
85  std::vector<VertexHandle> get_cell_vertices(CellHandle ch, VertexHandle vh) const;
86  std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh) const;
87  std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const;
88 
89  std::vector<VertexHandle> get_halfface_vertices(HalfFaceHandle hfh) const;
90  std::vector<VertexHandle> get_halfface_vertices(HalfFaceHandle hfh, VertexHandle vh) const;
91  std::vector<VertexHandle> get_halfface_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const;
92 
93  VertexHandle halfface_opposite_vertex(HalfFaceHandle hfh) const;
94 
95 
96  VertexHandle collapse_edge(HalfEdgeHandle _heh);
97 protected:
98  void split_edge(HalfEdgeHandle _heh, VertexHandle _vh);
99  void split_face(FaceHandle _fh, VertexHandle _vh);
100 
101 public:
102 
103 
104  // ======================= Specialized Iterators =============================
105 
106  friend class TetVertexIter;
107 
108  typedef class TetVertexIter TetVertexIter;
109 
110  TetVertexIter tv_iter(const CellHandle& _ref_h, int _max_laps = 1) const {
111  return TetVertexIter(_ref_h, this, _max_laps);
112  }
113 
114  std::pair<TetVertexIter,TetVertexIter> tet_vertices(const CellHandle& _ref_h, int _max_laps = 1) const {
115  TetVertexIter begin = tv_iter(_ref_h, _max_laps);
116  TetVertexIter end = make_end_circulator(begin);
117  return std::make_pair(begin, end);
118  }
119 
120 private:
121  // void replaceHalfFace(CellHandle ch, HalfFaceHandle hf_del, HalfFaceHandle hf_ins);
122  // void replaceHalfEdge(HalfFaceHandle hfh, HalfEdgeHandle he_del, HalfEdgeHandle he_ins);
123 
124  template <typename PropIterator, typename Handle>
125  void swapPropertyElements(PropIterator begin, PropIterator end, Handle source, Handle destination)
126  {
127  PropIterator p_iter = begin;
128  for (; p_iter != end; ++p_iter)
129  (*p_iter)->swap_elements(source, destination);
130  }
131 };
132 
133 } // Namespace OpenVolumeMesh
134 
135 #endif /* TETRAHEDRALMESHTOPOLOGYKERNEL_HH */
A data structure based on PolyhedralMesh with specializations for tetrahedra.
FaceHandle add_face(const std::vector< HalfEdgeHandle > &_halfedges, bool _topologyCheck=false) override
Add face via incident edges.
CellHandle add_cell(const std::vector< HalfFaceHandle > &_halffaces, bool _topologyCheck=false) override
Add cell via incident halffaces.