forked from xu-0020/PointCloud_Octree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HRTree.cpp
574 lines (506 loc) · 24.8 KB
/
HRTree.cpp
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
#include "RTreePoints.h"
#include "RTreeT.h"
#include <map>
#include <cmath>
#include <iostream>
#include <fstream>
#include <sstream>
#include <chrono>
#include <list>
using namespace std;
#include <unordered_map>
#include <random>
#include <dirent.h>
#include <sys/stat.h>
#include <cstring>
#include <experimental/filesystem>
void write_result(string filename, list<string> results){
std::ofstream outputFile(filename, std::ios::trunc);
if (outputFile.is_open()) { // Check if the file is successfully opened
for (const auto& str : results) {
outputFile << str << std::endl; // Write each string to the file
}
outputFile.close(); // Close the file
std::cout << "File write successful." << std::endl;
} else {
std::cout << "Failed to open the file." << std::endl;
}
return;
}
// summary of the points(max and min of x, y, z, time)
std::unordered_map<std::string, float> Summary(vector<Point> points){
std::unordered_map<std::string, float> summary;
auto maxTPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.time < b.time;
}
);
auto minTPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.time > b.time;
}
);
auto maxXPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.time < b.time;
}
);
auto minXPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.x > b.x;
}
);
auto maxYPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.x < b.x;
}
);
auto minYPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.y > b.y;
}
);
auto maxZPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.z < b.z;
}
);
auto minZPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.z > b.z;
}
);
summary["maxTime"] = maxTPoint->time;
summary["minTime"] = minTPoint->time;
summary["maxX"] = maxXPoint->x;
summary["minX"] = minXPoint->x;
summary["maxY"] = maxYPoint->y;
summary["minY"] = minYPoint->y;
summary["maxZ"] = maxZPoint->z;
summary["minZ"] = minZPoint->z;
return summary;
}
std::vector<Point> getRandomPoints(const std::vector<Point>& data, int count) {
std::vector<Point> randomPoints;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, data.size() - 1);
for (int i = 0; i < count; ++i) {
int index = dis(gen);
randomPoints.push_back(data[index]);
}
return randomPoints;
}
// summary of the points(max and min of x, y, z, time)
std::unordered_map<std::string, float> Summary_e(vector<Point> points){
std::unordered_map<std::string, float> summary;
auto maxXPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.time < b.time;
}
);
auto minXPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.x > b.x;
}
);
auto maxYPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.x < b.x;
}
);
auto minYPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.y > b.y;
}
);
auto maxZPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.z < b.z;
}
);
auto minZPoint = std::max_element(
points.begin(),
points.end(),
[](Point& a, Point& b) {
return a.z > b.z;
}
);
summary["maxX"] = maxXPoint->x;
summary["minX"] = minXPoint->x;
summary["maxY"] = maxYPoint->y;
summary["minY"] = minYPoint->y;
summary["maxZ"] = maxZPoint->z;
summary["minZ"] = minZPoint->z;
return summary;
}
vector<Point> GetDataFromSingleCSV(const string& filename){
bool firstPoint = true;
vector<Point> points;
ifstream file(filename);
string line;
if (!getline(file, line)) { // Skip header
cerr << "Error reading the file or the file is empty: " << filename << endl;
return points; // Return empty bounds if file is empty or can't be read
}
while (getline(file, line)) {
stringstream ss(line);
string value;
vector<string> values;
while (getline(ss, value, ',')) {
values.push_back(value);
}
float x = stof(values[0]);
float y = stof(values[1]);
float z = stof(values[2]);
float time = stof(values[3]);
Point point = Point(x, y, z, -1, -1, -1, filename, floor(time));
points.push_back(point);
}
return points;
}
vector<Point> GetDataFromSingleFolder(const std::string& folderPath) {
vector<Point> points;
vector<Point> tmp;
DIR* directory = opendir(folderPath.c_str());
if (directory == nullptr) {
std::cout << "Failed to open directory: " << folderPath << std::endl;
return points;
}
dirent* entry;
while ((entry = readdir(directory)) != nullptr) {
std::string fileName = entry->d_name;
if (fileName != "." && fileName != "..") {
std::string absolutePath = folderPath + "/" + fileName;
std::cout << "File: " << absolutePath << std::endl;
tmp = GetDataFromSingleCSV(absolutePath);
points.insert(points.end(), tmp.begin(), tmp.end());
}
}
closedir(directory);
return points;
}
class RTreeNode {
public:
float time;
RTreePoints* tree;
RTreeNode(vector<Point> points): time(points.front().time) {
this->tree = new RTreePoints;
RInsert(this->tree, points);
}
~RTreeNode(){
delete this->tree;
this->tree = nullptr;
}
// void HRTreeNodeInsert(Point point){
// RInsertPoint(this->tree, point);
// }
void HRSearch(std::vector<Point>& results, Bounds& queryRange){
RSearch(this->tree, results, queryRange);
return;
}
void print_tree_node(){
cout<< "Tree node with the time "<< this->time<<endl;
auto list = tree->ListTree();
int counter = 0;
for (auto aabb : list) {
cout << "TreeList [" << counter++ << "]: "
<< aabb.m_min[0] << ", "
<< aabb.m_min[1] << ", "
<< aabb.m_min[2] << "; "
<< aabb.m_max[0] << ", "
<< aabb.m_max[1] << ", "
<< aabb.m_max[2] << endl;
}
return;
}
};
bool compareByAttribute(RTreeNode& obj1, RTreeNode& obj2) {
return obj1.time < obj2.time;
}
bool compareByPoints(Point& obj1, Point& obj2) {
return obj1.time < obj2.time;
}
class HRTree {
private:
std::map<float, RTreeNode*> trees;
public:
HRTree(vector<Point> points){
if (points.empty()){
return;
}
std::sort(points.begin(), points.end(), compareByPoints);
// Group the elements based on 'attribute'
std::map<float, std::vector<Point>> groupedMap;
for (const Point& point : points) {
groupedMap[point.time].push_back(point);
}
for (const auto& entry : groupedMap) {
// cout<< entry.first;
this->trees[entry.first] = new RTreeNode(groupedMap[entry.first]);
}
return;
}
~HRTree() {
this->trees.clear();
}
void print_tree(){
for (auto& entry : this->trees) {
entry.second->print_tree_node();
}
return;
}
void HRTreeSearch(float start, float end, std::vector<Point>& results, Bounds& queryRange){
for (auto& entry : this->trees) {
if (entry.first >= start && entry.first <= end){
entry.second->HRSearch(results, queryRange);
}
}
return;
}
};
int main(){
// // Read in data.
// auto startTime = std::chrono::high_resolution_clock::now();
// cout << "----------------------------------Reading data---------------------------------" << endl;
// string folderPath = "/export/project/hjingaa/PointCloud_Octree/data_csv/Montreal"; // 替换为实际的文件夹路径
// vector<Point> points = GetDataFromSingleFolder(folderPath);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
// cout<< "Reading data cost " <<duration.count()<< "ms"<<endl;
// // Get the summary data.
// cout << "----------------------------------Process data summary---------------------------------" << endl;
// std::unordered_map<std::string, float> map = Summary_e(points);
// // Print the summary data.
// cout << "maxX = " << map["maxX"] << " " << "minX = " << map["minX"] << " " << "maxY = " << map["maxY"] << " " << "minY = " << map["minY"] << " " << "maxZ = " << map["maxZ"] << " " << "minZ = " << map["minZ"] << " " << endl;
// Bounds maxBound = Bounds(Point(map["minX"], map["minY"], map["minZ"]), Point(map["maxX"], map["maxY"], map["maxZ"]));
// // RTree test
// cout << "----------------------------------Build the Rtree---------------------------------" << endl;
// startTime = std::chrono::high_resolution_clock::now();
// RTreePoints* Rtree = new RTreePoints;
// RInsert(Rtree, points);
// endTime = std::chrono::high_resolution_clock::now();
// duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
// cout<< "Buiding the Rtree cost " <<duration.count()<< "ms"<<endl;
// // Octree+Rtree Coordinate test.
// cout << "----------------------------------Begin the experiments---------------------------------" << endl;
// std::list<string> result_time_cost;
// for (float i = 1.0; i < 100.0; i++){
// std::vector<Point> results;
// // Get the random points.
// std::vector<Point> query_points = getRandomPoints(points, i * points.size() / 10000.0);
// std::unordered_map<std::string, float> query_map = Summary(query_points);
// // Compoute the bound in this loop.
// float tmp_minX = query_map["minX"];
// float tmp_maxX = query_map["maxX"];
// float tmp_minY = query_map["minY"];
// float tmp_maxY = query_map["maxY"];
// float tmp_minZ = query_map["minZ"];
// float tmp_maxZ = query_map["maxZ"];
// Point pmin = Point(tmp_minX, tmp_minY, tmp_minZ);
// Point pmax = Point(tmp_maxX, tmp_maxY, tmp_maxZ);
// Bounds bound = Bounds(pmin, pmax);
// auto startTime = std::chrono::high_resolution_clock::now();
// RSearch(Rtree, results, bound);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
// // Make the bounds words
// string bound_words = "The bound is (" + to_string(tmp_minX) + ", " + to_string(tmp_maxX) + "), (" + to_string(tmp_minY) + ", " + to_string(tmp_maxY) + "), (" + to_string(tmp_minZ) + ", " + to_string(tmp_maxZ) + ")." + " Time cost = " + to_string(duration.count())+" microseconds." + "find " + to_string(results.size()) + " points.";
// result_time_cost.push_back(bound_words);
// cout << bound_words << endl;
// }
// write_result("result_montreal/Result_R.txt", result_time_cost);
// // Read in data.
// auto startTime = std::chrono::high_resolution_clock::now();
// cout << "----------------------------------Reading data---------------------------------" << endl;
// vector<Point> points = GetDataFromSingleCSV("data_csv/whampoa_0521.csv");
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
// cout<< "Reading data cost " <<duration.count()<< "ms"<<endl;
// // Get the summary data.
// cout << "----------------------------------Process data summary---------------------------------" << endl;
// std::unordered_map<std::string, float> map = Summary(points);
// // Print the summary data.
// cout<< "maxTime = " << map["maxTime"] << " " << "minTime = " << map["minTime"] << " " << "maxX = " << map["maxX"] << " " << "minX = " << map["minX"] << " " << "maxY = " << map["maxY"] << " " << "minY = " << map["minY"] << " " << "maxZ = " << map["maxZ"] << " " << "minZ = " << map["minZ"] << " " << endl;
// // compute the fixed bound.
// Point Cmin = Point(7./10. *map["minX"] + 3./10. * map["maxX"],7./10. *map["minY"] + 3./10. * map["maxY"],7./10. *map["minZ"] + 3./10. * map["maxZ"]);
// Point Cmax = Point(3./10. *map["minX"] + 7./10. * map["maxX"],3./10. *map["minY"] + 7./10. * map["maxY"],3./10. *map["minZ"] + 7./10. * map["maxZ"]);
// Bounds fixedBound = Bounds(Cmin, Cmax);
// // Compute the fixed time query
// float Tmin = 7./10. *map["minTime"] + 3./10. * map["maxTime"];
// float Tmax = 3./10. *map["minTime"] + 7./10. * map["maxTime"];
// // Build hrtree
// cout << "----------------------------------Build the hrtree---------------------------------" << endl;
// startTime = std::chrono::high_resolution_clock::now();
// HRTree* tree = new HRTree(points);
// endTime = std::chrono::high_resolution_clock::now();
// duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
// cout<< "Buiding the hrtree cost " <<duration.count()<< "ms"<<endl;
// // HRTree Coordinate test.
// cout << "----------------------------------Begin the Coordinate experiments---------------------------------" << endl;
// std::list<string> result_time_cost;
// for (float i = 1.0; i < 100; i++){
// std::vector<Point> results;
// // Compoute the bound in this loop.
// float tmp_minX = (143.0+i * 57.0/100.0) / 200.0 * map["minX"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxX"];
// float tmp_maxX = (57.0-i * 57.0/100.0) / 200.0 * map["minX"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxX"];
// float tmp_minY = (143.0+i * 57.0/100.0) / 200.0 * map["minY"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxY"];
// float tmp_maxY = (57.0-i * 57.0/100.0) / 200.0 * map["minY"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxY"];
// float tmp_minZ = (143.0+i * 57.0/100.0) / 200.0 * map["minZ"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxZ"];
// float tmp_maxZ = (57.0-i * 57.0/100.0) / 200.0 * map["minZ"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxZ"];
// Point pmin = Point(tmp_minX, tmp_minY, tmp_minZ);
// Point pmax = Point(tmp_maxX, tmp_maxY, tmp_maxZ);
// Bounds bound = Bounds(pmin, pmax);
// auto startTime = std::chrono::high_resolution_clock::now();
// tree->HRTreeSearch(Tmin, Tmax, results, bound);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
// // Make the bounds words
// string bound_words = "The bound is (" + to_string(tmp_minX) + ", " + to_string(tmp_maxX) + "), (" + to_string(tmp_minY) + ", " + to_string(tmp_maxY) + "), (" + to_string(tmp_minZ) + ", " + to_string(tmp_maxZ) + ") with time bound (" + to_string(Tmin) + ", " + to_string(Tmax) + ")." + " Time cost = " + to_string(duration.count())+" microseconds." + "find " + to_string(results.size()) + " points.";
// result_time_cost.push_back(bound_words);
// cout << bound_words << endl;
// }
// write_result("result/FtimeRVbound_HR.txt", result_time_cost);
// // HRTree Time test
// cout << "----------------------------------Begin the Time experiments---------------------------------" << endl;
// std::list<string> result_time_cost;
// for (float i = 1.0; i < 100; i++){
// std::vector<Point> results;
// float tmp_minT = (100.0+i) / 200.0 * map["minTime"] + (100.0-i) / 200.0 * map["maxTime"];
// float tmp_maxT = (100.0-i) / 200.0 * map["minTime"] + (100.0+i) / 200.0 * map["maxTime"];
// // Compoute the bound in this loop.
// auto startTime = std::chrono::high_resolution_clock::now();
// tree->HRTreeSearch(tmp_minT, tmp_maxT, results, fixedBound);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
// // Make the bounds words
// string bound_words = "The bound is (" + to_string(fixedBound.min.x) + ", " + to_string(fixedBound.max.x) + "), (" + to_string(fixedBound.min.y) + ", " + to_string(fixedBound.max.x) + "), (" + to_string(fixedBound.min.z) + ", " + to_string(fixedBound.max.x) + ") with time bound (" + to_string(tmp_minT) + ", " + to_string(tmp_maxT) + ")." + " Time cost = " + to_string(duration.count())+" microseconds." + "find " + to_string(results.size()) + " points.";
// result_time_cost.push_back(bound_words);
// cout << bound_words << endl;
// }
// write_result("result/FboundRVtime_HR.txt", result_time_cost);
// // RTree test
// cout << "----------------------------------Build the Rtree---------------------------------" << endl;
// startTime = std::chrono::high_resolution_clock::now();
// RTreePoints* Rtree = new RTreePoints;
// RInsert(Rtree, points);
// endTime = std::chrono::high_resolution_clock::now();
// duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
// cout<< "Buiding the Rtree cost " <<duration.count()<< "ms"<<endl;
// // Coordinate test.
// cout << "----------------------------------Begin the Coordinate experiments---------------------------------" << endl;
// std::list<string> result_time_cost;
// for (float i = 1.0; i < 100; i++){
// std::vector<Point> results;
// // Compoute the bound in this loop.
// float tmp_minX = (143.0+i * 57.0/100.0) / 200.0 * map["minX"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxX"];
// float tmp_maxX = (57.0-i * 57.0/100.0) / 200.0 * map["minX"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxX"];
// float tmp_minY = (143.0+i * 57.0/100.0) / 200.0 * map["minY"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxY"];
// float tmp_maxY = (57.0-i * 57.0/100.0) / 200.0 * map["minY"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxY"];
// float tmp_minZ = (143.0+i * 57.0/100.0) / 200.0 * map["minZ"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxZ"];
// float tmp_maxZ = (57.0-i * 57.0/100.0) / 200.0 * map["minZ"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxZ"];
// Point pmin = Point(tmp_minX, tmp_minY, tmp_minZ);
// Point pmax = Point(tmp_maxX, tmp_maxY, tmp_maxZ);
// Bounds bound = Bounds(pmin, pmax);
// auto startTime = std::chrono::high_resolution_clock::now();
// RSearch(Rtree, results, bound);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
// // Make the bounds words
// string bound_words = "The bound is (" + to_string(tmp_minX) + ", " + to_string(tmp_maxX) + "), (" + to_string(tmp_minY) + ", " + to_string(tmp_maxY) + "), (" + to_string(tmp_minZ) + ", " + to_string(tmp_maxZ) + ") Time cost = " + to_string(duration.count())+" microseconds." + "find " + to_string(results.size()) + " points.";
// result_time_cost.push_back(bound_words);
// cout << bound_words << endl;
// }
// write_result("result/RVbound_R.txt", result_time_cost);
// // RTreeT Coordinate test
// cout << "----------------------------------Build the RtreeT---------------------------------" << endl;
// startTime = std::chrono::high_resolution_clock::now();
// RTreeT* RtreeT = new RTreeT;
// RTInsert(RtreeT, points);
// endTime = std::chrono::high_resolution_clock::now();
// duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
// cout<< "Buiding the RtreeT cost " <<duration.count()<< "ms"<<endl;
// // Coordinate test.
// cout << "----------------------------------Begin the Coordinate experiments---------------------------------" << endl;
// std::list<string> result_time_cost;
// for (float i = 1.0; i < 100; i++){
// std::vector<Point> results;
// // Compoute the bound in this loop.
// float tmp_minX = (143.0+i * 57.0/100.0) / 200.0 * map["minX"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxX"];
// float tmp_maxX = (57.0-i * 57.0/100.0) / 200.0 * map["minX"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxX"];
// float tmp_minY = (143.0+i * 57.0/100.0) / 200.0 * map["minY"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxY"];
// float tmp_maxY = (57.0-i * 57.0/100.0) / 200.0 * map["minY"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxY"];
// float tmp_minZ = (143.0+i * 57.0/100.0) / 200.0 * map["minZ"] + (57.0-i * 57.0/100.0) / 200.0 * map["maxZ"];
// float tmp_maxZ = (57.0-i * 57.0/100.0) / 200.0 * map["minZ"] + (143.0+i * 57.0/100.0) / 200.0 * map["maxZ"];
// Point pmin = Point(tmp_minX, tmp_minY, tmp_minZ, -1, -1, -1, "", Tmin);
// Point pmax = Point(tmp_maxX, tmp_maxY, tmp_maxZ, -1, -1, -1, "", Tmax);
// Bounds bound = Bounds(pmin, pmax);
// auto startTime = std::chrono::high_resolution_clock::now();
// RTSearch(RtreeT, results, bound);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
// // Make the bounds words
// string bound_words = "The bound is (" + to_string(tmp_minX) + ", " + to_string(tmp_maxX) + "), (" + to_string(tmp_minY) + ", " + to_string(tmp_maxY) + "), (" + to_string(tmp_minZ) + ", " + to_string(tmp_maxZ) + ") with time bound (" + to_string(Tmin) + ", " + to_string(Tmax) + ")." + " Time cost = " + to_string(duration.count())+" microseconds." + "find " + to_string(results.size()) + " points.";
// result_time_cost.push_back(bound_words);
// cout << bound_words << endl;
// }
// write_result("result/FtimeRVbound_RT.txt", result_time_cost);
// // Time test.
// // HRTree Time test
// cout << "----------------------------------Begin the Time experiments---------------------------------" << endl;
// std::list<string> result_time_cost;
// for (float i = 1.0; i < 100; i++){
// std::vector<Point> results;
// float tmp_minT = (100.0+i) / 200.0 * map["minTime"] + (100.0-i) / 200.0 * map["maxTime"];
// float tmp_maxT = (100.0-i) / 200.0 * map["minTime"] + (100.0+i) / 200.0 * map["maxTime"];
// // Compoute the bound in this loop.
// Point pmin = Point(map["minX"],map["minY"],map["minZ"], -1, -1, -1, "", tmp_minT);
// Point pmax = Point(map["maxX"],map["maxY"],map["maxZ"], -1, -1, -1, "", tmp_maxT);
// Bounds bound = Bounds(pmin, pmax);
// auto startTime = std::chrono::high_resolution_clock::now();
// RTSearch(RtreeT, results, bound);
// auto endTime = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
// // Make the bounds words
// string bound_words = "The bound is (" + to_string(fixedBound.min.x) + ", " + to_string(fixedBound.max.x) + "), (" + to_string(fixedBound.min.y) + ", " + to_string(fixedBound.max.x) + "), (" + to_string(fixedBound.min.z) + ", " + to_string(fixedBound.max.x) + ") with time bound (" + to_string(tmp_minT) + ", " + to_string(tmp_maxT) + ")." + " Time cost = " + to_string(duration.count())+" microseconds." + "find " + to_string(results.size()) + " points.";
// result_time_cost.push_back(bound_words);
// cout << bound_words << endl;
// }
// write_result("result/FboundRVtime_RT.txt", result_time_cost);
// // Some test.
// HRTree* tree = new HRTree(points);
// // // tree->print_tree();
// std::vector<Point> results;
// Point min = Point(0,0,0);
// Point max = Point(15,15,15);
// Bounds bound = Bounds(min, max);
// tree->HRTreeSearch(1.2, 1.2, results, bound);
// for (Point point : results) point.print_point();
return 0;
}