From 837f3482f5bc9cb5fe0d307b357dcd3a8931e0c6 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 23 Aug 2006 15:35:36 +0000 Subject: [PATCH] added severla comments reimplemented operator () --- vcg/simplex/vertex/distance.h | 40 ++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/vcg/simplex/vertex/distance.h b/vcg/simplex/vertex/distance.h index 07c0dc61..e3cff04c 100644 --- a/vcg/simplex/vertex/distance.h +++ b/vcg/simplex/vertex/distance.h @@ -20,6 +20,11 @@ * for more details. * * * ****************************************************************************/ +// marco : +// comments +// corrected bug + + /**************************************************************************** History @@ -38,19 +43,38 @@ namespace vcg { class PointDistanceFunctor { public: template - inline bool operator () (const VERTEXTYPE & v, const Point3 & p, SCALARTYPE & minDist, Point3 & q) { + + /* + * @param v [IN] is a reference to the current object being tested, + * @param p [IN] is the query point, + * @param minDist [IN/OUT] is in input the reject distance and in output the closest distance, + * @param q [OUT] is the closest point. + * + * @remarks The operator returns true if the closest distance is less than input reject distance. + * + */ + inline bool operator () (const VERTEXTYPE & v, const Point3 & p, SCALARTYPE & minDist, Point3 & q) + { + // convert the coordinates of p from SCALARTYPE to VERTEXTYPE::ScalarType type const Point3 fp = Point3::Construct(p); - typename VERTEXTYPE::ScalarType md; - md=(v.P()-fp).Norm(); - bool ret = (md<=minDist); - if (ret) minDist = (SCALARTYPE)(md); - q = v.P(); - return (ret); + + typename VERTEXTYPE::ScalarType md; // distance between v and fp + md = (v.P() - fp).Norm(); + + if (md <= minDist) + { + minDist = (SCALARTYPE)(md); // minDist is updated to the closest distance + q = v.P(); // q is the current closest point + + return true; + } + + return false; } }; -} // end namespace face +} // end namespace vertex } // end namespace vcg