/src/geos/include/geos/geomgraph/index/SegmentIntersector.h
Line | Count | Source |
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 <array> |
20 | | #include <vector> |
21 | | |
22 | | #include <geos/geom/Coordinate.h> // for composition |
23 | | |
24 | | #ifdef _MSC_VER |
25 | | #pragma warning(push) |
26 | | #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class |
27 | | #endif |
28 | | |
29 | | // Forward declarations |
30 | | namespace geos { |
31 | | namespace algorithm { |
32 | | class LineIntersector; |
33 | | } |
34 | | namespace geomgraph { |
35 | | class Node; |
36 | | class Edge; |
37 | | } |
38 | | } |
39 | | |
40 | | namespace geos { |
41 | | namespace geomgraph { // geos::geomgraph |
42 | | namespace index { // geos::geomgraph::index |
43 | | |
44 | | /// \brief Computes the intersection of line segments, and adds the |
45 | | /// intersection to the edges containing the segments. |
46 | | class GEOS_DLL SegmentIntersector { |
47 | | |
48 | | private: |
49 | | |
50 | | /** |
51 | | * These variables keep track of what types of intersections were |
52 | | * found during ALL edges that have been intersected. |
53 | | */ |
54 | | bool hasIntersectionVar; |
55 | | |
56 | | bool hasProper; |
57 | | |
58 | | bool hasProperInterior; |
59 | | |
60 | | /// the proper intersection point found |
61 | | geom::Coordinate properIntersectionPoint; |
62 | | |
63 | | algorithm::LineIntersector* li; |
64 | | |
65 | | bool includeProper; |
66 | | |
67 | | bool recordIsolated; |
68 | | |
69 | | int numIntersections; |
70 | | |
71 | | /// Elements are externally owned |
72 | | std::array<std::vector<Node*>*, 2> bdyNodes; |
73 | | |
74 | | bool isTrivialIntersection(Edge* e0, std::size_t segIndex0, Edge* e1, std::size_t segIndex1); |
75 | | |
76 | | bool isBoundaryPoint(algorithm::LineIntersector* p_li, |
77 | | std::array<std::vector<Node*>*, 2>& tstBdyNodes) |
78 | 0 | { |
79 | 0 | return isBoundaryPoint(p_li, tstBdyNodes[0]) || isBoundaryPoint(p_li, tstBdyNodes[1]); |
80 | 0 | }; |
81 | | |
82 | | bool isBoundaryPoint(algorithm::LineIntersector* li, |
83 | | std::vector<Node*>* tstBdyNodes); |
84 | | |
85 | | public: |
86 | | |
87 | | static bool isAdjacentSegments(std::size_t i1, size_t i2) |
88 | 0 | { |
89 | 0 | return (i1 > i2 ? i1 - i2 : i2 - i1) == 1; |
90 | 0 | }; |
91 | | |
92 | | // testing only |
93 | | int numTests; |
94 | | |
95 | | //SegmentIntersector(); |
96 | | |
97 | | virtual |
98 | 0 | ~SegmentIntersector() {} |
99 | | |
100 | | SegmentIntersector(algorithm::LineIntersector* newLi, |
101 | | bool newIncludeProper, bool newRecordIsolated) |
102 | | : |
103 | 0 | hasIntersectionVar(false), |
104 | 0 | hasProper(false), |
105 | 0 | hasProperInterior(false), |
106 | 0 | li(newLi), |
107 | 0 | includeProper(newIncludeProper), |
108 | 0 | recordIsolated(newRecordIsolated), |
109 | 0 | numIntersections(0), |
110 | 0 | bdyNodes{{nullptr, nullptr}}, |
111 | 0 | numTests(0) |
112 | 0 | {} |
113 | | |
114 | | /// \brief |
115 | | /// Parameters are externally owned. |
116 | | /// Make sure they live for the whole lifetime of this object |
117 | | void setBoundaryNodes(std::vector<Node*>* bdyNodes0, |
118 | | std::vector<Node*>* bdyNodes1) |
119 | 0 | { |
120 | 0 | bdyNodes[0] = bdyNodes0; |
121 | 0 | bdyNodes[1] = bdyNodes1; |
122 | 0 | }; |
123 | | |
124 | | /* |
125 | | * @return the proper intersection point, or <code>null</code> |
126 | | * if none was found |
127 | | */ |
128 | | geom::Coordinate& getProperIntersectionPoint() |
129 | 0 | { |
130 | 0 | return properIntersectionPoint; |
131 | 0 | }; |
132 | | |
133 | | bool hasIntersection() const |
134 | 0 | { |
135 | 0 | return hasIntersectionVar; |
136 | 0 | }; |
137 | | |
138 | | /** |
139 | | * A proper intersection is an intersection which is interior to at least two |
140 | | * line segments. Note that a proper intersection is not necessarily |
141 | | * in the interior of the entire Geometry, since another edge may have |
142 | | * an endpoint equal to the intersection, which according to SFS semantics |
143 | | * can result in the point being on the Boundary of the Geometry. |
144 | | */ |
145 | | bool hasProperIntersection() const |
146 | 0 | { |
147 | 0 | return hasProper; |
148 | 0 | }; |
149 | | |
150 | | /** |
151 | | * A proper interior intersection is a proper intersection which is <b>not</b> |
152 | | * contained in the set of boundary nodes set for this SegmentIntersector. |
153 | | */ |
154 | | bool hasProperInteriorIntersection() const |
155 | 0 | { |
156 | 0 | return hasProperInterior; |
157 | 0 | }; |
158 | | |
159 | | void addIntersections(Edge* e0, std::size_t segIndex0, Edge* e1, std::size_t segIndex1); |
160 | | |
161 | | bool getIsDone() const |
162 | 0 | { |
163 | 0 | return false; |
164 | 0 | }; |
165 | | |
166 | | |
167 | | }; |
168 | | |
169 | | } // namespace geos.geomgraph.index |
170 | | } // namespace geos.geomgraph |
171 | | } // namespace geos |
172 | | |
173 | | |
174 | | #ifdef _MSC_VER |
175 | | #pragma warning(pop) |
176 | | #endif |