GEOS 3.9.1
SegmentIntersectionDetector.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
16#ifndef GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
17#define GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
18
19#include <cstddef>
20#include <geos/noding/SegmentIntersector.h>
21#include <geos/algorithm/LineIntersector.h>
22#include <geos/geom/Coordinate.h>
23#include <geos/geom/CoordinateArraySequence.h>
24#include <geos/noding/SegmentString.h>
25
26namespace geos {
27namespace noding { // geos::noding
28
43private:
45
46 bool findProper;
47 bool findAllTypes;
48
49 bool _hasIntersection;
50 bool _hasProperIntersection;
51 bool _hasNonProperIntersection;
52
53 const geom::Coordinate* intPt;
55
56protected:
57public:
59 :
60 li(p_li),
61 findProper(false),
62 findAllTypes(false),
63 _hasIntersection(false),
64 _hasProperIntersection(false),
65 _hasNonProperIntersection(false),
66 intPt(nullptr),
67 intSegments(nullptr)
68 { }
69
71 {
72 //delete intPt;
73 delete intSegments;
74 }
75
76
77 void
78 setFindProper(bool p_findProper)
79 {
80 this->findProper = p_findProper;
81 }
82
83 void
84 setFindAllIntersectionTypes(bool p_findAllTypes)
85 {
86 this->findAllTypes = p_findAllTypes;
87 }
88
94 bool
96 {
97 return _hasIntersection;
98 }
99
105 bool
107 {
108 return _hasProperIntersection;
109 }
110
116 bool
118 {
119 return _hasNonProperIntersection;
120 }
121
128 const geom::Coordinate*
130 {
131 return intPt;
132 }
133
134
142 {
143 return intSegments;
144 }
145
146 bool
147 isDone() const override
148 {
149 // If finding all types, we can stop
150 // when both possible types have been found.
151 if(findAllTypes) {
152 return _hasProperIntersection && _hasNonProperIntersection;
153 }
154
155 // If searching for a proper intersection, only stop if one is found
156 if(findProper) {
157 return _hasProperIntersection;
158 }
159
160 return _hasIntersection;
161 }
162
171 void processIntersections(noding::SegmentString* e0, size_t segIndex0,
172 noding::SegmentString* e1, size_t segIndex1) override;
173
174};
175
176} // namespace geos::noding
177} // namespace geos
178
179#endif // GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:37
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Detects and records an intersection between two SegmentStrings, if one exists.
Definition: SegmentIntersectionDetector.h:42
bool hasIntersection() const
Tests whether an intersection was found.
Definition: SegmentIntersectionDetector.h:95
const geom::Coordinate * getIntersection() const
Gets the computed location of the intersection. Due to round-off, the location may not be exact.
Definition: SegmentIntersectionDetector.h:129
bool isDone() const override
Reports whether the client of this class needs to continue testing all intersections in an arrangemen...
Definition: SegmentIntersectionDetector.h:147
const geom::CoordinateSequence * getIntersectionSegments() const
Gets the endpoints of the intersecting segments.
Definition: SegmentIntersectionDetector.h:141
bool hasNonProperIntersection() const
Tests whether a non-proper intersection was found.
Definition: SegmentIntersectionDetector.h:117
void processIntersections(noding::SegmentString *e0, size_t segIndex0, noding::SegmentString *e1, size_t segIndex1) override
This method is called by clients of the SegmentIntersector class to process intersections for two seg...
bool hasProperIntersection() const
Tests whether a proper intersection was found.
Definition: SegmentIntersectionDetector.h:106
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