GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 <geos/noding/SegmentIntersector.h>
20 #include <geos/algorithm/LineIntersector.h>
21 #include <geos/geom/Coordinate.h>
22 #include <geos/geom/CoordinateSequence.h>
23 #include <geos/noding/SegmentString.h>
24
25 using namespace geos::algorithm;
26
27 namespace geos {
28 namespace noding { // geos::noding
29
43 class SegmentIntersectionDetector : public SegmentIntersector
44 {
45 private:
46 LineIntersector * li;
47
48 bool findProper;
49 bool findAllTypes;
50
51 bool _hasIntersection;
52 bool _hasProperIntersection;
53 bool _hasNonProperIntersection;
54
55 const geom::Coordinate * intPt;
56 geom::CoordinateSequence * intSegments;
57
58 protected:
59 public:
60 SegmentIntersectionDetector( LineIntersector * li)
61 :
62 li( li),
63 findProper(false),
64 findAllTypes(false),
65 _hasIntersection(false),
66 _hasProperIntersection(false),
67 _hasNonProperIntersection(false),
68 intPt( NULL),
69 intSegments( NULL)
70 { }
71
72 ~SegmentIntersectionDetector()
73 {
74 //delete intPt;
75 delete intSegments;
76 }
77
78
79 void setFindProper( bool findProper)
80 {
81 this->findProper = findProper;
82 }
83
84 void setFindAllIntersectionTypes( bool findAllTypes)
85 {
86 this->findAllTypes = findAllTypes;
87 }
88
94 bool hasIntersection() const
95 {
96 return _hasIntersection;
97 }
98
104 bool hasProperIntersection() const
105 {
106 return _hasProperIntersection;
107 }
108
114 bool hasNonProperIntersection() const
115 {
116 return _hasNonProperIntersection;
117 }
118
125 const geom::Coordinate * const getIntersection() const
126 {
127 return intPt;
128 }
129
130
136 const geom::CoordinateSequence * getIntersectionSegments() const
137 {
138 return intSegments;
139 }
140
141 bool isDone() const
142 {
143 // If finding all types, we can stop
144 // when both possible types have been found.
145 if (findAllTypes)
146 return _hasProperIntersection && _hasNonProperIntersection;
147
148 // If searching for a proper intersection, only stop if one is found
149 if (findProper)
150 return _hasProperIntersection;
151
152 return _hasIntersection;
153 }
154
163 void processIntersections( noding::SegmentString * e0, int segIndex0,
164 noding::SegmentString * e1, int segIndex1 );
165
166 };
167
168 } // namespace geos::noding
169 } // namespace geos
170
171 #endif // GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H