GEOS  3.8.0dev
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 
60 class GEOS_DLL IntersectionAdder: public SegmentIntersector {
61 
62 private:
63 
68  bool hasIntersectionVar;
69  bool hasProper;
70  bool hasProperInterior;
71  bool hasInterior;
72 
73  // the proper intersection point found
74  const geom::Coordinate* properIntersectionPoint;
75 
77  // bool isSelfIntersection;
78  // bool intersectionFound;
79 
86  bool isTrivialIntersection(const SegmentString* e0, size_t segIndex0,
87  const SegmentString* e1, size_t segIndex1);
88 
89  // Declare type as noncopyable
90  IntersectionAdder(const IntersectionAdder& other) = delete;
91  IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
92 
93 public:
94 
95  int numIntersections;
96  int numInteriorIntersections;
97  int numProperIntersections;
98 
99  // testing only
100  int numTests;
101 
103  :
104  hasIntersectionVar(false),
105  hasProper(false),
106  hasProperInterior(false),
107  hasInterior(false),
108  properIntersectionPoint(nullptr),
109  li(newLi),
110  numIntersections(0),
111  numInteriorIntersections(0),
112  numProperIntersections(0),
113  numTests(0)
114  {}
115 
117  getLineIntersector()
118  {
119  return li;
120  }
121 
126  const geom::Coordinate*
128  {
129  return properIntersectionPoint;
130  }
131 
132  bool
133  hasIntersection()
134  {
135  return hasIntersectionVar;
136  }
137 
147  bool
149  {
150  return hasProper;
151  }
152 
157  bool
159  {
160  return hasProperInterior;
161  }
162 
167  bool
169  {
170  return hasInterior;
171  }
172 
173 
182  void processIntersections(
183  SegmentString* e0, size_t segIndex0,
184  SegmentString* e1, size_t segIndex1) override;
185 
186 
187  static bool
188  isAdjacentSegments(size_t i1, size_t i2)
189  {
190  return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
191  }
192 
198  bool
199  isDone() const override
200  {
201  return false;
202  }
203 };
204 
205 
206 } // namespace geos.noding
207 } // namespace geos
208 
209 #endif // GEOS_NODING_INTERSECTIONADDER_H
bool hasProperIntersection()
A proper intersection is an intersection which is interior to at least two line segments.
Definition: IntersectionAdder.h:148
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
bool hasInteriorIntersection()
An interior intersection is an intersection which is in the interior of some segment.
Definition: IntersectionAdder.h:168
bool isDone() const override
Always process all intersections.
Definition: IntersectionAdder.h:199
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Computes the intersections between two line segments in SegmentString and adds them to each string...
Definition: IntersectionAdder.h:60
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:48
bool hasProperInteriorIntersection()
A proper interior intersection is a proper intersection which is not contained in the set of boundary...
Definition: IntersectionAdder.h:158
const geom::Coordinate * getProperIntersectionPoint()
Definition: IntersectionAdder.h:127