60#ifndef OPENMESH_DECIMATER_MODNORMALFLIPPING_HH
61#define OPENMESH_DECIMATER_MODNORMALFLIPPING_HH
84template <
typename MeshT>
97 const bool mesh_has_normals = _mesh.has_face_normals();
98 _mesh.request_face_normals();
100 if (!mesh_has_normals)
102 omerr() <<
"Mesh has no face normals. Compute them automatically." << std::endl;
103 _mesh.update_face_normals();
110 Base::mesh().release_face_normals();
133 Base::mesh().set_point(_ci.v0, _ci.p1);
140 for (; vf_it.is_valid(); ++vf_it)
143 if (fh != _ci.fl && fh != _ci.fr)
146 typename Mesh::Normal n2 = Base::mesh().calc_face_normal(fh);
156 Base::mesh().set_point(_ci.v0, _ci.p0);
158 return float( (c < min_cos_) ? Base::ILLEGAL_COLLAPSE : Base::LEGAL_COLLAPSE );
163 if (_factor >= 0.0 && _factor <= 1.0) {
167 double max_normal_deviation = (max_deviation_ * 180.0/M_PI) * _factor / this->error_tolerance_factor_;
169 this->error_tolerance_factor_ = _factor;
185 max_deviation_ = _d / 180.0 * M_PI;
186 min_cos_ = cos(max_deviation_);
192 void set_binary(
bool _b) {}
197 double max_deviation_, min_cos_;
Base class for all decimation modules.
#define DECIMATING_MODULE(Classname, MeshT, Name)
Convenience macro, to be used in derived modules The macro defines the types.
Definition: ModBaseT.hh:154
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:181
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:113
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:117
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Definition: PolyMeshT.hh:179
Kernel::FaceHandle FaceHandle
Scalar type.
Definition: PolyMeshT.hh:142
Base class for all decimation modules.
Definition: ModBaseT.hh:198
Decimating module to avoid flipping of faces.
Definition: ModNormalFlippingT.hh:86
double max_normal_deviation() const
get normal deviation
Definition: ModNormalFlippingT.hh:177
ModNormalFlippingT(MeshT &_mesh)
Constructor.
Definition: ModNormalFlippingT.hh:94
void set_error_tolerance_factor(double _factor)
set the percentage of maximum normal deviation
Definition: ModNormalFlippingT.hh:162
void set_max_normal_deviation(double _d)
Set normal deviation.
Definition: ModNormalFlippingT.hh:184
float collapse_priority(const CollapseInfo &_ci)
Compute collapse priority due to angular deviation of face normals before and after a collapse.
Definition: ModNormalFlippingT.hh:130