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