63 #include <ACG/Geometry/Algorithms.hh> 64 #include "Math_Tools/Math_Tools.hh" 67 #include <OpenMesh/Core/Geometry/MathDefs.hh> 79 template<
typename MeshT >
81 gauss_curvature(MeshT& _mesh,
const typename MeshT::VertexHandle& _vh) {
82 if (_mesh.status(_vh).deleted())
85 double gauss_curv = 2.0 * M_PI;
97 const typename MeshT::Point p0 = _mesh.point(_vh);
99 typename MeshT::CVOHIter voh_it( _mesh.cvoh_iter(_vh));
100 typename MeshT::CVOHIter n_voh_it = voh_it;
102 if ( ! voh_it->is_valid() )
108 for(; voh_it.is_valid(); ++voh_it, ++n_voh_it)
110 typename MeshT::Point p1 = _mesh.point(_mesh.to_vertex_handle( *voh_it));
111 typename MeshT::Point p2 = _mesh.point(_mesh.to_vertex_handle( *n_voh_it));
120 template<
class MeshT,
class VectorT,
class REALT>
121 void discrete_mean_curv_op(
const MeshT& _m,
122 const typename MeshT::VertexHandle& _vh,
129 typename MeshT::ConstVertexOHalfedgeIter voh_it = _m.cvoh_iter(_vh);
131 if ( ! voh_it->is_valid() )
134 for(; voh_it.is_valid(); ++voh_it)
136 if ( _m.is_boundary( _m.edge_handle( *voh_it ) ) )
139 const typename MeshT::Point p0 = _m.point( _vh );
140 const typename MeshT::Point p1 = _m.point( _m.to_vertex_handle( *voh_it));
142 const typename MeshT::Point p2 = _m.point( _m.from_vertex_handle( _m.prev_halfedge_handle( *voh_it)));
143 const typename MeshT::Point p3 = _m.point( _m.to_vertex_handle( _m.next_halfedge_handle( _m.opposite_halfedge_handle(*voh_it))));
145 const REALT alpha = acos(
OpenMesh::sane_aarg((p0-p2).normalize() | (p1-p2).normalize()) );
150 if ( !OpenMesh::is_eq(alpha,M_PI/2.0) )
151 cotw += (REALT(1.0))/tan(alpha);
153 if ( !OpenMesh::is_eq(beta,M_PI/2.0) )
154 cotw += (REALT(1.0))/tan(beta);
171 if ( !OpenMesh::is_eq(alpha,M_PI/2.0) )
172 tmp += (p0-p1).sqrnorm()*1.0/tan(alpha);
174 if ( !OpenMesh::is_eq(gamma,M_PI/2.0) )
175 tmp += (p0-p2).sqrnorm()*1.0/tan(gamma);
185 _area += 0.125*( tmp );
191 _area += ((p1-p0) % (p2-p0)).norm() * 0.5 * 0.5;
195 _area += ((p1-p0) % (p2-p0)).norm() * 0.5 * 0.25;
199 _n += ((p0-p1)*cotw);
T sane_aarg(T _aarg)
Trigonometry/angles - related.
int isObtuse(const VectorT &_p0, const VectorT &_p1, const VectorT &_p2)
bool is_zero(const T &_a, Real _eps)