diff --git a/vcg/space/sphere3.h b/vcg/space/sphere3.h index 665f352e..8a770e86 100644 --- a/vcg/space/sphere3.h +++ b/vcg/space/sphere3.h @@ -96,7 +96,9 @@ protected: int CreateFromBox(int n, const Point3 *points); //makes 36 iterations over the data... but get good results. - int CreateTight(int n, const Point3 *points, + int CreateTight(int n, const Point3 *points, + T threshold = 1.01, T speed = 0.6); + int CreateTight(const std::vector > & points, T threshold = 1.01, T speed = 0.6); }; @@ -179,7 +181,6 @@ template void Sphere3::Intersect(const Sphere3 &s) { Radius() = (min - max).Norm()/2; return 0; } - template int Sphere3::CreateTight(int n, const Point3 *points, T threshold, T speed) { //This is quantized gradient descent... really ugly. But simple :P @@ -226,7 +227,7 @@ template void Sphere3::Intersect(const Sphere3 &s) { Radius() = best_radius; } step *= speed; - if(step < Radius() * (threshold - 1)) + if(step <= Radius() * (threshold - 1)) break; } Radius() *= 1.01; @@ -238,6 +239,11 @@ template void Sphere3::Intersect(const Sphere3 &s) { return count; } +template int Sphere3::CreateTight(const std::vector > & points, + T threshold, T speed){ + return (points.empty())? -1 :CreateTight(points.size(),&(*points.begin()),threshold,speed); +} + } //namespace