GEOS 3.11.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#pragma once
17
18#include <geos/export.h>
19#include <string>
20
21// Forward declarations
22namespace geos {
23namespace geomgraph {
24namespace index {
25class SweepLineEventOBJ;
26}
27}
28}
29
30namespace geos {
31namespace geomgraph { // geos::geomgraph
32namespace index { // geos::geomgraph::index
33
34//class SweepLineEventLessThen; // needed ??
35
36class GEOS_DLL SweepLineEvent final {
37 friend class SweepLineEventLessThen;
38
39public:
40
41 enum {
42 INSERT_EVENT = 1,
43 DELETE_EVENT
44 };
45
46 SweepLineEvent(void* newEdgeSet, double x,
47 SweepLineEvent* newInsertEvent,
48 SweepLineEventOBJ* newObj);
49
50 ~SweepLineEvent() = default;
51
52 bool
53 isInsert()
54 {
55 return insertEvent == nullptr;
56 }
57
58 bool
59 isDelete()
60 {
61 return insertEvent != nullptr;
62 }
63
64 int
65 eventType()
66 {
67 return insertEvent == nullptr ? INSERT_EVENT : DELETE_EVENT;
68 }
69
70 SweepLineEvent*
71 getInsertEvent()
72 {
73 return insertEvent;
74 }
75
76 size_t
77 getDeleteEventIndex()
78 {
79 return deleteEventIndex;
80 }
81
82 void
83 setDeleteEventIndex(std::size_t newDeleteEventIndex)
84 {
85 deleteEventIndex = newDeleteEventIndex;
86 }
87
88 SweepLineEventOBJ*
89 getObject() const
90 {
91 return obj;
92 }
93
94 int compareTo(SweepLineEvent* sle);
95
96 std::string print();
97
98 void* edgeSet; // used for red-blue intersection detection
99
100protected:
101
102 SweepLineEventOBJ* obj;
103
104private:
105
106 double xValue;
107
108 SweepLineEvent* insertEvent; // null if this is an INSERT_EVENT event
109
110 std::size_t deleteEventIndex;
111};
112
113class GEOS_DLL SweepLineEventLessThen {
114public:
115 template<typename T>
116 bool
117 operator()(const T& f, const T& s) const
118 {
119 if(f->xValue < s->xValue) {
120 return true;
121 }
122 if(f->xValue > s->xValue) {
123 return false;
124 }
125 if(f->eventType() < s->eventType()) {
126 return true;
127 }
128 return false;
129 }
130};
131
132
133} // namespace geos.geomgraph.index
134} // namespace geos.geomgraph
135} // namespace geos
136
Basic namespace for all GEOS functionalities.
Definition: geos.h:39