Developer Documentation
Loading...
Searching...
No Matches
ModEdgeLengthT_impl.hh
Go to the documentation of this file.
1
/* ========================================================================= *
2
* *
3
* OpenMesh *
4
* Copyright (c) 2001-2025, 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>
74
float
ModEdgeLengthT<MeshT>::collapse_priority
(
const
CollapseInfo
& _ci) {
75
typename
Mesh::Scalar
sqr_length = sqrnorm(_ci.
p0
- _ci.
p1
);
76
77
return
( (sqr_length <= sqr_edge_length_) ? sqr_length : float(Base::ILLEGAL_COLLAPSE));
78
}
79
80
//-----------------------------------------------------------------------------
81
82
template
<
class
MeshT>
83
void
ModEdgeLengthT<MeshT>::set_error_tolerance_factor
(
double
_factor) {
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
new_edge_length = edge_length_ *
static_cast<
typename
Mesh::Scalar
>
(_factor / this->error_tolerance_factor_);
89
set_edge_length(new_edge_length);
90
this->error_tolerance_factor_ = _factor;
91
}
92
}
93
94
//=============================================================================
95
}
96
}
97
//=============================================================================
ModEdgeLengthT.hh
OpenMesh::Decimater::ModEdgeLengthT::set_error_tolerance_factor
void set_error_tolerance_factor(double _factor) override
set the percentage of edge length
Definition
ModEdgeLengthT_impl.hh:83
OpenMesh::Decimater::ModEdgeLengthT::set_edge_length
void set_edge_length(typename Mesh::Scalar _f)
set edge_length
Definition
ModEdgeLengthT.hh:91
OpenMesh::Decimater::ModEdgeLengthT::ModEdgeLengthT
ModEdgeLengthT(MeshT &_mesh, float _edge_length=FLT_MAX, bool _is_binary=true)
Constructor.
Definition
ModEdgeLengthT_impl.hh:65
OpenMesh::Decimater::ModEdgeLengthT::collapse_priority
float collapse_priority(const CollapseInfo &_ci) override
Definition
ModEdgeLengthT_impl.hh:74
OpenMesh::PolyMeshT::Scalar
Kernel::Scalar Scalar
Scalar type.
Definition
PolyMeshT.hh:110
OpenVolumeMesh::GeometryKernel
Definition
GeometryKernel.hh:50
OpenMesh
Definition
MeshItems.hh:59
OpenMesh::Decimater::CollapseInfoT
Definition
CollapseInfoT.hh:74
OpenMesh::Decimater::CollapseInfoT::p0
Mesh::Point p0
Position of removed vertex.
Definition
CollapseInfoT.hh:84
OpenMesh::Decimater::CollapseInfoT::p1
Mesh::Point p1
Positions of remaining vertex.
Definition
CollapseInfoT.hh:85
OpenFlipper
libs_required
OpenMesh
src
OpenMesh
Tools
Decimater
ModEdgeLengthT_impl.hh
Generated on Wed Jul 16 2025 14:44:33 for Developer Documentation by
1.9.8