54 #define OPENMESH_LAPLACE_SMOOTHERT_C
72 LaplaceSmootherT<Mesh>::
73 LaplaceSmootherT(Mesh& _mesh)
74 : SmootherT<Mesh>(_mesh)
77 Base::mesh_.add_property(vertex_weights_);
78 Base::mesh_.add_property(edge_weights_);
86 LaplaceSmootherT<Mesh>::
90 Base::mesh_.remove_property(vertex_weights_);
91 Base::mesh_.remove_property(edge_weights_);
100 LaplaceSmootherT<Mesh>::
101 initialize(Component _comp, Continuity _cont)
103 SmootherT<Mesh>::initialize(_comp, _cont);
108 case Base::Tangential:
109 compute_weights(UniformWeighting);
114 compute_weights(CotWeighting);
118 case Base::Tangential_and_Normal:
119 compute_weights(UniformWeighting);
128 template <
class Mesh>
130 LaplaceSmootherT<Mesh>::
131 compute_weights(LaplaceWeighting _weighting)
133 typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end());
134 typename Mesh::EdgeIter e_it, e_end(Base::mesh_.edges_end());
136 typename Mesh::VertexHandle v0, v1;
138 typename Mesh::Scalar weight, lb(-1.0), ub(1.0);
143 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
144 Base::mesh_.property(vertex_weights_, *v_it) = 0.0;
151 case UniformWeighting:
153 for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
155 heh0 = Base::mesh_.halfedge_handle(*e_it, 0);
156 heh1 = Base::mesh_.halfedge_handle(*e_it, 1);
157 v0 = Base::mesh_.to_vertex_handle(heh0);
158 v1 = Base::mesh_.to_vertex_handle(heh1);
160 Base::mesh_.property(edge_weights_, *e_it) = 1.0;
161 Base::mesh_.property(vertex_weights_, v0) += 1.0;
162 Base::mesh_.property(vertex_weights_, v1) += 1.0;
172 for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
174 const typename Mesh::Point *p0, *p1, *p2;
178 heh0 = Base::mesh_.halfedge_handle(*e_it, 0);
179 v0 = Base::mesh_.to_vertex_handle(heh0);
180 p0 = &Base::mesh_.point(v0);
182 heh1 = Base::mesh_.halfedge_handle(*e_it, 1);
183 v1 = Base::mesh_.to_vertex_handle(heh1);
184 p1 = &Base::mesh_.point(v1);
186 heh2 = Base::mesh_.next_halfedge_handle(heh0);
187 p2 = &Base::mesh_.point(Base::mesh_.to_vertex_handle(heh2));
188 d0 = (*p0 - *p2); d0.normalize();
189 d1 = (*p1 - *p2); d1.normalize();
190 weight +=
static_cast<typename Mesh::Scalar
>(1.0) / tan(acos(std::max(lb, std::min(ub,
dot(d0,d1) ))));
192 heh2 = Base::mesh_.next_halfedge_handle(heh1);
193 p2 = &Base::mesh_.point(Base::mesh_.to_vertex_handle(heh2));
194 d0 = (*p0 - *p2); d0.normalize();
195 d1 = (*p1 - *p2); d1.normalize();
196 weight +=
static_cast<typename Mesh::Scalar
>(1.0) / tan(acos(std::max(lb, std::min(ub,
dot(d0,d1) ))));
198 Base::mesh_.property(edge_weights_, *e_it) = weight;
199 Base::mesh_.property(vertex_weights_, v0) += weight;
200 Base::mesh_.property(vertex_weights_, v1) += weight;
210 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
212 weight = Base::mesh_.property(vertex_weights_, *v_it);
214 Base::mesh_.property(vertex_weights_, *v_it) =
static_cast<typename Mesh::Scalar
>(1.0) / weight;
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
@ Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:82
Scalar dot(const VectorT< Scalar, DIM > &_v1, const VectorT< Scalar, DIM > &_v2)
symmetric version of the dot product
Definition: Vector11T.hh:724
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:114
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition: PolyMeshT.hh:137