51 #define OPENMESH_DECIMATER_MODASPECTRATIOT_C
65 typename ModAspectRatioT<MeshT>::Scalar ModAspectRatioT<MeshT>::aspectRatio(
66 const Point& _v0,
const Point& _v1,
const Point& _v2) {
71 Scalar l2, maxl2 = d0.sqrnorm();
72 if ((l2 = d1.sqrnorm()) > maxl2)
76 if ((l2 = d1.sqrnorm()) > maxl2)
80 Scalar a2 = (d0 % d1).sqrnorm();
90 return sqrt((maxl2 * maxl2) / a2);
98 typename Mesh::FVIter fv_it;
100 for (f_it = mesh_.faces_begin(); f_it != f_end; ++f_it) {
101 fv_it = mesh_.fv_iter(*f_it);
102 typename Mesh::Point& p0 = mesh_.point(*fv_it);
103 typename Mesh::Point& p1 = mesh_.point(*(++fv_it));
104 typename Mesh::Point& p2 = mesh_.point(*(++fv_it));
106 mesh_.property(aspect_, *f_it) =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(p0, p1, p2);
112 template<
class MeshT>
115 typename Mesh::FVIter fv_it;
117 for (
typename Mesh::VFIter vf_it = mesh_.vf_iter(_ci.v0); vf_it.is_valid(); ++vf_it) {
119 if (fh != _ci.fl && fh != _ci.fr) {
120 fv_it = mesh_.fv_iter(fh);
121 typename Mesh::Point& p0 = mesh_.point(*fv_it);
122 typename Mesh::Point& p1 = mesh_.point(*(++fv_it));
123 typename Mesh::Point& p2 = mesh_.point(*(++fv_it));
125 mesh_.property(aspect_, fh) =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(p0, p1, p2);
132 template<
class MeshT>
136 const typename Mesh::Point* p1(&_ci.p1);
140 v3 = mesh_.to_vertex_handle(*voh_it);
141 auto p3 = &mesh_.point(v3);
143 while (voh_it.is_valid()) {
148 v3 = mesh_.to_vertex_handle(*voh_it);
149 p3 = &mesh_.point(v3);
151 fh = mesh_.face_handle(*voh_it);
156 if ((r0 = mesh_.property(aspect_, fh)) < r0_min)
160 if (!(v2 == _ci.v1 || v3 == _ci.v1))
161 if ((r1 =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(*p1, *p2, *p3)) < r1_min)
166 if (Base::is_binary()) {
168 ((r1_min > r0_min) || (r1_min > min_aspect_)) ? float(Base::LEGAL_COLLAPSE) :
169 float(Base::ILLEGAL_COLLAPSE);
173 return 1.f - float(r1_min);
176 (r1_min > min_aspect_) ? 2.f - float(r1_min) : float(Base::ILLEGAL_COLLAPSE);
182 template<
class MeshT>
184 if (_factor >= 0.0 && _factor <= 1.0) {
188 float min_aspect = min_aspect_ * (2.f - float(_factor)) / (2.f -
float(this->error_tolerance_factor_));
189 set_aspect_ratio(1.f/min_aspect);
190 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::FaceIter FaceIter
Scalar type.
Definition: PolyMeshT.hh:146
Kernel::FaceHandle FaceHandle
Scalar type.
Definition: PolyMeshT.hh:139
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:173
void preprocess_collapse(const CollapseInfo &_ci) override
update aspect ratio of one-ring
Definition: ModAspectRatioT_impl.hh:113
float collapse_priority(const CollapseInfo &_ci) override
Returns the collapse priority.
Definition: ModAspectRatioT_impl.hh:133
void set_error_tolerance_factor(double _factor) override
set percentage of aspect ratio
Definition: ModAspectRatioT_impl.hh:183
void initialize() override
precompute face aspect ratio
Definition: ModAspectRatioT_impl.hh:96