I am trying to compute the 3D Periodic Delaunay Triangulation with the CGAL library, using the example given here as a starting point:
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Periodic_3_Delaunay_triangulation_traits_3<K> Gt;
typedef CGAL::Periodic_3_Delaunay_triangulation_3<Gt> P3DT3;
typedef CGAL::Creator_uniform_3<double, Point> Creator;
typedef P3DT3::Point Point;
//...
//...
CGAL::Random random(7);
CGAL::Random_points_in_cube_3<Point, Creator> in_cube(.5, random);
int n = 10000;
std::vector<Point> pts;
P3DT3 T;
// Generating n random points
for (int i=0 ; i < n ; i++) {
Point p = *in_cube;
in_cube++;
pts.push_back(Point(p.x()+.5,p.y()+.5,p.z()+.5));
}
for (int i=0; i<n; i++)
{
T.insert(pts[i]);
}
They offer three possibilities to insert points, each of them quite fast. However, if I take the example above and insert custom points (instead of the random ones), the insertion is almost 100 times slower. The results are the same, though. Here is a code sample:
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Periodic_3_Delaunay_triangulation_traits_3<K> Gt;
typedef CGAL::Periodic_3_Delaunay_triangulation_3<Gt> P3DT3;
typedef CGAL::Creator_uniform_3<double, Point> Creator;
typedef P3DT3::Point Point;
//...
//...
int n = 10000;
std::vector< std::vector<float> > pts(n); // my custom points
P3DT3 T;
for (int i = 0; i < n; i++)
{
Point p(pts[i][0],pts[i][1],pts[i][2]);
T.insert(p);
}
Am I doing something wrong? I need to insert a very large point set (~10^7 - 10^8), so speed is critical.
T.insert(p)
sentence? BTW, what isT
? - alseetherT.insert(pts.begin(),pts.end())
? That does help (by a factor of 2 or 3), but it is still pretty slow. - Julian