mirror of https://github.com/CGAL/cgal
Adding data sets to the testsuite and changed the test to load those.
This commit is contained in:
parent
bd096e4b2a
commit
a779b4d7cc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -15,26 +15,29 @@ const bool pre_run = false;
|
|||
const bool do_remove = true;
|
||||
const int n_runs = 2;
|
||||
|
||||
void load_data(const char *filename, Iso_rectangle &domain, std::vector<Point> &pts)
|
||||
bool load_data(const char *filename, Iso_rectangle &domain, std::vector<Point> &pts)
|
||||
{
|
||||
std::ifstream file (filename, std::ios::in | std::ios::binary);
|
||||
if (!file.is_open()) exit(1);
|
||||
if (!file.is_open()) {
|
||||
std::cout << "Couldn't load " << filename << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
float dom[2];
|
||||
file.read((char *)&dom[0], 2 * sizeof(float));
|
||||
domain = Iso_rectangle(0, 0, dom[0], dom[1]);
|
||||
|
||||
float coords[2];
|
||||
while (!file.eof())
|
||||
{
|
||||
file.read((char *)&coords[0], 2 * sizeof(float));
|
||||
while (coords[0] < 0) coords[0] += dom[0];
|
||||
while (coords[1] < 0) coords[1] += dom[1];
|
||||
while (coords[0] >= dom[0]) coords[0] -= dom[0];
|
||||
while (coords[1] >= dom[1]) coords[1] -= dom[1];
|
||||
|
||||
pts.push_back(Point(coords[0], coords[1]));
|
||||
}
|
||||
while (!file.eof()) {
|
||||
file.read((char *)&coords[0], 2 * sizeof(float));
|
||||
while (coords[0] < 0) coords[0] += dom[0];
|
||||
while (coords[1] < 0) coords[1] += dom[1];
|
||||
while (coords[0] >= dom[0]) coords[0] -= dom[0];
|
||||
while (coords[1] >= dom[1]) coords[1] -= dom[1];
|
||||
|
||||
pts.push_back(Point(coords[0], coords[1]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
@ -57,18 +60,12 @@ void test(const std::vector<Point> &input, T &t)
|
|||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
srand(42);
|
||||
const char *filename = "/home/nico/Code/periodic_data_sets/512000_000.dat";
|
||||
if (argc == 2)
|
||||
{
|
||||
filename = argv[1];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool test(const char *filename) {
|
||||
Iso_rectangle domain;
|
||||
std::vector<Point> pts;
|
||||
load_data(filename, domain, pts);
|
||||
if (!load_data(filename, domain, pts))
|
||||
return false;
|
||||
|
||||
for (int run = 0; run < 3; ++run)
|
||||
{
|
||||
|
|
@ -92,14 +89,14 @@ int main(int argc, char * argv[])
|
|||
{
|
||||
if (pre_run)
|
||||
{
|
||||
Periodic_2_Delaunay_triangulation_2<Gt> t(domain);
|
||||
T t(domain);
|
||||
test(pts, t);
|
||||
}
|
||||
|
||||
std::clock_t total_start = std::clock();
|
||||
for (int i = 0; i < n_runs; ++i)
|
||||
{
|
||||
Periodic_2_Delaunay_triangulation_2<Gt> t(domain);
|
||||
T t(domain);
|
||||
test(pts, t);
|
||||
}
|
||||
double total_time = (std::clock() - total_start) / (double)CLOCKS_PER_SEC;
|
||||
|
|
@ -107,5 +104,25 @@ int main(int argc, char * argv[])
|
|||
std::cout << "Periodic space, " << filename << ", " << total_time << std::endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
typedef Periodic_2_Delaunay_triangulation_2<Gt> T;
|
||||
srand(42);
|
||||
|
||||
int result = 0;
|
||||
if (argc == 2) {
|
||||
if (!test<T>(argv[1])) result++;
|
||||
}
|
||||
else {
|
||||
if (!test<T>("data/gredner000.dat")) result++;
|
||||
if (!test<T>("data/gredner050.dat")) result++;
|
||||
if (!test<T>("data/gredner100.dat")) result++;
|
||||
if (!test<T>("data/gredner150.dat")) result++;
|
||||
if (!test<T>("data/gredner200.dat")) result++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue