GEOS 3.9.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 noding {
36class SegmentString;
37}
38namespace algorithm {
39class LineIntersector;
40}
41}
42
43namespace geos {
44namespace noding { // geos.noding
45
57class GEOS_DLL IntersectionAdder: public SegmentIntersector {
58
59private:
60
65 bool hasIntersectionVar;
66 bool hasProper;
67 bool hasProperInterior;
68 bool hasInterior;
69
70 // the proper intersection point found
71 geom::Coordinate properIntersectionPoint;
72
74 // bool isSelfIntersection;
75 // bool intersectionFound;
76
83 bool isTrivialIntersection(const SegmentString* e0, size_t segIndex0,
84 const SegmentString* e1, size_t segIndex1);
85
86 // Declare type as noncopyable
87 IntersectionAdder(const IntersectionAdder& other) = delete;
88 IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
89
90public:
91
92 int numIntersections;
93 int numInteriorIntersections;
94 int numProperIntersections;
95
96 // testing only
97 int numTests;
98
100 :
101 hasIntersectionVar(false),
102 hasProper(false),
103 hasProperInterior(false),
104 hasInterior(false),
105 properIntersectionPoint(),
106 li(newLi),
107 numIntersections(0),
108 numInteriorIntersections(0),
109 numProperIntersections(0),
110 numTests(0)
111 {}
112
114 getLineIntersector()
115 {
116 return li;
117 }
118
123 const geom::Coordinate&
125 {
126 return properIntersectionPoint;
127 }
128
129 bool
130 hasIntersection()
131 {
132 return hasIntersectionVar;
133 }
134
144 bool
146 {
147 return hasProper;
148 }
149
154 bool
156 {
157 return hasProperInterior;
158 }
159
164 bool
166 {
167 return hasInterior;
168 }
169
170
180 SegmentString* e0, size_t segIndex0,
181 SegmentString* e1, size_t segIndex1) override;
182
183
184 static bool
185 isAdjacentSegments(size_t i1, size_t i2)
186 {
187 return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
188 }
189
195 bool
196 isDone() const override
197 {
198 return false;
199 }
200};
201
202
203} // namespace geos.noding
204} // namespace geos
205
206#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:57
bool hasInteriorIntersection()
An interior intersection is an intersection which is in the interior of some segment.
Definition IntersectionAdder.h:165
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...
bool hasProperInteriorIntersection()
A proper interior intersection is a proper intersection which is not contained in the set of boundary...
Definition IntersectionAdder.h:155
const geom::Coordinate & getProperIntersectionPoint()
Definition IntersectionAdder.h:124
bool isDone() const override
Always process all intersections.
Definition IntersectionAdder.h:196
bool hasProperIntersection()
A proper intersection is an intersection which is interior to at least two line segments.
Definition IntersectionAdder.h:145
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:26