GEOS 3.8.1
IntersectionAdder.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: noding/IntersectionAdder.java rev. 1.6 (JTS-1.9)
16 *
17 **********************************************************************/
18
19#ifndef GEOS_NODING_INTERSECTIONADDER_H
20#define GEOS_NODING_INTERSECTIONADDER_H
21
22#include <geos/export.h>
23
24#include <vector>
25#include <iostream>
26#include <cstdlib> // for abs()
27
28#include <geos/inline.h>
29
30#include <geos/geom/Coordinate.h>
31#include <geos/noding/SegmentIntersector.h> // for inheritance
32
33// Forward declarations
34namespace geos {
35namespace geom {
36class Coordinate;
37}
38namespace noding {
39class SegmentString;
40}
41namespace algorithm {
42class LineIntersector;
43}
44}
45
46namespace geos {
47namespace noding { // geos.noding
48
60class GEOS_DLL IntersectionAdder: public SegmentIntersector {
61
62private:
63
68 bool hasIntersectionVar;
69 bool hasProper;
70 bool hasProperInterior;
71 bool hasInterior;
72
73 // the proper intersection point found
74 const geom::Coordinate* properIntersectionPoint;
75
77 // bool isSelfIntersection;
78 // bool intersectionFound;
79
86 bool isTrivialIntersection(const SegmentString* e0, size_t segIndex0,
87 const SegmentString* e1, size_t segIndex1);
88
89 // Declare type as noncopyable
90 IntersectionAdder(const IntersectionAdder& other) = delete;
91 IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
92
93public:
94
95 int numIntersections;
96 int numInteriorIntersections;
97 int numProperIntersections;
98
99 // testing only
100 int numTests;
101
103 :
104 hasIntersectionVar(false),
105 hasProper(false),
106 hasProperInterior(false),
107 hasInterior(false),
108 properIntersectionPoint(nullptr),
109 li(newLi),
110 numIntersections(0),
111 numInteriorIntersections(0),
112 numProperIntersections(0),
113 numTests(0)
114 {}
115
117 getLineIntersector()
118 {
119 return li;
120 }
121
126 const geom::Coordinate*
128 {
129 return properIntersectionPoint;
130 }
131
132 bool
133 hasIntersection()
134 {
135 return hasIntersectionVar;
136 }
137
147 bool
149 {
150 return hasProper;
151 }
152
157 bool
159 {
160 return hasProperInterior;
161 }
162
167 bool
169 {
170 return hasInterior;
171 }
172
173
183 SegmentString* e0, size_t segIndex0,
184 SegmentString* e1, size_t segIndex1) override;
185
186
187 static bool
188 isAdjacentSegments(size_t i1, size_t i2)
189 {
190 return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
191 }
192
198 bool
199 isDone() const override
200 {
201 return false;
202 }
203};
204
205
206} // namespace geos.noding
207} // namespace geos
208
209#endif // GEOS_NODING_INTERSECTIONADDER_H
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Computes the intersections between two line segments in SegmentString and adds them to each string.
Definition: IntersectionAdder.h:60
bool hasInteriorIntersection()
An interior intersection is an intersection which is in the interior of some segment.
Definition: IntersectionAdder.h:168
void processIntersections(SegmentString *e0, size_t segIndex0, SegmentString *e1, size_t segIndex1) override
This method is called by clients of the SegmentIntersector class to process intersections for two seg...
const geom::Coordinate * getProperIntersectionPoint()
Definition: IntersectionAdder.h:127
bool hasProperInteriorIntersection()
A proper interior intersection is a proper intersection which is not contained in the set of boundary...
Definition: IntersectionAdder.h:158
bool isDone() const override
Always process all intersections.
Definition: IntersectionAdder.h:199
bool hasProperIntersection()
A proper intersection is an intersection which is interior to at least two line segments.
Definition: IntersectionAdder.h:148
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:48
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25