GEOS  3.8.0dev
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
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 {
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  virtual ~SweepLineEvent();
53 
54  bool
55  isInsert()
56  {
57  return insertEvent == nullptr;
58  }
59 
60  bool
61  isDelete()
62  {
63  return insertEvent != nullptr;
64  }
65 
66  SweepLineEvent*
67  getInsertEvent()
68  {
69  return insertEvent;
70  }
71 
72  size_t
73  getDeleteEventIndex()
74  {
75  return deleteEventIndex;
76  }
77 
78  void
79  setDeleteEventIndex(size_t newDeleteEventIndex)
80  {
81  deleteEventIndex = newDeleteEventIndex;
82  }
83 
84  SweepLineEventOBJ*
85  getObject() const
86  {
87  return obj;
88  }
89 
90  int compareTo(SweepLineEvent* sle);
91 
92  std::string print();
93 
94  void* edgeSet; // used for red-blue intersection detection
95 
96 protected:
97 
98  SweepLineEventOBJ* obj;
99 
100 private:
101 
102  double xValue;
103 
104  int eventType;
105 
106  SweepLineEvent* insertEvent; // null if this is an INSERT_EVENT event
107 
108  size_t deleteEventIndex;
109 };
110 
111 class GEOS_DLL SweepLineEventLessThen {
112 public:
113  bool
114  operator()(const SweepLineEvent* f, const SweepLineEvent* s) const
115  {
116  if(f->xValue < s->xValue) {
117  return true;
118  }
119  if(f->xValue > s->xValue) {
120  return false;
121  }
122  if(f->eventType < s->eventType) {
123  return true;
124  }
125  return false;
126  }
127 };
128 
129 
130 
131 } // namespace geos.geomgraph.index
132 } // namespace geos.geomgraph
133 } // namespace geos
134 
135 #endif
136 
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25