57 #include <ACG/Geometry/Algorithms.hh> 58 #include "Math_Tools/Math_Tools.hh" 61 #include <OpenMesh/Core/Geometry/MathDefs.hh> 73 template<
typename MeshT >
76 if (_mesh.status(_vh).deleted())
79 double gauss_curv = 2.0 * M_PI;
91 const typename MeshT::Point p0 = _mesh.point(_vh);
93 typename MeshT::CVOHIter voh_it( _mesh.cvoh_iter(_vh));
94 typename MeshT::CVOHIter n_voh_it = voh_it;
96 if ( ! voh_it->is_valid() )
102 for(; voh_it.is_valid(); ++voh_it, ++n_voh_it)
104 typename MeshT::Point p1 = _mesh.point(_mesh.to_vertex_handle( *voh_it));
105 typename MeshT::Point p2 = _mesh.point(_mesh.to_vertex_handle( *n_voh_it));
114 template<
class MeshT,
class VectorT,
class REALT>
116 const typename MeshT::VertexHandle& _vh,
123 typename MeshT::ConstVertexOHalfedgeIter voh_it = _m.cvoh_iter(_vh);
125 if ( ! voh_it->is_valid() )
128 for(; voh_it.is_valid(); ++voh_it)
130 if ( _m.is_boundary( _m.edge_handle( *voh_it ) ) )
133 const typename MeshT::Point p0 = _m.point( _vh );
134 const typename MeshT::Point p1 = _m.point( _m.to_vertex_handle( *voh_it));
136 const typename MeshT::Point p2 = _m.point( _m.from_vertex_handle( _m.prev_halfedge_handle( *voh_it)));
137 const typename MeshT::Point p3 = _m.point( _m.to_vertex_handle( _m.next_halfedge_handle( _m.opposite_halfedge_handle(*voh_it))));
139 const REALT alpha = acos(
OpenMesh::sane_aarg((p0-p2).normalize() | (p1-p2).normalize()) );
144 if ( !OpenMesh::is_eq(alpha,M_PI/2.0) )
145 cotw += (REALT(1.0))/tan(alpha);
147 if ( !OpenMesh::is_eq(beta,M_PI/2.0) )
148 cotw += (REALT(1.0))/tan(beta);
165 if ( !OpenMesh::is_eq(alpha,M_PI/2.0) )
166 tmp += (p0-p1).sqrnorm()*1.0/tan(alpha);
168 if ( !OpenMesh::is_eq(gamma,M_PI/2.0) )
169 tmp += (p0-p2).sqrnorm()*1.0/tan(gamma);
179 _area += 0.125*( tmp );
185 _area += ((p1-p0) % (p2-p0)).norm() * 0.5 * 0.5;
189 _area += ((p1-p0) % (p2-p0)).norm() * 0.5 * 0.25;
193 _n += ((p0-p1)*cotw);
void discrete_mean_curv_op(const MeshT &_m, const typename MeshT::VertexHandle &_vh, VectorT &_n, REALT &_area)
T sane_aarg(T _aarg)
Trigonometry/angles - related.
bool is_zero(const T &_a, Real _eps)
int isObtuse(const VectorT &_p0, const VectorT &_p1, const VectorT &_p2)
double gauss_curvature(MeshT &_mesh, const typename MeshT::VertexHandle &_vh)