Developer Documentation
DiffGeoT.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 //=============================================================================
44 //
45 // CLASS DiffGeoT
46 //
47 //=============================================================================
48 
49 
50 #ifndef DIFFGEO_HH
51 #define DIFFGEO_HH
52 
53 
54 //== INCLUDES =================================================================
55 
56 #include <OpenMesh/Core/Utils/Property.hh>
57 
58 
59 //== NAMESPACES ===============================================================
60 
61 namespace Remeshing {
62 
63 //== CLASS DEFINITION =========================================================
64 
65 
66 template <class Mesh>
67 class DiffGeoT
68 {
69 public:
70 
71  typedef typename Mesh::Scalar Scalar;
72  typedef typename Mesh::VertexHandle VertexHandle;
73 
74 
75  explicit DiffGeoT(Mesh& _mesh);
76  ~DiffGeoT();
77 
78 
79  void compute(unsigned int _post_smoothing_iters=0);
80 
81  void compute_edge_weights();
82  void compute_area();
83  void compute_gauss_curvature();
84  void compute_mean_curvature();
85  void post_smoothing(unsigned int _iters);
86 
87 
88  Scalar compute_area(VertexHandle _vh) const;
89 
90 
91  Scalar area(VertexHandle _vh) const {
92  return mesh_.property(area_, _vh);
93  }
94 
95  Scalar gauss_curvature(VertexHandle _vh) const {
96  return mesh_.property(gauss_curvature_, _vh);
97  }
98 
99  Scalar mean_curvature(VertexHandle _vh) const {
100  return mesh_.property(mean_curvature_, _vh);
101  }
102 
103  Scalar min_curvature(VertexHandle _vh) const {
104  const Scalar zero(0.0);
105  Scalar H = mean_curvature(_vh);
106  Scalar K = gauss_curvature(_vh);
107  return H - sqrt(std::max(zero, H*H-K));
108  }
109 
110  Scalar max_curvature(VertexHandle _vh) const {
111  const Scalar zero(0.0);
112  Scalar H = mean_curvature(_vh);
113  Scalar K = gauss_curvature(_vh);
114  return H + sqrt(std::max(zero, H*H-K));
115  }
116 
117 
118 private:
119 
120  Mesh& mesh_;
121 
123  OpenMesh::VPropHandleT<Scalar> gauss_curvature_;
124  OpenMesh::VPropHandleT<Scalar> mean_curvature_;
125  OpenMesh::EPropHandleT<Scalar> edge_weight_;
126 
127  bool weights_computed_, area_computed_;
128 };
129 
130 
131 //=============================================================================
132 } // namespace Remeshing
133 //=============================================================================
134 #if defined(INCLUDE_TEMPLATES) && !defined(DIFFGEOT_C)
135 #define DIFFGEO_TEMPLATES
136 #include "DiffGeoT_impl.hh"
137 #endif
138 //=============================================================================
139 #endif // DIFFGEO_HH defined
140 //=============================================================================
141 
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:110
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136