53 #ifndef OPENMESH_DECIMATER_MODNORMALDEVIATIONT_HH 
   54 #define OPENMESH_DECIMATER_MODNORMALDEVIATIONT_HH 
   60 #include <OpenMesh/Core/Utils/Property.hh> 
   61 #include <OpenMesh/Core/Geometry/NormalConeT.hh> 
   87 template <
class MeshT>
 
  108   : Base(_mesh, true), mesh_(Base::
mesh())
 
  111     mesh_.add_property(normal_cones_);
 
  113     const bool mesh_has_normals = _mesh.has_face_normals();
 
  114     _mesh.request_face_normals();
 
  116     if (!mesh_has_normals)
 
  118       omerr() << 
"Mesh has no face normals. Compute them automatically." << std::endl;
 
  119       _mesh.update_face_normals();
 
  126     mesh_.remove_property(normal_cones_);
 
  127     mesh_.release_face_normals();
 
  133     return normal_deviation_ / M_PI * 180.0;
 
  138     normal_deviation_ = _s / 
static_cast<Scalar
>(180.0) * 
static_cast<Scalar
>(M_PI);
 
  144     if (!normal_cones_.is_valid())
 
  145       mesh_.add_property(normal_cones_);
 
  148         f_end = mesh_.faces_end();
 
  150     for (; f_it != f_end; ++f_it)
 
  151       mesh_.property(normal_cones_, *f_it) = 
NormalCone(mesh_.normal(*f_it));
 
  170     mesh_.set_point(_ci.
v0, _ci.
p1);
 
  177     if (_ci.v0vl.is_valid())  fhl = mesh_.face_handle(_ci.v0vl);
 
  178     if (_ci.vrv0.is_valid())  fhr = mesh_.face_handle(_ci.vrv0);
 
  180     for (; vf_it.is_valid(); ++vf_it) {
 
  182       if (fh != _ci.
fl && fh != _ci.
fr) {
 
  183         NormalCone nc = mesh_.property(normal_cones_, fh);
 
  186         if (fh == fhl) nc.
merge(mesh_.property(normal_cones_, _ci.
fl));
 
  187         if (fh == fhr) nc.
merge(mesh_.property(normal_cones_, _ci.
fr));
 
  189         if (nc.
angle() > max_angle) {
 
  190           max_angle = nc.
angle();
 
  191           if (max_angle > 0.5 * normal_deviation_)
 
  199     mesh_.set_point(_ci.
v0, _ci.
p0);
 
  202     return (max_angle < 0.5 * normal_deviation_ ? max_angle : 
float( Base::ILLEGAL_COLLAPSE ));
 
  207     if (_factor >= 0.0 && _factor <= 1.0) {
 
  211       Scalar normal_deviation_value = normal_deviation_ *  
static_cast<Scalar
>(  180.0 / M_PI * _factor / this->error_tolerance_factor_);
 
  214       this->error_tolerance_factor_ = _factor;
 
  222     for (; vf_it.is_valid(); ++vf_it)
 
  223       mesh_.property(normal_cones_, *vf_it).
 
  230     if (_ci.
vlv1.is_valid()) {
 
  231       fh = mesh_.face_handle(mesh_.opposite_halfedge_handle(_ci.
vlv1));
 
  233         mesh_.property(normal_cones_, fh).
 
  234         merge(mesh_.property(normal_cones_, _ci.
fl));
 
  237     if (_ci.v1vr.is_valid()) {
 
  238       fh = mesh_.face_handle(mesh_.opposite_halfedge_handle(_ci.v1vr));
 
  240         mesh_.property(normal_cones_, fh).
 
  241         merge(mesh_.property(normal_cones_, _ci.
fr));
 
  250   Scalar                              normal_deviation_;
 
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:149
 
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
 
/class NormalCone NormalCone.hh <OpenMesh/Core/Geometry/NormalConeT.hh>
Definition: NormalConeT.hh:78
 
void merge(const NormalConeT &)
merge _cone; this instance will then enclose both former cones
Definition: NormalConeT_impl.hh:118
 
Scalar angle() const
returns size of cone (radius in radians)
Definition: NormalConeT.hh:105
 
Polygonal mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:96
 
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
 
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:110
 
Kernel::EdgeHandle EdgeHandle
Scalar type.
Definition: PolyMeshT.hh:138
 
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Definition: PolyMeshT.hh:166
 
Kernel::FaceIter FaceIter
Scalar type.
Definition: PolyMeshT.hh:146
 
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:114
 
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Definition: PolyMeshT.hh:176
 
Kernel::FaceHandle FaceHandle
Scalar type.
Definition: PolyMeshT.hh:139
 
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:112
 
Handle representing a face property.
Definition: Property.hh:462
 
Stores information about a halfedge collapse.
Definition: CollapseInfoT.hh:74
 
Mesh::HalfedgeHandle vlv1
Outer remaining halfedge of diamond spanned by v0, v1, vl, and vr.
Definition: CollapseInfoT.hh:94
 
Mesh::FaceHandle fr
Right face.
Definition: CollapseInfoT.hh:87
 
Mesh::Point p0
Position of removed vertex.
Definition: CollapseInfoT.hh:84
 
Mesh::VertexHandle v1
Remaining vertex.
Definition: CollapseInfoT.hh:83
 
Mesh::Point p1
Positions of remaining vertex.
Definition: CollapseInfoT.hh:85
 
Mesh::VertexHandle v0
Vertex to be removed.
Definition: CollapseInfoT.hh:82
 
Mesh::FaceHandle fl
Left face.
Definition: CollapseInfoT.hh:86
 
Base class for all decimation modules.
Definition: ModBaseT.hh:193
 
MeshT & mesh()
Access the mesh associated with the decimater.
Definition: ModBaseT.hh:277
 
Use Normal deviation to control decimation.
Definition: ModNormalDeviationT.hh:89
 
void postprocess_collapse(const CollapseInfo &_ci) override
After _from_vh has been collapsed into _to_vh, this method will be called.
Definition: ModNormalDeviationT.hh:219
 
void set_normal_deviation(Scalar _s)
Set normal deviation ( 0 .. 360 )
Definition: ModNormalDeviationT.hh:137
 
Scalar normal_deviation() const
Get normal deviation ( 0 .. 360 )
Definition: ModNormalDeviationT.hh:132
 
void set_error_tolerance_factor(double _factor) override
set the percentage of normal deviation
Definition: ModNormalDeviationT.hh:206
 
void initialize() override
Allocate and init normal cones.
Definition: ModNormalDeviationT.hh:143
 
~ModNormalDeviationT()
Destructor.
Definition: ModNormalDeviationT.hh:125
 
ModNormalDeviationT(MeshT &_mesh, float _max_dev=180.0)
Constructor.
Definition: ModNormalDeviationT.hh:107
 
float collapse_priority(const CollapseInfo &_ci) override
Control normals when Decimating.
Definition: ModNormalDeviationT.hh:168