53 #ifndef OPENMESH_DECIMATER_MODNORMALFLIPPING_HH
54 #define OPENMESH_DECIMATER_MODNORMALFLIPPING_HH
77 template <
typename MeshT>
90 const bool mesh_has_normals = _mesh.has_face_normals();
91 _mesh.request_face_normals();
93 if (!mesh_has_normals)
95 std::cerr <<
"Mesh has no face normals. Compute them automatically." << std::endl;
96 _mesh.update_face_normals();
103 Base::mesh().release_face_normals();
126 Base::mesh().set_point(_ci.
v0, _ci.
p1);
129 typename Mesh::ConstVertexFaceIter vf_it(Base::mesh(), _ci.
v0);
130 typename Mesh::FaceHandle fh;
131 typename Mesh::Scalar c(1.0);
133 for (; vf_it.is_valid(); ++vf_it)
136 if (fh != _ci.
fl && fh != _ci.
fr)
139 typename Mesh::Normal n2 = Base::mesh().calc_face_normal(fh);
149 Base::mesh().set_point(_ci.
v0, _ci.
p0);
151 return float( (c < min_cos_) ? Base::ILLEGAL_COLLAPSE : Base::LEGAL_COLLAPSE );
156 if (_factor >= 0.0 && _factor <= 1.0) {
160 double max_normal_deviation = (max_deviation_ * 180.0/M_PI) * _factor / this->error_tolerance_factor_;
162 this->error_tolerance_factor_ = _factor;
178 max_deviation_ = _d / 180.0 * M_PI;
179 min_cos_ = cos(max_deviation_);
185 void set_binary(
bool _b) {}
190 double max_deviation_, min_cos_;
198 #endif // OPENACG_MODNORMALFLIPPING_HH defined
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:80
Decimating module to avoid flipping of faces.
Definition: ModNormalFlippingT.hh:78
Mesh::Point p1
Positions of remaining vertex.
Definition: CollapseInfoT.hh:93
Mesh::FaceHandle fl
Left face.
Definition: CollapseInfoT.hh:94
double max_normal_deviation() const
get normal deviation
Definition: ModNormalFlippingT.hh:170
#define DECIMATING_MODULE(Classname, MeshT, Name)
Convenience macro, to be used in derived modules The macro defines the types.
Definition: ModBaseT.hh:147
void set_error_tolerance_factor(double _factor)
set the percentage of maximum normal deviation
Definition: ModNormalFlippingT.hh:155
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:174
Mesh::VertexHandle v0
Vertex to be removed.
Definition: CollapseInfoT.hh:90
void set_max_normal_deviation(double _d)
Set normal deviation.
Definition: ModNormalFlippingT.hh:177
Base class for all decimation modules.
float collapse_priority(const CollapseInfo &_ci)
Compute collapse priority due to angular deviation of face normals before and after a collapse...
Definition: ModNormalFlippingT.hh:123
Base class for all decimation modules.
Definition: ModBaseT.hh:190
Stores information about a halfedge collapse.
Definition: CollapseInfoT.hh:73
Mesh::Point p0
Position of removed vertex.
Definition: CollapseInfoT.hh:92
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
Mesh::FaceHandle fr
Right face.
Definition: CollapseInfoT.hh:95
ModNormalFlippingT(MeshT &_mesh)
Constructor.
Definition: ModNormalFlippingT.hh:87