OpenMesh
ModEdgeLengthT_impl.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 ModEdgeLengthT - IMPLEMENTATION
49 //
50 //=============================================================================
51 #define OPENMESH_DECIMATER_MODEDGELENGTHT_C
52 
53 //== INCLUDES =================================================================
54 
55 #include "ModEdgeLengthT.hh"
56 
57 //== NAMESPACES ===============================================================
58 
59 namespace OpenMesh {
60 namespace Decimater {
61 
62 //== IMPLEMENTATION ==========================================================
63 
64 template<class MeshT>
65 ModEdgeLengthT<MeshT>::ModEdgeLengthT(MeshT &_mesh, float _edge_length,
66  bool _is_binary) :
67  Base(_mesh, _is_binary), mesh_(Base::mesh()) {
68  set_edge_length(_edge_length);
69 }
70 
71 //-----------------------------------------------------------------------------
72 
73 template<class MeshT>
75  typename Mesh::Scalar sqr_length = (_ci.p0 - _ci.p1).sqrnorm();
76 
77  return ( (sqr_length <= sqr_edge_length_) ? sqr_length : float(Base::ILLEGAL_COLLAPSE));
78 }
79 
80 //-----------------------------------------------------------------------------
81 
82 template<class MeshT>
84  if (_factor >= 0.0 && _factor <= 1.0) {
85  // the smaller the factor, the smaller edge_length_ gets
86  // thus creating a stricter constraint
87  // division by error_tolerance_factor_ is for normalization
88  typename Mesh::Scalar edge_length = edge_length_ * static_cast<typename Mesh::Scalar>(_factor / this->error_tolerance_factor_);
89  set_edge_length(edge_length);
90  this->error_tolerance_factor_ = _factor;
91  }
92 }
93 
94 //=============================================================================
95 }
96 }
97 //=============================================================================
void set_edge_length(typename Mesh::Scalar _f)
set edge_length
Definition: ModEdgeLengthT.hh:91
ModEdgeLengthT(MeshT &_mesh, float _edge_length=FLT_MAX, bool _is_binary=true)
Constructor.
Definition: ModEdgeLengthT_impl.hh:65
void set_error_tolerance_factor(double _factor) override
set the percentage of edge length
Definition: ModEdgeLengthT_impl.hh:83
Mesh::Point p0
Position of removed vertex.
Definition: CollapseInfoT.hh:93
float edge_length() const
get edge_length
Definition: ModEdgeLengthT.hh:86
Mesh::Point p1
Positions of remaining vertex.
Definition: CollapseInfoT.hh:94
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
float collapse_priority(const CollapseInfo &_ci) override
Compute priority: Binary mode: Don&#39;t collapse edges longer then edge_length_ Cont.
Definition: ModEdgeLengthT_impl.hh:74
Stores information about a halfedge collapse.
Definition: CollapseInfoT.hh:74

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .