GEOS 3.9.1
geomgraph/index/SweepLineEvent.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************/
15
16#ifndef GEOS_GEOMGRAPH_INDEX_SWEEPLINEEVENT_H
17#define GEOS_GEOMGRAPH_INDEX_SWEEPLINEEVENT_H
18
19
20#include <geos/export.h>
21#include <string>
22
23// Forward declarations
24namespace geos {
25namespace geomgraph {
26namespace index {
27class SweepLineEventOBJ;
28}
29}
30}
31
32namespace geos {
33namespace geomgraph { // geos::geomgraph
34namespace index { // geos::geomgraph::index
35
36//class SweepLineEventLessThen; // needed ??
37
38class GEOS_DLL SweepLineEvent final {
39 friend class SweepLineEventLessThen;
40
41public:
42
43 enum {
44 INSERT_EVENT = 1,
45 DELETE_EVENT
46 };
47
48 SweepLineEvent(void* newEdgeSet, double x,
49 SweepLineEvent* newInsertEvent,
50 SweepLineEventOBJ* newObj);
51
52 ~SweepLineEvent() = default;
53
54 bool
55 isInsert()
56 {
57 return insertEvent == nullptr;
58 }
59
60 bool
61 isDelete()
62 {
63 return insertEvent != nullptr;
64 }
65
66 int
67 eventType()
68 {
69 return insertEvent == nullptr ? INSERT_EVENT : DELETE_EVENT;
70 }
71
72 SweepLineEvent*
73 getInsertEvent()
74 {
75 return insertEvent;
76 }
77
78 size_t
79 getDeleteEventIndex()
80 {
81 return deleteEventIndex;
82 }
83
84 void
85 setDeleteEventIndex(size_t newDeleteEventIndex)
86 {
87 deleteEventIndex = newDeleteEventIndex;
88 }
89
90 SweepLineEventOBJ*
91 getObject() const
92 {
93 return obj;
94 }
95
96 int compareTo(SweepLineEvent* sle);
97
98 std::string print();
99
100 void* edgeSet; // used for red-blue intersection detection
101
102protected:
103
104 SweepLineEventOBJ* obj;
105
106private:
107
108 double xValue;
109
110 SweepLineEvent* insertEvent; // null if this is an INSERT_EVENT event
111
112 size_t deleteEventIndex;
113};
114
115class GEOS_DLL SweepLineEventLessThen {
116public:
117 template<typename T>
118 bool
119 operator()(const T& f, const T& s) const
120 {
121 if(f->xValue < s->xValue) {
122 return true;
123 }
124 if(f->xValue > s->xValue) {
125 return false;
126 }
127 if(f->eventType() < s->eventType()) {
128 return true;
129 }
130 return false;
131 }
132};
133
134
135
136} // namespace geos.geomgraph.index
137} // namespace geos.geomgraph
138} // namespace geos
139
140#endif
141
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26