-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvent.cpp
65 lines (49 loc) · 1.41 KB
/
Event.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
#include "Event.hpp"
Event::Event(){}
Event::Event(const Point& p, const Segment& seg, EventType type){
this->point = p;
this->segs.push_back(seg);
this->type = type;
this->value = p.x;
}
Event::Event(const Point& p, const std::vector<Segment> seg, EventType type){
this->point = p;
this->type = type;
this->value = p.x;
this->segs = seg;
}
Point Event::getPoint() const{
return point;
}
std::vector<Segment> Event::getSegments() const{
return segs;
}
double Event::getValue() const{
return value;
}
EventType Event::getType() const{
return type;
}
bool Event::operator() (const Event& lhs, const Event& rhs) const{
return lhs.value > rhs.value;
}
bool Event::equals(const Event& e) const{
if(e.type == segsintersection){
if((segs.at(0).equals(e.segs.at(0)) && segs.at(1).equals(e.segs.at(1))) || (segs.at(1).equals(e.segs.at(0)) && segs.at(0).equals(e.segs.at(1)))){
return true;
}
}else{
if(segs.at(0).equals(e.segs.at(0))) return true;
}
return false;
}
std::ostream& operator<<(std::ostream& os, const Event& e){
os << "value = " << e.getValue() << "; ";
if(e.getType() == segsintersection){
os << "intersection - s1 = " << e.getSegments().at(0) << "; s2 = " << e.getSegments().at(1);
}else{
os << "start or end - s1 = " << e.getSegments().at(0);
}
os << std::endl;
return os;
}