54 #ifndef OPENMESH_DECIMATER_MODROUNDNESST_HH 55 #define OPENMESH_DECIMATER_MODROUNDNESST_HH 63 #if defined(OM_CC_MSVC) 64 # define OM_ENABLE_WARNINGS 4244 65 # pragma warning(disable : OM_ENABLE_WARNINGS ) 85 template <
class MeshT>
94 typedef typename MeshT::Point Point;
126 double priority = 0.0;
127 typename Mesh::FaceHandle fhC, fhB;
132 C =
vector_cast<
Vec3f>(Base::mesh().point( Base::mesh().to_vertex_handle(*voh_it)));
133 fhC = Base::mesh().face_handle( *voh_it );
135 for (++voh_it; voh_it.is_valid(); ++voh_it)
139 C =
vector_cast<
Vec3f>(Base::mesh().point(Base::mesh().to_vertex_handle(*voh_it)));
140 fhC = Base::mesh().face_handle( *voh_it );
142 if ( fhB == _ci.
fl || fhB == _ci.
fr )
146 r = roundness( vector_cast<Vec3f>(_ci.
p1), B, C );
149 priority = std::max( priority, (1.0-r) );
155 C =
vector_cast<
Vec3f>(Base::mesh().point( Base::mesh().to_vertex_handle(*voh_it)));
156 fhC = Base::mesh().face_handle( *voh_it );
158 for (++voh_it; voh_it.is_valid() && (priority==Base::LEGAL_COLLAPSE); ++voh_it)
162 C =
vector_cast<
Vec3f>(Base::mesh().point(Base::mesh().to_vertex_handle(*voh_it)));
163 fhC = Base::mesh().face_handle( *voh_it );
165 if ( fhB == _ci.
fl || fhB == _ci.
fr )
168 priority = ( (r=roundness( vector_cast<Vec3f>(_ci.
p1), B, C )) < min_r_)
169 ? Base::ILLEGAL_COLLAPSE : Base::LEGAL_COLLAPSE;
173 return (
float) priority;
179 if (_factor >= 0.0 && _factor <= 1.0) {
183 value_type min_roundness = min_r_ *
static_cast<value_type
>(_factor / this->error_tolerance_factor_);
185 this->error_tolerance_factor_ = _factor;
193 void set_min_angle(
float _angle,
bool )
195 assert( _angle > 0 && _angle < 60 );
197 _angle = float(M_PI * _angle /180.0);
201 A =
Vec3f( 0.0f, 0.0f, 0.0f);
202 B =
Vec3f( 2.0f * cos(_angle), 0.0f, 0.0f);
203 C =
Vec3f( cos(_angle), sin(_angle), 0.0f);
205 double r1 = roundness(A,B,C);
207 _angle = float(0.5 * ( M_PI - _angle ));
209 A =
Vec3f( 0.0f, 0.0f, 0.0f);
210 B =
Vec3f( 2.0f*cos(_angle), 0.0f, 0.0f);
211 C =
Vec3f( cos(_angle), sin(_angle), 0.0f);
213 double r2 = roundness(A,B,C);
227 assert( 0.0 <= _min_roundness && _min_roundness <= 1.0 );
228 min_r_ = _min_roundness;
229 Base::set_binary(_binary);
236 Base::set_binary(
false);
282 const value_type epsilon = value_type(1e-15);
284 static const value_type sqrt43 = value_type(sqrt(4.0/3.0));
290 value_type aa = (B-C).sqrnorm();
291 value_type bb = vecAC.
sqrnorm();
292 value_type cc = vecAB.
sqrnorm();
293 value_type AA =
cross(vecAC,vecAB).sqrnorm();
298 double nom = AA * std::min( std::min(aa,bb),cc );
299 double denom = aa * bb * cc;
300 double nR = sqrt43 * sqrt(nom/denom);
315 #if defined(OM_CC_MSVC) && defined(OM_ENABLE_WARNINGS) 316 # pragma warning(default : OM_ENABLE_WARNINGS) 317 # undef OM_ENABLE_WARNINGS 320 #endif // OPENMESH_DECIMATER_MODROUNDNESST_HH defined Mesh::Point p1
Positions of remaining vertex.
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.
Mesh::FaceHandle fl
Left face.
osg::Vec3f cross(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
void set_min_roundness(value_type _min_roundness, bool _binary=true)
Mesh::FaceHandle fr
Right face.
float collapse_priority(const CollapseInfo &_ci) override
void unset_min_roundness()
Unset minimum value constraint and enable non-binary mode.
void set_error_tolerance_factor(double _factor) override
set the percentage of minimum roundness
VectorT< float, 3 > Vec3f
Use Roundness of triangles to control decimation.
bool is_binary(void) const
Returns true if criteria returns a binary value.
Mesh::VertexHandle v0
Vertex to be removed.
ModRoundnessT(MeshT &_dec)
Constructor.
~ModRoundnessT()
Destructor.
decltype(std::declval< S >() *std::declval< S >()) sqrnorm() const
compute squared euclidean norm
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.