GEOS  3.9.1dev
geomgraph/index/SweepLineEvent.h
Go to the documentation of this file.
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
24 namespace geos {
25 namespace geomgraph {
26 namespace index {
27 class SweepLineEventOBJ;
28 }
29 }
30 }
31 
32 namespace geos {
33 namespace geomgraph { // geos::geomgraph
34 namespace index { // geos::geomgraph::index
35 
36 //class SweepLineEventLessThen; // needed ??
37 
38 class GEOS_DLL SweepLineEvent final {
39  friend class SweepLineEventLessThen;
40 
41 public:
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
56  {
57  return insertEvent == nullptr;
58  }
59 
60  bool
62  {
63  return insertEvent != nullptr;
64  }
65 
66  int
68  {
69  return insertEvent == nullptr ? INSERT_EVENT : DELETE_EVENT;
70  }
71 
74  {
75  return insertEvent;
76  }
77 
78  size_t
80  {
81  return deleteEventIndex;
82  }
83 
84  void
85  setDeleteEventIndex(size_t newDeleteEventIndex)
86  {
87  deleteEventIndex = newDeleteEventIndex;
88  }
89 
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 
102 protected:
103 
105 
106 private:
107 
108  double xValue;
109 
110  SweepLineEvent* insertEvent; // null if this is an INSERT_EVENT event
111 
113 };
114 
116 public:
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 
#define GEOS_DLL
Definition: export.h:28
void setDeleteEventIndex(size_t newDeleteEventIndex)
Basic namespace for all GEOS functionalities.