GEOS 3.4.2

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

- File List

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
34 namespace geos {
35 namespace geom {
36 class Coordinate;
37 }
38 namespace noding {
39 class SegmentString;
40 }
41 namespace algorithm {
42 class LineIntersector;
43 }
44 }
45
46 namespace geos {
47 namespace noding { // geos.noding
48
58 class GEOS_DLL IntersectionAdder: public SegmentIntersector {
59
60 private:
61
66 bool hasIntersectionVar;
67 bool hasProper;
68 bool hasProperInterior;
69 bool hasInterior;
70
71 // the proper intersection point found
72 const geom::Coordinate* properIntersectionPoint;
73
74 algorithm::LineIntersector& li;
75 bool isSelfIntersection;
76 //bool intersectionFound;
77
84 bool isTrivialIntersection(const SegmentString* e0, int segIndex0,
85 const SegmentString* e1, int segIndex1);
86
87 // Declare type as noncopyable
88 IntersectionAdder(const IntersectionAdder& other);
89 IntersectionAdder& operator=(const IntersectionAdder& rhs);
90
91 public:
92
93 int numIntersections;
94 int numInteriorIntersections;
95 int numProperIntersections;
96
97 // testing only
98 int numTests;
99
100 IntersectionAdder(algorithm::LineIntersector& newLi)
101 :
102 hasIntersectionVar(false),
103 hasProper(false),
104 hasProperInterior(false),
105 hasInterior(false),
106 properIntersectionPoint(NULL),
107 li(newLi),
108 numIntersections(0),
109 numInteriorIntersections(0),
110 numProperIntersections(0),
111 numTests(0)
112 {}
113
114 algorithm::LineIntersector& getLineIntersector() { return li; }
115
120 const geom::Coordinate* getProperIntersectionPoint() {
121 return properIntersectionPoint;
122 }
123
124 bool hasIntersection() { return hasIntersectionVar; }
125
134 bool hasProperIntersection() { return hasProper; }
135
141 bool hasProperInteriorIntersection() { return hasProperInterior; }
142
147 bool hasInteriorIntersection() { return hasInterior; }
148
149
159 void processIntersections(
160 SegmentString* e0, int segIndex0,
161 SegmentString* e1, int segIndex1);
162
163
164 static bool isAdjacentSegments(int i1, int i2) {
165 return std::abs(i1 - i2) == 1;
166 }
167
173 virtual bool isDone() const {
174 return false;
175 }
176 };
177
178
179 } // namespace geos.noding
180 } // namespace geos
181
182 #endif // GEOS_NODING_INTERSECTIONADDER_H