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)
109 compute_weights(UniformWeighting);
114 compute_weights(CotWeighting);
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());
135 typename Mesh::HalfedgeHandle heh0, heh1, heh2;
144 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
145 Base::mesh_.property(vertex_weights_, *v_it) = 0.0;
152 case UniformWeighting:
154 for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
156 heh0 = Base::mesh_.halfedge_handle(*e_it, 0);
157 heh1 = Base::mesh_.halfedge_handle(*e_it, 1);
158 v0 = Base::mesh_.to_vertex_handle(heh0);
159 v1 = Base::mesh_.to_vertex_handle(heh1);
161 Base::mesh_.property(edge_weights_, *e_it) = 1.0;
162 Base::mesh_.property(vertex_weights_, v0) += 1.0;
163 Base::mesh_.property(vertex_weights_, v1) += 1.0;
173 for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
177 heh0 = Base::mesh_.halfedge_handle(*e_it, 0);
178 v0 = Base::mesh_.to_vertex_handle(heh0);
179 p0 = &Base::mesh_.point(v0);
181 heh1 = Base::mesh_.halfedge_handle(*e_it, 1);
182 v1 = Base::mesh_.to_vertex_handle(heh1);
183 p1 = &Base::mesh_.point(v1);
185 heh2 = Base::mesh_.next_halfedge_handle(heh0);
186 p2 = &Base::mesh_.point(Base::mesh_.to_vertex_handle(heh2));
187 d0 = (*p0 - *p2); d0.normalize();
188 d1 = (*p1 - *p2); d1.normalize();
189 weight +=
static_cast<typename
Mesh::Scalar>(1.0) / tan(acos(std::max(lb, std::min(ub,
dot(d0,d1) ))));
191 heh2 = Base::mesh_.next_halfedge_handle(heh1);
192 p2 = &Base::mesh_.point(Base::mesh_.to_vertex_handle(heh2));
193 d0 = (*p0 - *p2); d0.normalize();
194 d1 = (*p1 - *p2); d1.normalize();
195 weight +=
static_cast<typename
Mesh::Scalar>(1.0) / tan(acos(std::max(lb, std::min(ub,
dot(d0,d1) ))));
197 Base::mesh_.property(edge_weights_, *e_it) = weight;
198 Base::mesh_.property(vertex_weights_, v0) += weight;
199 Base::mesh_.property(vertex_weights_, v1) += weight;
209 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
211 weight = Base::mesh_.property(vertex_weights_, *v_it);
213 Base::mesh_.property(vertex_weights_, *v_it) =
static_cast<typename
Mesh::Scalar>(1.0) / weight;
Kernel::Point Point
Coordinate type.
Kernel::Scalar Scalar
Scalar type.
void initialize(Component _comp, Continuity _cont)
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Smooth tangential direction.
Kernel::Normal Normal
Normal type.
Smooth tangential and normal direction.