57 #define OPENMESH_DECIMATER_MODASPECTRATIOT_C
72 const Point& _v0,
const Point& _v1,
const Point& _v2) {
77 Scalar l2, maxl2 = d0.sqrnorm();
78 if ((l2 = d1.sqrnorm()) > maxl2)
82 if ((l2 = d1.sqrnorm()) > maxl2)
86 Scalar a2 = (d0 % d1).sqrnorm();
96 return sqrt((maxl2 * maxl2) / a2);
101 template<
class MeshT>
103 typename Mesh::FaceIter f_it, f_end(mesh_.faces_end());
104 typename Mesh::FVIter fv_it;
106 for (f_it = mesh_.faces_begin(); f_it != f_end; ++f_it) {
107 fv_it = mesh_.fv_iter(*f_it);
109 typename Mesh::Point& p1 = mesh_.point(*(++fv_it));
110 typename Mesh::Point& p2 = mesh_.point(*(++fv_it));
112 mesh_.property(aspect_, *f_it) =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(p0, p1, p2);
118 template<
class MeshT>
120 typename Mesh::FaceHandle fh;
121 typename Mesh::FVIter fv_it;
123 for (
typename Mesh::VFIter vf_it = mesh_.vf_iter(_ci.
v0); vf_it.is_valid(); ++vf_it) {
125 if (fh != _ci.
fl && fh != _ci.
fr) {
126 fv_it = mesh_.fv_iter(fh);
128 typename Mesh::Point& p1 = mesh_.point(*(++fv_it));
129 typename Mesh::Point& p2 = mesh_.point(*(++fv_it));
131 mesh_.property(aspect_, fh) =
static_cast<typename
Mesh::Scalar>(1.0) / aspectRatio(p0, p1, p2);
138 template<
class MeshT>
141 typename Mesh::FaceHandle fh;
146 v3 = mesh_.to_vertex_handle(*voh_it);
147 p3 = &mesh_.point(v3);
149 while (voh_it.is_valid()) {
154 v3 = mesh_.to_vertex_handle(*voh_it);
155 p3 = &mesh_.point(v3);
157 fh = mesh_.face_handle(*voh_it);
162 if ((r0 = mesh_.property(aspect_, fh)) < r0_min)
166 if (!(v2 == _ci.
v1 || v3 == _ci.
v1))
167 if ((r1 = static_cast<typename Mesh::Scalar>(1.0) / aspectRatio(*p1, *p2, *p3)) < r1_min)
172 if (Base::is_binary()) {
174 ((r1_min > r0_min) || (r1_min > min_aspect_)) ? float(Base::LEGAL_COLLAPSE) :
175 float(Base::ILLEGAL_COLLAPSE);
179 return 1.f - float(r1_min);
182 (r1_min > min_aspect_) ? 2.f - float(r1_min) : float(Base::ILLEGAL_COLLAPSE);
188 template<
class MeshT>
190 if (_factor >= 0.0 && _factor <= 1.0) {
194 float min_aspect = min_aspect_ * (2.f - float(_factor)) / (2.f -
float(this->error_tolerance_factor_));
195 set_aspect_ratio(1.f/min_aspect);
196 this->error_tolerance_factor_ = _factor;
Mesh::VertexHandle v1
Remaining vertex.
void initialize()
precompute face aspect ratio
Mesh::Point p1
Positions of remaining vertex.
Mesh::VertexHandle v0
Vertex to be removed.
Mesh::FaceHandle fr
Right face.
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Mesh::FaceHandle fl
Left face.
Kernel::Point Point
Coordinate type.
float collapse_priority(const CollapseInfo &_ci)
Returns the collapse priority.
void set_error_tolerance_factor(double _factor)
set percentage of aspect ratio
Kernel::Scalar Scalar
Scalar type.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Scalar aspectRatio(const Point &_v0, const Point &_v1, const Point &_v2)
return aspect ratio (length/height) of triangle
void preprocess_collapse(const CollapseInfo &_ci)
update aspect ratio of one-ring