-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsweepline_state.hpp
47 lines (37 loc) · 1.13 KB
/
sweepline_state.hpp
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
#ifndef SWEEPLINE_STATE_HPP
#define SWEEPLINE_STATE_HPP
#include "point.hpp"
#include <deque>
#include <vector>
class sweepline_state
{
public:
sweepline_state(const std::vector<coordinate>& coordinates, unsigned start_vertex)
: coordinates(coordinates)
, sweepline_start(coordinates[start_vertex])
{
}
using edge = std::pair<unsigned, unsigned>;
using edge_list = std::deque<edge>;
using edge_iterator = edge_list::const_iterator;
edge_list intersecting_edges;
void move_sweepline(const coordinate& position);
void insert_edge(const edge& edge);
void remove_edge(const edge& edge);
edge_iterator get_first_intersecting(const coordinate& coord) const;
private:
bool edge_comparator(const sweepline_state::edge& lhs, const sweepline_state::edge& rhs) const;
const std::vector<coordinate>& coordinates;
coordinate sweepline_start;
coordinate sweepline_end;
};
namespace std
{
template<typename FirstT, typename SecondT>
std::ostream& operator<<(std::ostream& lhs, const std::pair<FirstT, SecondT>& rhs)
{
lhs << rhs.first << " -> " << rhs.second;
return lhs;
}
}
#endif