59 #define OPENMESH_LAPLACE_SMOOTHERT_C 77 LaplaceSmootherT<Mesh>::
78 LaplaceSmootherT(
Mesh& _mesh)
79 : SmootherT<
Mesh>(_mesh)
82 Base::mesh_.add_property(vertex_weights_);
83 Base::mesh_.add_property(edge_weights_);
91 LaplaceSmootherT<Mesh>::
95 Base::mesh_.remove_property(vertex_weights_);
96 Base::mesh_.remove_property(edge_weights_);
103 template <
class Mesh>
105 LaplaceSmootherT<Mesh>::
106 initialize(Component _comp, Continuity _cont)
114 compute_weights(UniformWeighting);
119 compute_weights(CotWeighting);
124 compute_weights(UniformWeighting);
133 template <
class Mesh>
135 LaplaceSmootherT<Mesh>::
136 compute_weights(LaplaceWeighting _weighting)
138 typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end());
139 typename Mesh::EdgeIter e_it, e_end(Base::mesh_.edges_end());
140 typename Mesh::HalfedgeHandle heh0, heh1, heh2;
149 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
150 Base::mesh_.property(vertex_weights_, *v_it) = 0.0;
157 case UniformWeighting:
159 for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
161 heh0 = Base::mesh_.halfedge_handle(*e_it, 0);
162 heh1 = Base::mesh_.halfedge_handle(*e_it, 1);
163 v0 = Base::mesh_.to_vertex_handle(heh0);
164 v1 = Base::mesh_.to_vertex_handle(heh1);
166 Base::mesh_.property(edge_weights_, *e_it) = 1.0;
167 Base::mesh_.property(vertex_weights_, v0) += 1.0;
168 Base::mesh_.property(vertex_weights_, v1) += 1.0;
178 for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
182 heh0 = Base::mesh_.halfedge_handle(*e_it, 0);
183 v0 = Base::mesh_.to_vertex_handle(heh0);
184 p0 = &Base::mesh_.point(v0);
186 heh1 = Base::mesh_.halfedge_handle(*e_it, 1);
187 v1 = Base::mesh_.to_vertex_handle(heh1);
188 p1 = &Base::mesh_.point(v1);
190 heh2 = Base::mesh_.next_halfedge_handle(heh0);
191 p2 = &Base::mesh_.point(Base::mesh_.to_vertex_handle(heh2));
192 d0 = (*p0 - *p2); d0.normalize();
193 d1 = (*p1 - *p2); d1.normalize();
194 weight +=
static_cast<typename
Mesh::Scalar>(1.0) / tan(acos(std::max(lb, std::min(ub,
dot(d0,d1) ))));
196 heh2 = Base::mesh_.next_halfedge_handle(heh1);
197 p2 = &Base::mesh_.point(Base::mesh_.to_vertex_handle(heh2));
198 d0 = (*p0 - *p2); d0.normalize();
199 d1 = (*p1 - *p2); d1.normalize();
200 weight +=
static_cast<typename
Mesh::Scalar>(1.0) / tan(acos(std::max(lb, std::min(ub,
dot(d0,d1) ))));
202 Base::mesh_.property(edge_weights_, *e_it) = weight;
203 Base::mesh_.property(vertex_weights_, v0) += weight;
204 Base::mesh_.property(vertex_weights_, v1) += weight;
214 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
216 weight = Base::mesh_.property(vertex_weights_, *v_it);
218 Base::mesh_.property(vertex_weights_, *v_it) =
static_cast<typename
Mesh::Scalar>(1.0) / weight;
Kernel::Normal Normal
Normal type.
Smooth tangential and normal direction.
Smooth tangential direction.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Kernel::Point Point
Coordinate type.
void initialize(Component _comp, Continuity _cont)
Kernel::Scalar Scalar
Scalar type.