From a952bb1801a889fa3e65f31ddb8fcffe0d8a8b01 Mon Sep 17 00:00:00 2001 From: ganovelli Date: Wed, 24 Sep 2008 08:42:17 +0000 Subject: [PATCH] DistanceFunctor templated on the type of the query Added PointNormalDistanceFunctor --- vcg/simplex/vertex/distance.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/vcg/simplex/vertex/distance.h b/vcg/simplex/vertex/distance.h index e3cff04c..29d5cef8 100644 --- a/vcg/simplex/vertex/distance.h +++ b/vcg/simplex/vertex/distance.h @@ -40,9 +40,12 @@ namespace vcg { namespace vertex{ +template class PointDistanceFunctor { public: - template + typedef Point3 QueryType; + static inline const Point3 & Pos(const QueryType & qt) {return qt;} + template /* * @param v [IN] is a reference to the current object being tested, @@ -73,6 +76,34 @@ namespace vcg { } }; +template +class PointNormalDistanceFunctor { + public: + typedef typename VERTEXTYPE QueryType; + typedef typename VERTEXTYPE::ScalarType ScalarType; + static inline const Point3 & Pos(const QueryType & qt) {return qt.P();} + + static ScalarType & Alpha(){static ScalarType alpha = 1.0; return alpha;} + static ScalarType & Beta(){static ScalarType beta= 1.0; return beta;} + static ScalarType & Gamma(){static ScalarType gamma= 1.0; return gamma;} + static ScalarType & InterPoint (){static ScalarType interpoint= 1.0; return interpoint;} + + template + inline bool operator () (const VERTEXTYPE & v, const VERTEXTYPE & vp, SCALARTYPE & minDist, Point3 & q) { + + float h = vcg::Distance(v.cP(),vp.P()) ; + float dev = InterPoint ()* ( pow((ScalarType) (1-v.cN()*vp.cN()),(ScalarType) Beta()) / (Gamma()*h +0.1)); + if(h+dev < minDist){ + minDist = h+dev; + q = v.P(); + return true; + } + + // minDist = h +0.0* (1-v.cN()*vp.cN()) / (h + 0.1); + + return false; + } + }; } // end namespace vertex