Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
66  // Constructor
68 
69  // Destructor
71 
72  // Overridden function
73  virtual FaceHandle add_face(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck = false);
74 
75  // Overridden function
76  virtual FaceHandle add_face(const std::vector<VertexHandle>& _vertices);
77 
78  // Overridden function
79  virtual CellHandle add_cell(const std::vector<HalfFaceHandle>& _halffaces, bool _topologyCheck = false);
80 
81  CellHandle add_cell(const std::vector<VertexHandle>& _vertices, bool _topologyCheck = false);
82  CellHandle add_cell(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3, bool _topologyCheck = false);
83 
84  HalfFaceHandle add_halfface(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck = false);
85  HalfFaceHandle add_halfface(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, bool _topologyCheck = false);
86 
87  HalfEdgeHandle add_halfedge(const VertexHandle& _fromVertex, const VertexHandle& _toVertex);
88 
89  std::vector<VertexHandle> get_cell_vertices(CellHandle ch) const;
90  std::vector<VertexHandle> get_cell_vertices(CellHandle ch, VertexHandle vh) const;
91  std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh) const;
92  std::vector<VertexHandle> get_cell_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const;
93 
94  std::vector<VertexHandle> get_halfface_vertices(HalfFaceHandle hfh) const;
95  std::vector<VertexHandle> get_halfface_vertices(HalfFaceHandle hfh, VertexHandle vh) const;
96  std::vector<VertexHandle> get_halfface_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const;
97 
98 
99  VertexHandle collapse_edge(HalfEdgeHandle _heh);
100 protected:
101  void split_edge(HalfEdgeHandle _heh, VertexHandle _vh);
102  void split_face(FaceHandle _fh, VertexHandle _vh);
103 
104 public:
105 
106 
107  // ======================= Specialized Iterators =============================
108 
109  friend class TetVertexIter;
110 
111  typedef class TetVertexIter TetVertexIter;
112 
113  TetVertexIter tv_iter(const CellHandle& _ref_h, int _max_laps = 1) const {
114  return TetVertexIter(_ref_h, this, _max_laps);
115  }
116 
117  std::pair<TetVertexIter,TetVertexIter> tet_vertices(const CellHandle& _ref_h, int _max_laps = 1) const {
118  TetVertexIter begin = tv_iter(_ref_h, _max_laps);
119  TetVertexIter end = make_end_circulator(begin);
120  return std::make_pair(begin, end);
121  }
122 
123 private:
124  // void replaceHalfFace(CellHandle ch, HalfFaceHandle hf_del, HalfFaceHandle hf_ins);
125  // void replaceHalfEdge(HalfFaceHandle hfh, HalfEdgeHandle he_del, HalfEdgeHandle he_ins);
126 
127  template <typename PropIterator, typename Handle>
128  void swapPropertyElements(PropIterator begin, PropIterator end, Handle source, Handle destination)
129  {
130  PropIterator p_iter = begin;
131  for (; p_iter != end; ++p_iter)
132  (*p_iter)->swap_elements(source, destination);
133  }
134 };
135 
136 } // Namespace OpenVolumeMesh
137 
138 #endif /* TETRAHEDRALMESHTOPOLOGYKERNEL_HH */
A data structure based on PolyhedralMesh with specializations for tetrahedra.
virtual FaceHandle add_face(const std::vector< HalfEdgeHandle > &_halfedges, bool _topologyCheck=false)
Add face via incident edges.
virtual CellHandle add_cell(const std::vector< HalfFaceHandle > &_halffaces, bool _topologyCheck=false)
Add cell via incident halffaces.