51#define OPENMESH_DECIMATER_MODASPECTRATIOT_C
65typename ModAspectRatioT<MeshT>::Scalar ModAspectRatioT<MeshT>::aspectRatio(
66 const Point& _v0,
const Point& _v1,
const Point& _v2) {
69 const Point d0 = _v0 - _v1;
70 const Point d1 = _v1 - _v2;
71 const Point d2 = _v2 - _v0;
74 const Scalar l0 = sqrnorm(d0);
75 const Scalar l1 = sqrnorm(d1);
76 const Scalar l2 = sqrnorm(d2);
79 const Scalar maxl2 = std::max(l0, std::max(l1, l2));
83 Scalar a2 = sqrnorm(d0 % d2);
94 return maxl2 / sqrt(a2);
102 for (
const auto& fh : mesh_.faces())
104 auto fv_it = mesh_.cfv_iter(fh);
106 const typename Mesh::Point& p0 = mesh_.point(*fv_it);
107 const typename Mesh::Point& p1 = mesh_.point(*(++fv_it));
108 const typename Mesh::Point& p2 = mesh_.point(*(++fv_it));
110 mesh_.property(aspect_, fh) =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(p0, p1, p2);
120 typename Mesh::FVIter fv_it;
122 for (
typename Mesh::VFIter vf_it = mesh_.vf_iter(_ci.v0); vf_it.is_valid(); ++vf_it) {
124 if (fh != _ci.fl && fh != _ci.fr) {
125 fv_it = mesh_.fv_iter(fh);
127 typename Mesh::Point& p1 = mesh_.point(*(++fv_it));
128 typename Mesh::Point& p2 = mesh_.point(*(++fv_it));
130 mesh_.property(aspect_, fh) =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(p0, p1, p2);
145 v3 = mesh_.to_vertex_handle(*voh_it);
146 auto p3 = &mesh_.point(v3);
148 while (voh_it.is_valid()) {
153 v3 = mesh_.to_vertex_handle(*voh_it);
154 p3 = &mesh_.point(v3);
156 fh = mesh_.face_handle(*voh_it);
161 if ((r0 = mesh_.property(aspect_, fh)) < r0_min)
165 if (!(v2 == _ci.v1 || v3 == _ci.v1))
166 if ((r1 =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(*p1, *p2, *p3)) < r1_min)
171 if (Base::is_binary()) {
173 ((r1_min > r0_min) || (r1_min > min_aspect_)) ? float(Base::LEGAL_COLLAPSE) :
174 float(Base::ILLEGAL_COLLAPSE);
178 return 1.f - float(r1_min);
181 (r1_min > min_aspect_) ? 2.f - float(r1_min) : float(Base::ILLEGAL_COLLAPSE);
189 if (_factor >= 0.0 && _factor <= 1.0) {
193 float min_aspect = min_aspect_ * (2.f - float(_factor)) / (2.f -
float(this->error_tolerance_factor_));
194 set_aspect_ratio(1.f/min_aspect);
195 this->error_tolerance_factor_ = _factor;
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition PolyMeshT.hh:136
Kernel::Scalar Scalar
Scalar type.
Definition PolyMeshT.hh:110
Kernel::FaceHandle FaceHandle
Scalar type.
Definition PolyMeshT.hh:139
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition PolyMeshT.hh:173
Kernel::Point Point
Coordinate type.
Definition PolyMeshT.hh:112
void preprocess_collapse(const CollapseInfo &_ci) override
update aspect ratio of one-ring
Definition ModAspectRatioT_impl.hh:118
float collapse_priority(const CollapseInfo &_ci) override
Returns the collapse priority.
Definition ModAspectRatioT_impl.hh:138
void set_error_tolerance_factor(double _factor) override
set percentage of aspect ratio
Definition ModAspectRatioT_impl.hh:188
void initialize() override
precompute face aspect ratio
Definition ModAspectRatioT_impl.hh:100