49 #define ADAPTIVE_REMESHERT_C 54 #include "AdaptiveRemesherT.hh" 55 #include <ACG/Geometry/Algorithms.hh> 56 #include "DiffGeoT.hh" 69 AdaptiveRemesherT<Mesh>::
72 Base::init_reference();
75 Base::refmesh_->add_property(refcurv_);
76 compute_curvature(*Base::refmesh_, refcurv_);
77 Base::mesh_.add_property(curvature_);
78 compute_curvature(Base::mesh_, curvature_);
87 AdaptiveRemesherT<Mesh>::
91 typename Mesh::FaceHandle fh = Base::bsp_->nearest(p).handle;
93 if ( ! fh.is_valid() ) {
94 std::cerr <<
"AdaptiveRemesherT: Projection, invalid face handle" << std::endl;
98 typename Mesh::CFVIter fv_it = Base::refmesh_->cfv_iter(fh);
101 const typename Mesh::Point& p0 = Base::refmesh_->point(*fv_it);
102 typename Mesh::Normal n0 = Base::refmesh_->normal(*fv_it);
103 typename Mesh::Scalar c0 = Base::refmesh_->property(refcurv_, *fv_it);
104 const typename Mesh::Point& p1 = Base::refmesh_->point(*(++fv_it));
105 typename Mesh::Normal n1 = Base::refmesh_->normal(*fv_it);
106 typename Mesh::Scalar c1 = Base::refmesh_->property(refcurv_, *fv_it);
107 const typename Mesh::Point& p2 = Base::refmesh_->point(*(++fv_it));
108 typename Mesh::Normal n2 = Base::refmesh_->normal(*fv_it);
109 typename Mesh::Scalar c2 = Base::refmesh_->property(refcurv_, *fv_it);
114 ACG::Geometry::distPointTriangle<typename Mesh::Point>(p, p0, p1, p2, p);
115 Base::mesh_.set_point(_vh, p);
120 p[0] = p[1] = p[2] = 1.0/3.0;
129 Base::mesh_.set_normal(_vh, n);
137 Base::mesh_.property(curvature_, _vh) = c;
144 template <
class Mesh>
146 AdaptiveRemesherT<Mesh>::
149 DiffGeoT<Mesh> diffgeo(_mesh);
152 typename Mesh::VIter v_it, v_end(_mesh.vertices_end());
154 for (v_it=_mesh.vertices_begin(); v_it!=v_end; ++v_it)
155 _mesh.property(_ph, *v_it) = diffgeo.max_curvature(*v_it);
162 template <
class Mesh>
164 AdaptiveRemesherT<Mesh>::
165 remesh(Scalar _error,
169 bool _use_projection,
170 Selection _selection)
178 Base::remesh(_iters, 0, _use_projection, _selection);
181 Base::mesh_.remove_property(curvature_);
188 template <
class Mesh>
190 AdaptiveRemesherT<Mesh>::
191 is_too_long(VertexHandle v0, VertexHandle v1)
const 193 const Point& p0 = Base::mesh_.point(v0);
194 const Point& p1 = Base::mesh_.point(v1);
196 Scalar c = 0.5 * ( Base::mesh_.property(curvature_, v0) +
197 Base::mesh_.property(curvature_, v1) );
199 Scalar e = 2.0/c*error_ - error_*error_;
200 e = (e <= 0.0 ? error_ : 2.0*sqrt(e));
202 if (e<emin_) e=emin_;
else if (e>emax_) e=emax_;
203 Scalar emax = 4.0/3.0 * e;
205 return ((p0 - p1).sqrnorm() > emax*emax);
212 template <
class Mesh>
214 AdaptiveRemesherT<Mesh>::
215 is_too_short(VertexHandle v0, VertexHandle v1)
const 217 const Point& p0 = Base::mesh_.point(v0);
218 const Point& p1 = Base::mesh_.point(v1);
220 Scalar c = 0.5 * ( Base::mesh_.property(curvature_, v0) +
221 Base::mesh_.property(curvature_, v1) );
223 Scalar e = 2.0/c*error_ - error_*error_;
224 e = (e <= 0.0 ? error_ : 2.0*sqrt(e));
226 if (e<emin_) e=emin_;
else if (e>emax_) e=emax_;
227 Scalar emin = 4.0/5.0 * e;
229 return ((p0 - p1).sqrnorm() < emin*emin);
Kernel::Normal Normal
Normal type.
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.