decimation_modules.hpp
Go to the documentation of this file.
00001 
00063 using namespace OpenMesh;
00064 using namespace Decimator;
00065 
00066 template<typename MeshT>
00067 void ModNormalQuadricT<MeshT>::initialize()
00068 {
00069   /*
00070   using OpenMesh::Geometry::Quadricd;
00071   if (!quadrics_.is_valid())
00072     Base::mesh().add_property( quadrics_ );
00073 
00074   typename MeshT::VertexIter v_it  = Base::mesh().vertices_begin();
00075   typename MeshT::VertexIter v_end = Base::mesh().vertices_end();
00076 
00077   for (; v_it!=v_end; ++v_it)
00078   {
00079     Vec4f p = Base::mesh().property(normals_, v_it);
00080     //std::cout << p << std::endl;
00081     Base::mesh().property(quadrics_, v_it)
00082       = Quadricd(p[0], p[1], p[2], p[3]);
00083   }
00084   */
00085 
00086   using OpenMesh::Geometry::Quadricd;
00087   if (!quadrics_.is_valid())
00088     Base::mesh().add_property( quadrics_ );
00089 
00090   typename Mesh::VertexIter v_it  = Base::mesh().vertices_begin();
00091   typename Mesh::VertexIter v_end = Base::mesh().vertices_end();
00092 
00093   for (; v_it!=v_end; ++v_it)
00094     Base::mesh().property(quadrics_, v_it).clear();
00095 
00096   typename Mesh::FaceIter f_it  = Base::mesh().faces_begin();
00097   typename Mesh::FaceIter f_end = Base::mesh().faces_end();
00098   typename Mesh::FaceVertexIter fv_it;
00099   typename Mesh::VertexHandle vh0, vh1, vh2;
00100   Vec4f n;
00101 
00102   for (; f_it!=f_end; ++f_it)
00103   {
00104     fv_it = Base::mesh().fv_iter(f_it.handle());
00105     for (int i=0; i<3; ++i, ++fv_it)
00106     {
00107       vh0 = fv_it.handle();
00108       n = Base::mesh().property(normals_, vh0);
00109       Base::mesh().property(quadrics_, vh0) += Quadricd(n);
00110     }
00111 
00112     /*
00113     vh0 = fv_it.handle(); ++fv_it;
00114     vh1 = fv_it.handle(); ++fv_it;
00115     vh2 = fv_it.handle();
00116 
00117     n1 = Base::mesh().property(normals_, vh0);
00118     n2 = Base::mesh().property(normals_, vh1);
00119     n3 = Base::mesh().property(normals_, vh2);
00120 
00121     Quadricd q1(n1);
00122     Quadricd q2(n2);
00123     Quadricd q3(n3);
00124 
00125     Base::mesh().property(quadrics_, vh0) += q1;
00126     Base::mesh().property(quadrics_, vh1) += q2;
00127     Base::mesh().property(quadrics_, vh2) += q3;
00128     */
00129   }
00130 }
00131 
00132 template<typename MeshT>
00133 void ModNormalQuadricT<MeshT>::set_error_tolerance_factor(double _factor)
00134 {
00135   if (this->is_binary()) {
00136     if (_factor >= 0.0 && _factor <= 1.0) {
00137       // the smaller the factor, the smaller max_err_ gets
00138       // thus creating a stricter constraint
00139       // division by error_tolerance_factor_ is for normalization
00140       double max_err = max_err_ * _factor / this->error_tolerance_factor_;
00141       set_max_err(max_err);
00142       this->error_tolerance_factor_ = _factor;
00143 
00144       initialize();
00145     }
00146   }
00147 }
00148 
00149 }
00150 }
00151 


cob_3d_meshing
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:03