56 #define ADAPTIVE_REMESHERT_C
61 #include "AdaptiveRemesherT.hh"
62 #include <ACG/Geometry/Algorithms.hh>
63 #include "DiffGeoT.hh"
79 Base::init_reference();
82 Base::refmesh_->add_property(refcurv_);
83 compute_curvature(*Base::refmesh_, refcurv_);
84 Base::mesh_.add_property(curvature_);
85 compute_curvature(Base::mesh_, curvature_);
98 typename Mesh::FaceHandle fh = Base::bsp_->nearest(p).handle;
100 if ( ! fh.is_valid() ) {
101 std::cerr <<
"AdaptiveRemesherT: Projection, invalid face handle" << std::endl;
105 typename Mesh::CFVIter fv_it = Base::refmesh_->cfv_iter(fh);
108 const typename Mesh::Point& p0 = Base::refmesh_->point(*fv_it);
109 typename Mesh::Normal n0 = Base::refmesh_->normal(*fv_it);
110 typename Mesh::Scalar c0 = Base::refmesh_->property(refcurv_, *fv_it);
111 const typename Mesh::Point& p1 = Base::refmesh_->point(*(++fv_it));
112 typename Mesh::Normal n1 = Base::refmesh_->normal(*fv_it);
113 typename Mesh::Scalar c1 = Base::refmesh_->property(refcurv_, *fv_it);
114 const typename Mesh::Point& p2 = Base::refmesh_->point(*(++fv_it));
115 typename Mesh::Normal n2 = Base::refmesh_->normal(*fv_it);
116 typename Mesh::Scalar c2 = Base::refmesh_->property(refcurv_, *fv_it);
121 ACG::Geometry::distPointTriangle<typename Mesh::Point>(p, p0, p1, p2, p);
122 Base::mesh_.set_point(_vh, p);
127 p[0] = p[1] = p[2] = 1.0/3.0;
136 Base::mesh_.set_normal(_vh, n);
144 Base::mesh_.property(curvature_, _vh) = c;
151 template <
class Mesh>
159 typename Mesh::VIter v_it, v_end(_mesh.vertices_end());
161 for (v_it=_mesh.vertices_begin(); v_it!=v_end; ++v_it)
162 _mesh.property(_ph, *v_it) = diffgeo.max_curvature(*v_it);
169 template <
class Mesh>
176 bool _use_projection,
177 Selection _selection)
185 Base::remesh(_iters, 0, _use_projection, _selection);
188 Base::mesh_.remove_property(curvature_);
195 template <
class Mesh>
198 is_too_long(VertexHandle v0, VertexHandle v1)
const
200 const Point& p0 = Base::mesh_.point(v0);
201 const Point& p1 = Base::mesh_.point(v1);
203 Scalar c = 0.5 * ( Base::mesh_.property(curvature_, v0) +
204 Base::mesh_.property(curvature_, v1) );
206 Scalar e = 2.0/c*error_ - error_*error_;
207 e = (e <= 0.0 ? error_ : 2.0*sqrt(e));
209 if (e<emin_) e=emin_;
else if (e>emax_) e=emax_;
210 Scalar emax = 4.0/3.0 * e;
212 return ((p0 - p1).sqrnorm() > emax*emax);
219 template <
class Mesh>
224 const Point& p0 = Base::mesh_.point(v0);
225 const Point& p1 = Base::mesh_.point(v1);
227 Scalar c = 0.5 * ( Base::mesh_.property(curvature_, v0) +
228 Base::mesh_.property(curvature_, v1) );
230 Scalar e = 2.0/c*error_ - error_*error_;
231 e = (e <= 0.0 ? error_ : 2.0*sqrt(e));
233 if (e<emin_) e=emin_;
else if (e>emax_) e=emax_;
234 Scalar emin = 4.0/5.0 * e;
236 return ((p0 - p1).sqrnorm() < emin*emin);
Kernel::Point Point
Coordinate type.
bool baryCoord(const VectorT< Scalar, 3 > &_p, const VectorT< Scalar, 3 > &_u, const VectorT< Scalar, 3 > &_v, const VectorT< Scalar, 3 > &_w, VectorT< Scalar, 3 > &_result)
Kernel::Scalar Scalar
Scalar type.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::Normal Normal
Normal type.