51 #define OPENMESH_DECIMATER_MODASPECTRATIOT_C 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);
97 typename Mesh::FaceIter f_it, f_end(mesh_.faces_end());
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);
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>
114 typename Mesh::FaceHandle fh;
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);
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>
135 typename Mesh::FaceHandle fh;
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;
Mesh::Point p1
Positions of remaining vertex.
Mesh::FaceHandle fl
Left face.
Mesh::FaceHandle fr
Right face.
Kernel::Point Point
Coordinate type.
void preprocess_collapse(const CollapseInfo &_ci) override
update aspect ratio of one-ring
void set_error_tolerance_factor(double _factor) override
set percentage of aspect ratio
Scalar aspectRatio(const Point &_v0, const Point &_v1, const Point &_v2)
return aspect ratio (length/height) of triangle
void initialize() override
precompute face aspect ratio
float collapse_priority(const CollapseInfo &_ci) override
Returns the collapse priority.
Kernel::Scalar Scalar
Scalar type.
Mesh::VertexHandle v0
Vertex to be removed.
Mesh::VertexHandle v1
Remaining vertex.
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.