59 #define OPENMESH_DECIMATER_MODQUADRIC_CC
75 template<
class DecimaterType>
82 if (!quadrics_.is_valid())
83 Base::mesh().add_property( quadrics_ );
86 typename Mesh::VertexIter v_it = Base::mesh().vertices_begin(),
87 v_end = Base::mesh().vertices_end();
89 for (; v_it != v_end; ++v_it)
90 Base::mesh().property(quadrics_, *v_it).
clear();
93 typename Mesh::FaceIter f_it = Base::mesh().faces_begin(),
94 f_end = Base::mesh().faces_end();
100 for (; f_it != f_end; ++f_it)
102 fv_it = Base::mesh().fv_iter(*f_it);
103 vh0 = *fv_it; ++fv_it;
104 vh1 = *fv_it; ++fv_it;
116 Vec3 n = (v1-v0) % (v2-v0);
117 double area = n.norm();
124 const double a = n[0];
125 const double b = n[1];
126 const double c = n[2];
127 const double d = -(
vector_cast<Vec3>(Base::mesh().point(vh0))|n);
129 Quadricd q(a, b, c, d);
132 Base::mesh().property(quadrics_, vh0) += q;
133 Base::mesh().property(quadrics_, vh1) += q;
134 Base::mesh().property(quadrics_, vh2) += q;
140 template<
class MeshT>
142 if (this->is_binary()) {
143 if (_factor >= 0.0 && _factor <= 1.0) {
147 double max_err = max_err_ * _factor / this->error_tolerance_factor_;
148 set_max_err(max_err);
149 this->error_tolerance_factor_ = _factor;
virtual void initialize(void)
Initalize the module and prepare the mesh for decimation.
void vector_cast(const src_t &_src, dst_t &_dst, GenProg::Int2Type< n >)
Cast vector type to another vector type by copying the vector elements.
void clear()
set all entries to zero
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::FaceVertexIter FaceVertexIter
Circulator.
void set_error_tolerance_factor(double _factor)
set the percentage of maximum quadric error