Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Date$ *
46 * *
47 \*===========================================================================*/
48
52 //=============================================================================
53 //
54 // CLASS ModAspectRatioT
55 //
56 //=============================================================================
57
58 #ifndef OPENMESH_DECIMATER_MODASPECTRATIOT_HH
59 #define OPENMESH_DECIMATER_MODASPECTRATIOT_HH
60
61 //== INCLUDES =================================================================
62
63 #include <OpenMesh/Tools/Decimater/ModBaseT.hh>
64 #include <OpenMesh/Core/Utils/Property.hh>
65
66 //== NAMESPACES ===============================================================
67
68 namespace OpenMesh {
69 namespace Decimater {
70
71 //== CLASS DEFINITION =========================================================
72
86 template<class MeshT>
87 class ModAspectRatioT: public ModBaseT<MeshT> {
88 public:
89
90 DECIMATING_MODULE( ModAspectRatioT, MeshT, AspectRatio )
91 ;
92
93 typedef typename Mesh::Scalar Scalar;
94 typedef typename Mesh::Point Point;
95
97 ModAspectRatioT(MeshT& _mesh, float _min_aspect = 5.0, bool _is_binary =
98 true) :
99 Base(_mesh, _is_binary), mesh_(Base::mesh()), min_aspect_(
100 1.f / _min_aspect) {
101 mesh_.add_property(aspect_);
102 }
103
105 ~ModAspectRatioT() {
106 mesh_.remove_property(aspect_);
107 }
108
110 float aspect_ratio() const {
111 return 1.f / min_aspect_;
112 }
113
115 void set_aspect_ratio(float _f) {
116 min_aspect_ = 1.f / _f;
117 }
118
120 void initialize();
121
123 float collapse_priority(const CollapseInfo& _ci);
124
126 void preprocess_collapse(const CollapseInfo& _ci);
127
129 void set_error_tolerance_factor(double _factor);
130
131 private:
132
136 Scalar aspectRatio(const Point& _v0, const Point& _v1, const Point& _v2);
137
138 private:
139
140 Mesh& mesh_;
141 float min_aspect_;
142 FPropHandleT<float> aspect_;
143 };
144
145 //=============================================================================
146 }// END_NS_DECIMATER
147 } // END_NS_OPENMESH
148 //=============================================================================
149 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_DECIMATER_MODASPECTRATIOT_C)
150 #define OPENMESH_DECIMATER_MODASPECTRATIOT_TEMPLATES
151 #include "ModAspectRatioT.cc"
152 #endif
153 //=============================================================================
154 #endif // OPENMESH_DECIMATER_MODASPECTRATIOT_HH defined
155 //=============================================================================
156
OpenMesh::Decimater::ModAspectRatioT::initialize
void initialize()
precompute face aspect ratio
Definition: ModAspectRatioT.cc:102
DECIMATING_MODULE
#define DECIMATING_MODULE(Classname, MeshT, Name)
Definition: ModBaseT.hh:154
OpenMesh::Decimater::ModAspectRatioT
Use aspect ratio to control decimation.
Definition: ModAspectRatioT.hh:87
OpenMesh
Definition: MeshItems.hh:64
ModAspectRatioT.cc
OpenMesh::PolyMeshT::Point
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
OpenMesh::TriMesh_ArrayKernelT< CustomTraits >
OpenMesh::Decimater::ModAspectRatioT::collapse_priority
float collapse_priority(const CollapseInfo &_ci)
Returns the collapse priority.
Definition: ModAspectRatioT.cc:139
OpenMesh::Decimater::ModAspectRatioT::aspect_ratio
float aspect_ratio() const
get aspect ratio
Definition: ModAspectRatioT.hh:110
OpenMesh::Decimater::ModAspectRatioT::set_aspect_ratio
void set_aspect_ratio(float _f)
set aspect ratio
Definition: ModAspectRatioT.hh:115
OpenMesh::Decimater::ModBaseT
Definition: ModBaseT.hh:197
ModBaseT.hh
OpenMesh::Decimater::ModBaseT::mesh
MeshT & mesh()
Access the mesh associated with the decimater.
Definition: ModBaseT.hh:282
OpenMesh::Decimater::ModAspectRatioT::set_error_tolerance_factor
void set_error_tolerance_factor(double _factor)
set percentage of aspect ratio
Definition: ModAspectRatioT.cc:189
OpenMesh::PolyMeshT::Scalar
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:113
OpenMesh::FPropHandleT< float >
OpenMesh::Decimater::ModAspectRatioT::ModAspectRatioT
ModAspectRatioT(MeshT &_mesh, float _min_aspect=5.0, bool _is_binary=true)
constructor
Definition: ModAspectRatioT.hh:97
OpenMesh::Decimater::ModAspectRatioT::aspectRatio
Scalar aspectRatio(const Point &_v0, const Point &_v1, const Point &_v2)
return aspect ratio (length/height) of triangle
Definition: ModAspectRatioT.cc:71
OpenMesh::Decimater::ModAspectRatioT::~ModAspectRatioT
~ModAspectRatioT()
destructor
Definition: ModAspectRatioT.hh:105
OpenMesh::Decimater::ModAspectRatioT::preprocess_collapse
void preprocess_collapse(const CollapseInfo &_ci)
update aspect ratio of one-ring
Definition: ModAspectRatioT.cc:119