GEOS 3.14.0dev
geomgraph/index/SegmentIntersector.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 <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
30namespace geos {
31namespace algorithm {
32class LineIntersector;
33}
34namespace geomgraph {
35class Node;
36class Edge;
37}
38}
39
40namespace geos {
41namespace geomgraph { // geos::geomgraph
42namespace index { // geos::geomgraph::index
43
46class GEOS_DLL SegmentIntersector {
47
48private:
49
54 bool hasIntersectionVar;
55
56 bool hasProper;
57
58 bool hasProperInterior;
59
61 geom::Coordinate properIntersectionPoint;
62
64
65 bool includeProper;
66
67 bool recordIsolated;
68
69 int numIntersections;
70
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 {
79 return isBoundaryPoint(p_li, tstBdyNodes[0]) || isBoundaryPoint(p_li, tstBdyNodes[1]);
80 };
81
82 bool isBoundaryPoint(algorithm::LineIntersector* li,
83 std::vector<Node*>* tstBdyNodes);
84
85public:
86
87 static bool isAdjacentSegments(std::size_t i1, size_t i2)
88 {
89 return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
90 };
91
92 // testing only
93 int numTests;
94
95 //SegmentIntersector();
96
97 virtual
99
101 bool newIncludeProper, bool newRecordIsolated)
102 :
103 hasIntersectionVar(false),
104 hasProper(false),
105 hasProperInterior(false),
106 li(newLi),
107 includeProper(newIncludeProper),
108 recordIsolated(newRecordIsolated),
109 numIntersections(0),
110 bdyNodes{{nullptr, nullptr}},
111 numTests(0)
112 {}
113
117 void setBoundaryNodes(std::vector<Node*>* bdyNodes0,
118 std::vector<Node*>* bdyNodes1)
119 {
120 bdyNodes[0] = bdyNodes0;
121 bdyNodes[1] = bdyNodes1;
122 };
123
124 /*
125 * @return the proper intersection point, or <code>null</code>
126 * if none was found
127 */
128 geom::Coordinate& getProperIntersectionPoint()
129 {
130 return properIntersectionPoint;
131 };
132
133 bool hasIntersection() const
134 {
135 return hasIntersectionVar;
136 };
137
146 {
147 return hasProper;
148 };
149
155 {
156 return hasProperInterior;
157 };
158
159 void addIntersections(Edge* e0, std::size_t segIndex0, Edge* e1, std::size_t segIndex1);
160
161 bool getIsDone() const
162 {
163 return false;
164 };
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
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
Definition geomgraph/Edge.h:63
Computes the intersection of line segments, and adds the intersection to the edges containing the seg...
Definition geomgraph/index/SegmentIntersector.h:46
bool hasProperInteriorIntersection() const
Definition geomgraph/index/SegmentIntersector.h:154
bool hasProperIntersection() const
Definition geomgraph/index/SegmentIntersector.h:145
void setBoundaryNodes(std::vector< Node * > *bdyNodes0, std::vector< Node * > *bdyNodes1)
Parameters are externally owned. Make sure they live for the whole lifetime of this object.
Definition geomgraph/index/SegmentIntersector.h:117
Basic namespace for all GEOS functionalities.
Definition geos.h:39