GEOS  3.9.1dev
SimpleMCSweepLineIntersector.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_SIMPLEMCSWEEPLINEINTERSECTOR_H
17 #define GEOS_GEOMGRAPH_INDEX_SIMPLEMCSWEEPLINEINTERSECTOR_H
18 
19 #include <geos/export.h>
20 #include <memory>
21 #include <vector>
22 
23 #include <geos/geomgraph/index/EdgeSetIntersector.h> // for inheritance
27 
28 #ifdef _MSC_VER
29 #pragma warning(push)
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31 #endif
32 
33 // Forward declarations
34 namespace geos {
35 namespace geomgraph {
36 class Edge;
37 }
38 }
39 
40 namespace geos {
41 namespace geomgraph { // geos::geomgraph
42 namespace index { // geos::geomgraph::index
43 
54 
55 public:
56 
57  SimpleMCSweepLineIntersector() = default;
58 
59  ~SimpleMCSweepLineIntersector() override = default;
60 
61  void computeIntersections(std::vector<Edge*>* edges,
62  SegmentIntersector* si, bool testAllSegments) override;
63 
64  void computeIntersections(std::vector<Edge*>* edges0,
65  std::vector<Edge*>* edges1,
66  SegmentIntersector* si) override;
67 
68 protected:
69 
70  // SweepLineEvents need to refer to each other, and to MonotoneChains.
71  // To avoid individually heap-allocating all of these, we store them
72  // in deques so that subsequent inserts preserve addresses. However,
73  // we also need to sort the SweepLineEvents after they have all been
74  // inserted, so we keep a pointer to each event in a separate vector,
75  // which can be freely reordered without breaking linkages.
76  std::vector<SweepLineEvent*> events;
77  std::deque<SweepLineEvent> eventStore;
78  std::deque<MonotoneChain> chains;
79 
80  // statistics information
81  int nOverlaps;
82 
83 private:
84  void add(std::vector<Edge*>* edges);
85 
86  void add(std::vector<Edge*>* edges, void* edgeSet);
87 
88  void add(Edge* edge, void* edgeSet);
89 
90  void prepareEvents();
91 
92  void computeIntersections(SegmentIntersector* si);
93 
94  void processOverlaps(size_t start, size_t end,
95  SweepLineEvent* ev0,
96  SegmentIntersector* si);
97  // Declare type as noncopyable
99  SimpleMCSweepLineIntersector& operator=(const SimpleMCSweepLineIntersector& rhs) = delete;
100 };
101 
102 } // namespace geos.geomgraph.index
103 } // namespace geos.geomgraph
104 } // namespace geos
105 
106 #ifdef _MSC_VER
107 #pragma warning(pop)
108 #endif
109 
110 #endif // GEOS_GEOMGRAPH_INDEX_SIMPLEMCSWEEPLINEINTERSECTOR_H
111 
#define GEOS_DLL
Definition: export.h:28
Computes the intersection of line segments, and adds the intersection to the edges containing the seg...
An EdgeSetIntersector computes all the intersections between the edges in the set.
Finds all intersections in one or two sets of edges, using an x-axis sweepline algorithm in conjuncti...
Basic namespace for all GEOS functionalities.