Result getRes(std::vector<Point> points) { typedef double mytype; // coordinate type int d = 2; // dimension int n = points.size(); // number of points mytype** ap = new mytype*[n]; for (int i=0; i<n; ++i) { mytype* p = new mytype[d]; p[0] = points[i].x; p[1] = points[i].y; ap[i]=p; } // define the types of iterators through the points and their coordinates // ---------------------------------------------------------------------- typedef mytype* const* PointIterator; typedef const mytype* CoordIterator; // create an instance of Miniball // ------------------------------ typedef Miniball:: Miniball <Miniball::CoordAccessor<PointIterator, CoordIterator> > MB; MB mb (d, ap, ap+n); Result res; const mytype* center = mb.center(); res.c.x = *center; ++center; res.c.y = *center; res.sr = mb.squared_radius(); res.valid = mb.is_valid(); for (int i=0; i<n; ++i) delete[] ap[i]; delete[] ap; return res; }
const SrSphere3D test_SmallestEnclosingSphere_Gaertner(const SrPoint3D* point, int n) { typedef double mytype; // coordinate type int d = 3; // dimension mytype** ap = new mytype*[n]; for (int i=0; i<n; ++i) { mytype* p = new mytype[d]; p[0] = point[i].x; p[1] = point[i].y; p[2] = point[i].z; ap[i]=p; } // define the types of iterators through the points and their coordinates // ---------------------------------------------------------------------- typedef mytype* const* PointIterator; typedef const mytype* CoordIterator; // create an instance of Miniball // ------------------------------ typedef Miniball::Miniball <Miniball::CoordAccessor<PointIterator, CoordIterator> > MB; MB mb (d, ap, ap+n); SrSphere3D sphere; const mytype* center = mb.center(); sphere.mCenter.x = *center; sphere.mCenter.y = *(++center); sphere.mCenter.z = *(++center); sphere.mRadius = sqrt(mb.squared_radius()); // clean up for (int i=0; i<n; ++i) delete[] ap[i]; delete[] ap; return sphere; }