GEOS 3.3.4

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

- File List

SegmentIntersectionDetector.h
1 /**********************************************************************
2 * $Id: SegmentIntersectionDetector.h 2263 2009-01-29 18:56:00Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research 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
17 #ifndef GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
18 #define GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
19
20 #include <geos/noding/SegmentIntersector.h>
21 #include <geos/algorithm/LineIntersector.h>
22 #include <geos/geom/Coordinate.h>
23 #include <geos/geom/CoordinateSequence.h>
24 #include <geos/noding/SegmentString.h>
25
26 using namespace geos::algorithm;
27
28 namespace geos {
29 namespace noding { // geos::noding
30
44 class SegmentIntersectionDetector : public SegmentIntersector
45 {
46 private:
47 LineIntersector * li;
48
49 bool findProper;
50 bool findAllTypes;
51
52 bool _hasIntersection;
53 bool _hasProperIntersection;
54 bool _hasNonProperIntersection;
55
56 const geom::Coordinate * intPt;
57 geom::CoordinateSequence * intSegments;
58
59 protected:
60 public:
61 SegmentIntersectionDetector( LineIntersector * li)
62 :
63 li( li),
64 findProper(false),
65 findAllTypes(false),
66 _hasIntersection(false),
67 _hasProperIntersection(false),
68 _hasNonProperIntersection(false),
69 intPt( NULL),
70 intSegments( NULL)
71 { }
72
73 ~SegmentIntersectionDetector()
74 {
75 //delete intPt;
76 delete intSegments;
77 }
78
79
80 void setFindProper( bool findProper)
81 {
82 this->findProper = findProper;
83 }
84
85 void setFindAllIntersectionTypes( bool findAllTypes)
86 {
87 this->findAllTypes = findAllTypes;
88 }
89
95 bool hasIntersection() const
96 {
97 return _hasIntersection;
98 }
99
105 bool hasProperIntersection() const
106 {
107 return _hasProperIntersection;
108 }
109
115 bool hasNonProperIntersection() const
116 {
117 return _hasNonProperIntersection;
118 }
119
126 const geom::Coordinate * const getIntersection() const
127 {
128 return intPt;
129 }
130
131
137 const geom::CoordinateSequence * getIntersectionSegments() const
138 {
139 return intSegments;
140 }
141
142 bool isDone() const
143 {
144 // If finding all types, we can stop
145 // when both possible types have been found.
146 if (findAllTypes)
147 return _hasProperIntersection && _hasNonProperIntersection;
148
149 // If searching for a proper intersection, only stop if one is found
150 if (findProper)
151 return _hasProperIntersection;
152
153 return _hasIntersection;
154 }
155
164 void processIntersections( noding::SegmentString * e0, int segIndex0,
165 noding::SegmentString * e1, int segIndex1 );
166
167 };
168
169 } // namespace geos::noding
170 } // namespace geos
171
172 #endif // GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
173 /**********************************************************************
174 * $Log$
175 **********************************************************************/
176
177