-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocksize.cxx
More file actions
113 lines (93 loc) · 2.78 KB
/
blocksize.cxx
File metadata and controls
113 lines (93 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/***************************************************************
* Copyright (c) 2013, Tsinghua University.
* This is a source file of C-Coupler.
* This file was initially finished by Haoyu Yang,
* supervised by Dr. Li Liu. If you have any problem,
* please contact Dr. Li Liu via liuli-cess@tsinghua.edu.cn
***************************************************************/
#include <cstdio>
#include <sys/time.h>
#include <cstdlib>
#include <cstring>
#include "common_utils.h"
#include "delaunay.h"
char rand_fine[][64] = {
"blocksize_random_10000000_0.flat",
"blocksize_random_10000000_1.flat",
};
char rand_midd[][64] = {
"blocksize_random_1000000_0.flat",
"blocksize_random_1000000_1.flat",
};
char rand_cors[][64] = {
"blocksize_random_100000_0.flat",
"blocksize_random_100000_1.flat",
};
char lonlat_fine[][64] = {
"blocksize_lonlat_0.1_0.flat",
"blocksize_lonlat_0.1_1.flat",
};
char lonlat_midd[][64] = {
"blocksize_lonlat_0.3_0.flat",
"blocksize_lonlat_0.3_1.flat",
};
char lonlat_cors[][64] = {
"blocksize_lonlat_1_0.flat",
"blocksize_lonlat_1_1.flat",
};
char cube_fine[][64] = {
"blocksize_cube_0.1_0.flat",
"blocksize_cube_0.1_1.flat",
};
char cube_midd[][64] = {
"blocksize_cube_0.3_0.flat",
"blocksize_cube_0.3_1.flat",
};
char cube_cors[][64] = {
"blocksize_cube_1_0.flat",
"blocksize_cube_1_1.flat",
};
char path[] = "grid/expand/%s";
int main(int argc, char* argv[])
{
bool non_incremental = false;
Delaunay_Voronoi* triangulation = new Delaunay_Voronoi();
for (int i = 0; i < 2; i++)
{
char filepath[64];
snprintf(filepath, 64, path, rand_fine[i]);
if (i > 0 && non_incremental)
strncat(filepath, ".png.flat", 64);
FILE* fp = fopen(filepath, "r");
if (!fp) {
perror("No such file\n");
return -1;
}
int num_points = 0;
fscanf(fp, "%d", &num_points);
if (num_points < 1) {
perror("Wrong number of points\n");
return -1;
}
double* x = new double[num_points];
double* y = new double[num_points];
for (int i = 0; i < num_points; i++)
fscanf(fp, "%lf, %lf", &x[i], &y[i]);
fclose(fp);
if (non_incremental)
{
delete triangulation;
triangulation = new Delaunay_Voronoi();
}
timeval start, end;
gettimeofday(&start, NULL);
triangulation->add_points(x, y, num_points);
gettimeofday(&end, NULL);
triangulation->triangulate();
if (i != 0)
fprintf(stderr, "time: %ld us, points: %d\n", (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec), num_points);
delete[] x;
delete[] y;
}
return 0;
}