From d52199f64c740ec64859c9e3dfb73ef02d90882e Mon Sep 17 00:00:00 2001 From: ganovelli Date: Wed, 24 Sep 2008 08:37:42 +0000 Subject: [PATCH] DistanceFunctor templated on the type of the query Added GetClosestVertexNormal which uses Vertex Position and Normal (see PointNormalDistanceFunctor) --- vcg/complex/trimesh/closest.h | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/vcg/complex/trimesh/closest.h b/vcg/complex/trimesh/closest.h index 1ddd6fdc..955b1c57 100644 --- a/vcg/complex/trimesh/closest.h +++ b/vcg/complex/trimesh/closest.h @@ -188,7 +188,7 @@ namespace vcg { typedef FaceTmark MarkerFace; MarkerFace mf; mf.SetMesh(&mesh); - vcg::face::PointDistanceFunctor FDistFunct; + vcg::face::PointDistanceFunctor FDistFunct; _minDist=_maxDist; typename MESH::FaceType* bestf= gr.GetClosest(FDistFunct, mf, _p, _maxDist, _minDist, _closestPt); @@ -247,13 +247,29 @@ namespace vcg { typedef VertTmark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); - typedef vcg::vertex::PointDistanceFunctor VDistFunct; + typedef vcg::vertex::PointDistanceFunctor VDistFunct; VDistFunct fn; _minDist=_maxDist; Point3x _closestPt; return (gr.GetClosest/**/(fn,mv,_p,_maxDist,_minDist,_closestPt)); } + template + typename MESH::VertexType * GetClosestVertexNormal( MESH & mesh,GRID & gr,const typename MESH::VertexType & _p, + const typename GRID::ScalarType & _maxDist,typename GRID::ScalarType & _minDist ) + { + typedef typename GRID::ScalarType ScalarType; + typedef Point3 Point3x; + typedef VertTmark MarkerVert; + MarkerVert mv; + mv.SetMesh(&mesh); + typedef vcg::vertex::PointNormalDistanceFunctor VDistFunct; + VDistFunct fn; + _minDist=_maxDist; + Point3x _closestPt; + return (gr.GetClosest(fn,mv,_p,_maxDist,_minDist,_closestPt)); + } + template unsigned int GetKClosestFace(MESH & mesh,GRID & gr, const unsigned int _k, const typename GRID::CoordType & _p, const typename GRID::ScalarType & _maxDist, @@ -275,7 +291,7 @@ namespace vcg { typedef VertTmark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); - typedef vcg::vertex::PointDistanceFunctor VDistFunct; + typedef vcg::vertex::PointDistanceFunctor VDistFunct; VDistFunct distFunct; return (gr.GetKClosest/* */ (distFunct,mv,_k,_p,_maxDist,_objectPtrs,_distances,_points)); @@ -310,7 +326,7 @@ namespace vcg { typedef VertTmark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); - typedef vcg::vertex::PointDistanceFunctor VDistFunct; + typedef vcg::vertex::PointDistanceFunctor VDistFunct; VDistFunct fn; return (gr.GetInSphere/**/ (fn, mv,_p,_r,_objectPtrs,_distances,_points)); @@ -388,13 +404,13 @@ namespace vcg { template class ClosestFaceIterator:public vcg::ClosestIterator > + vcg::face::PointDistanceFunctor, FaceTmark > { public: typedef GRID GridType; typedef MESH MeshType; typedef FaceTmark MarkerFace; - typedef vcg::face::PointDistanceFunctor PDistFunct; + typedef vcg::face::PointDistanceFunctor PDistFunct; typedef vcg::ClosestIterator > ClosestBaseType; typedef typename MESH::FaceType FaceType; typedef typename MESH::ScalarType ScalarType; @@ -408,13 +424,13 @@ namespace vcg { }; template - class ClosestVertexIterator:public vcg::ClosestIterator > + class ClosestVertexIterator:public vcg::ClosestIterator, VertTmark > { public: typedef GRID GridType; typedef MESH MeshType; typedef VertTmark MarkerVert; - typedef vcg::vertex::PointDistanceFunctor VDistFunct; + typedef vcg::vertex::PointDistanceFunctor VDistFunct; typedef vcg::ClosestIterator > ClosestBaseType; VDistFunct fn; ClosestVertexIterator(GridType &_Si):ClosestBaseType(_Si,fn){}