| OpenMesh

ModAspectRatioT.hh
Go to the documentation of this file.
1 /* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42
46 //=============================================================================
47 //
48 // CLASS ModAspectRatioT
49 //
50 //=============================================================================
51
52 #ifndef OPENMESH_DECIMATER_MODASPECTRATIOT_HH
53 #define OPENMESH_DECIMATER_MODASPECTRATIOT_HH
54
55 //== INCLUDES =================================================================
56
57 #include <OpenMesh/Tools/Decimater/ModBaseT.hh>
58 #include <OpenMesh/Core/Utils/Property.hh>
59
60 //== NAMESPACES ===============================================================
61
62 namespace OpenMesh {
63 namespace Decimater {
64
65 //== CLASS DEFINITION =========================================================
66
80 template<class MeshT>
81 class ModAspectRatioT: public ModBaseT<MeshT> {
82 public:
83
84 DECIMATING_MODULE( ModAspectRatioT, MeshT, AspectRatio )
85 ;
86
87 typedef typename Mesh::Scalar Scalar;
88 typedef typename Mesh::Point Point;
89
91 ModAspectRatioT(MeshT& _mesh, float _min_aspect = 5.0, bool _is_binary =
92 true) :
93 Base(_mesh, _is_binary), mesh_(Base::mesh()), min_aspect_(
94 1.f / _min_aspect) {
95 mesh_.add_property(aspect_);
96 }
97
99 ~ModAspectRatioT() {
100 mesh_.remove_property(aspect_);
101 }
102
104 float aspect_ratio() const {
105 return 1.f / min_aspect_;
106 }
107
109 void set_aspect_ratio(float _f) {
110 min_aspect_ = 1.f / _f;
111 }
112
114 void initialize() override;
115
117 float collapse_priority(const CollapseInfo& _ci) override;
118
120 void preprocess_collapse(const CollapseInfo& _ci) override;
121
123 void set_error_tolerance_factor(double _factor) override;
124
125 private:
126
130 Scalar aspectRatio(const Point& _v0, const Point& _v1, const Point& _v2);
131
132 private:
133
134 Mesh& mesh_;
135 float min_aspect_;
136 FPropHandleT<float> aspect_;
137 };
138
139 //=============================================================================
140 }// END_NS_DECIMATER
141 } // END_NS_OPENMESH
142 //=============================================================================
143 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_DECIMATER_MODASPECTRATIOT_C)
144 #define OPENMESH_DECIMATER_MODASPECTRATIOT_TEMPLATES
145 #include "ModAspectRatioT_impl.hh"
146 #endif
147 //=============================================================================
148 #endif // OPENMESH_DECIMATER_MODASPECTRATIOT_HH defined
149 //=============================================================================
150
OpenMesh::Decimater::ModAspectRatioT::collapse_priority
float collapse_priority(const CollapseInfo &_ci) override
Returns the collapse priority.
Definition: ModAspectRatioT_impl.hh:133
OpenMesh::FPropHandleT< float >
OpenMesh::Decimater::ModAspectRatioT
Use aspect ratio to control decimation.
Definition: ModAspectRatioT.hh:81
OpenMesh::PolyMeshT::Scalar
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:110
OpenMesh::Decimater::ModAspectRatioT::~ModAspectRatioT
~ModAspectRatioT()
destructor
Definition: ModAspectRatioT.hh:99
OpenMesh::Decimater::ModAspectRatioT::set_error_tolerance_factor
void set_error_tolerance_factor(double _factor) override
set percentage of aspect ratio
Definition: ModAspectRatioT_impl.hh:183
ModBaseT.hh
Base class for all decimation modules.
OpenMesh::Decimater::ModAspectRatioT::set_aspect_ratio
void set_aspect_ratio(float _f)
set aspect ratio
Definition: ModAspectRatioT.hh:109
OpenMesh::Decimater::ModAspectRatioT::ModAspectRatioT
ModAspectRatioT(MeshT &_mesh, float _min_aspect=5.0, bool _is_binary=true)
constructor
Definition: ModAspectRatioT.hh:91
DECIMATING_MODULE
#define DECIMATING_MODULE(Classname, MeshT, Name)
Convenience macro, to be used in derived modules The macro defines the types.
Definition: ModBaseT.hh:149
OpenMesh::Decimater::ModBaseT
Base class for all decimation modules.
Definition: ModBaseT.hh:192
ModAspectRatioT_impl.hh
OpenMesh::Decimater::ModBaseT::mesh
MeshT & mesh()
Access the mesh associated with the decimater.
Definition: ModBaseT.hh:277
OpenMesh::Decimater::ModAspectRatioT::initialize
void initialize() override
precompute face aspect ratio
Definition: ModAspectRatioT_impl.hh:96
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
OpenMesh::Decimater::ModAspectRatioT::aspect_ratio
float aspect_ratio() const
get aspect ratio
Definition: ModAspectRatioT.hh:104
OpenMesh::Decimater::ModAspectRatioT::preprocess_collapse
void preprocess_collapse(const CollapseInfo &_ci) override
update aspect ratio of one-ring
Definition: ModAspectRatioT_impl.hh:113