00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00046
00047
00048
00049
00050
00051
00052 #define OPENMESH_JACOBI_LAPLACE_SMOOTHERT_C
00053
00054
00055
00056 #include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>
00057
00058
00059
00060
00061
00062 namespace OpenMesh {
00063 namespace Smoother {
00064
00065
00066
00067
00068
00069 template <class Mesh>
00070 void
00071 JacobiLaplaceSmootherT<Mesh>::
00072 smooth(unsigned int _n)
00073 {
00074 if (Base::continuity() > Base::C0)
00075 {
00076 Base::mesh_.add_property(umbrellas_);
00077 if (Base::continuity() > Base::C1)
00078 Base::mesh_.add_property(squared_umbrellas_);
00079 }
00080
00081 LaplaceSmootherT<Mesh>::smooth(_n);
00082
00083 if (Base::continuity() > Base::C0)
00084 {
00085 Base::mesh_.remove_property(umbrellas_);
00086 if (Base::continuity() > Base::C1)
00087 Base::mesh_.remove_property(squared_umbrellas_);
00088 }
00089 }
00090
00091
00092
00093
00094
00095 template <class Mesh>
00096 void
00097 JacobiLaplaceSmootherT<Mesh>::
00098 compute_new_positions_C0()
00099 {
00100 typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end());
00101 typename Mesh::CVVIter vv_it;
00102 typename Mesh::Normal u, p, zero(0,0,0);
00103 typename Mesh::Scalar w;
00104
00105 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
00106 {
00107 if (is_active(v_it))
00108 {
00109
00110 u = zero;
00111 for (vv_it=Base::mesh_.cvv_iter(v_it); vv_it; ++vv_it)
00112 {
00113 w = weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle()));
00114 u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(vv_it)) * w;
00115 }
00116 u *= weight(v_it);
00117 u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(v_it));
00118
00119
00120 u *= 0.5;
00121
00122
00123 p = vector_cast<typename Mesh::Normal>(Base::mesh_.point(v_it));
00124 p += u;
00125 set_new_position(v_it, p);
00126 }
00127 }
00128 }
00129
00130
00131
00132
00133
00134 template <class Mesh>
00135 void
00136 JacobiLaplaceSmootherT<Mesh>::
00137 compute_new_positions_C1()
00138 {
00139 typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end());
00140 typename Mesh::CVVIter vv_it;
00141 typename Mesh::Normal u, uu, p, zero(0,0,0);
00142 typename Mesh::Scalar w, diag;
00143
00144
00145
00146 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
00147 {
00148 u = zero;
00149 for (vv_it=Base::mesh_.cvv_iter(v_it); vv_it; ++vv_it)
00150 {
00151 w = weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle()));
00152 u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(vv_it))*w;
00153 }
00154 u *= weight(v_it);
00155 u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(v_it));
00156
00157 Base::mesh_.property(umbrellas_, v_it) = u;
00158 }
00159
00160
00161
00162 for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
00163 {
00164 if (is_active(v_it))
00165 {
00166 uu = zero;
00167 diag = 0.0;
00168 for (vv_it=Base::mesh_.cvv_iter(v_it); vv_it; ++vv_it)
00169 {
00170 w = weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle()));
00171 uu -= Base::mesh_.property(umbrellas_, vv_it);
00172 diag += (w * weight(vv_it) + 1.0) * w;
00173 }
00174 uu *= weight(v_it);
00175 diag *= weight(v_it);
00176 uu += Base::mesh_.property(umbrellas_, v_it);
00177 if (diag) uu *= 1.0/diag;
00178
00179
00180 uu *= 0.25;
00181
00182
00183 p = vector_cast<typename Mesh::Normal>(Base::mesh_.point(v_it));
00184 p -= uu;
00185 set_new_position(v_it, p);
00186 }
00187 }
00188 }
00189
00190
00191
00192 }
00193 }
00194