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
ModEdgeLengthT.cc
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 ModEdgeLengthT - IMPLEMENTATION
55 //
56 //=============================================================================
57 #define OPENMESH_DECIMATER_MODEDGELENGTHT_C
58
59 //== INCLUDES =================================================================
60
61 #include "ModEdgeLengthT.hh"
62
63 //== NAMESPACES ===============================================================
64
65 namespace OpenMesh {
66 namespace Decimater {
67
68 //== IMPLEMENTATION ==========================================================
69
70 template<class MeshT>
71 ModEdgeLengthT<MeshT>::ModEdgeLengthT(MeshT &_mesh, float _edge_length,
72 bool _is_binary) :
73 Base(_mesh, _is_binary), mesh_(Base::mesh()) {
74 set_edge_length(_edge_length);
75 }
76
77 //-----------------------------------------------------------------------------
78
79 template<class MeshT>
80 float ModEdgeLengthT<MeshT>::collapse_priority(const CollapseInfo& _ci) {
81 typename Mesh::Scalar sqr_length = (_ci.p0 - _ci.p1).sqrnorm();
82
83 return ( (sqr_length <= sqr_edge_length_) ? sqr_length : float(Base::ILLEGAL_COLLAPSE));
84 }
85
86 //-----------------------------------------------------------------------------
87
88 template<class MeshT>
89 void ModEdgeLengthT<MeshT>::set_error_tolerance_factor(double _factor) {
90 if (_factor >= 0.0 && _factor <= 1.0) {
91 // the smaller the factor, the smaller edge_length_ gets
92 // thus creating a stricter constraint
93 // division by error_tolerance_factor_ is for normalization
94 float edge_length = edge_length_ * _factor / this->error_tolerance_factor_;
95 set_edge_length(edge_length);
96 this->error_tolerance_factor_ = _factor;
97 }
98 }
99
100 //=============================================================================
101 }
102 }
103 //=============================================================================
ModEdgeLengthT.hh
OpenMesh::Decimater::CollapseInfoT::p1
Mesh::Point p1
Positions of remaining vertex.
Definition: CollapseInfoT.hh:100
OpenMesh
Definition: MeshItems.hh:64
OpenMesh::Decimater::ModEdgeLengthT::ModEdgeLengthT
ModEdgeLengthT(MeshT &_mesh, float _edge_length=FLT_MAX, bool _is_binary=true)
Constructor.
Definition: ModEdgeLengthT.cc:71
OpenMesh::Decimater::CollapseInfoT::p0
Mesh::Point p0
Position of removed vertex.
Definition: CollapseInfoT.hh:99
OpenMesh::Decimater::ModEdgeLengthT::set_error_tolerance_factor
void set_error_tolerance_factor(double _factor)
set the percentage of edge length
Definition: ModEdgeLengthT.cc:89
OpenMesh::Decimater::ModEdgeLengthT::collapse_priority
float collapse_priority(const CollapseInfo &_ci)
Definition: ModEdgeLengthT.cc:80
OpenMesh::Decimater::CollapseInfoT
Definition: CollapseInfoT.hh:80
OpenMesh::PolyMeshT::Scalar
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:113
OpenMesh::Decimater::ModEdgeLengthT::set_edge_length
void set_edge_length(float _f)
set edge_length
Definition: ModEdgeLengthT.hh:97