Developer Documentation
TetrahedralGeometryKernel.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#include <cassert>
38#include <iostream>
39
40#include <OpenVolumeMesh/Geometry/VectorT.hh>
41#include <OpenVolumeMesh/Core/GeometryKernel.hh>
42#include <OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.hh>
43
44namespace OpenVolumeMesh {
45
46template <class VecT, class TopologyKernelT = TetrahedralMeshTopologyKernel>
47class TetrahedralGeometryKernel : public GeometryKernel<VecT, TopologyKernelT> {
48public:
49
50 typedef VecT PointT;
51 typedef TopologyKernelT KernelT;
53
56
59
60 VertexHandle split_edge(HalfEdgeHandle heh, double alpha = 0.5)
61 {
62 OpenVolumeMeshEdge e = TopologyKernelT::halfedge(heh);
63 PointT newPos = alpha*ParentT::vertex(e.from_vertex()) + (1.0-alpha)*ParentT::vertex(e.to_vertex());
64 VertexHandle splitVertex = ParentT::add_vertex(newPos);
65 TopologyKernelT::split_edge(heh, splitVertex);
66 return splitVertex;
67 }
68
69 VertexHandle split_edge(EdgeHandle eh)
70 {
71 return split_edge(TopologyKernelT::halfedge_handle(eh,0));
72 }
73
74 VertexHandle split_face(FaceHandle fh, PointT pos)
75 {
76 VertexHandle splitVertex = ParentT::add_vertex(pos);
77 TopologyKernelT::split_face(fh, splitVertex);
78 return splitVertex;
79 }
80
81 VertexHandle split_face(FaceHandle fh)
82 {
83 VertexHandle splitVertex = ParentT::add_vertex(ParentT::barycenter(fh));
84 TopologyKernelT::split_face(fh, splitVertex);
85 return splitVertex;
86 }
87
88protected:
89
90};
91
92} // Namespace OpenVolumeMesh
93
const VecT & vertex(VertexHandle _vh) const
Get point _vh's coordinates.
virtual VertexHandle add_vertex()
Add abstract vertex.