-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFASTCOVER.h
46 lines (34 loc) · 1.2 KB
/
FASTCOVER.h
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
//
// Created by Ghosh, Anirban on 11/11/21.
//
#ifndef UDC_FASTCOVER_H
#define UDC_FASTCOVER_H
#include <chrono>
#include <list>
#include <vector>
#include <unordered_set>
#include <CGAL/Cartesian.h>
typedef CGAL::Cartesian<double>::Point_2 Point;
class FASTCOVER {
std::vector<Point> &P;
std::list<Point> &diskCenters;
typedef std::pair<int,int> intPair;
typedef std::unordered_set<intPair,boost::hash<intPair>> SetOfCells;
const double sqrt2 = std::sqrt(2);
const double additiveFactor = sqrt2/2;
public:
FASTCOVER(std::vector<Point> &P, std::list<Point> &diskCenters) : P(P), diskCenters(diskCenters) { }
double execute() {
assert(!P.empty());
auto start = std::chrono::high_resolution_clock::now();
SetOfCells S;
for(const Point &p : P)
S.insert(std::make_pair(floor(p.x()/sqrt2),floor(p.y()/sqrt2)));
for(auto pair : S)
diskCenters.emplace_back(Point(pair.first*sqrt2+additiveFactor,pair.second*sqrt2+additiveFactor));
auto stop = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> duration = stop - start;
return duration.count();
}
};
#endif //UDC_FASTCOVER_H