-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelaunayTest.cpp
More file actions
88 lines (61 loc) · 1.78 KB
/
Copy pathDelaunayTest.cpp
File metadata and controls
88 lines (61 loc) · 1.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
#include <chrono>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "MySweepLDT.h"
int exampleUsage() {
std::ifstream file("DTSL - Testing datasets/clus1000000.pnt");
if (!file) {
std::cerr << "Cannot open points.txt\n";
return 1;
}
double BoxXMax, BoxYMax, BoxXMin, BoxYMin;
std::vector<double> XArr, YArr;
BoxXMin = BoxYMin = MaxDouble();
BoxXMax = BoxYMax = -MaxDouble();
std::string line;
int NoOfPoints = 0;
bool f = true;
int i = 0;
while (std::getline(file, line)) {
if (line.empty()) continue;
std::stringstream ss(line);
if (f) {
f = false;
ss >> NoOfPoints;
XArr.reserve(NoOfPoints);
YArr.reserve(NoOfPoints);
continue;
}
double x, y;
char comma;
if (ss >> x >> comma >> y && comma == ',') {
XArr.push_back(x);
YArr.push_back(y);
if (XArr[i] > BoxXMax) BoxXMax = XArr[i];
if (YArr[i] > BoxYMax) BoxYMax = YArr[i];
if (XArr[i] < BoxXMin) BoxXMin = XArr[i];
if (YArr[i] < BoxYMin) BoxYMin = YArr[i];
i++;
}
}
auto start = std::chrono::high_resolution_clock::now();
MySweepLDT DT;
std::vector<STLStyleTriangle> DTTriangles;
int LTEntries = (int)XArr.size();
LTEntries = (int)(LTEntries / 100);
if (LTEntries == 0) LTEntries = 2;
int DataFlag =
DT.InitSL(BoxXMin, BoxYMin, BoxXMax, BoxYMax, LTEntries, XArr, YArr);
if (DataFlag == 0) return -1;
DT.DoDT();
auto end = std::chrono::high_resolution_clock::now();
double milliseconds =
std::chrono::duration<double, std::milli>(end - start).count();
std::cout << "Triangulation time: " << milliseconds << " ms\n";
std::cout << "Triangles: " << DTTriangles.size() << '\n';
return -1;
}
int main() { exampleUsage(); }