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 
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 
75  // bool isSelfIntersection;
76  // bool intersectionFound;
77 
84  bool isTrivialIntersection(const SegmentString* e0, size_t segIndex0,
85  const SegmentString* e1, size_t segIndex1);
86 
87  // Declare type as noncopyable
88  IntersectionAdder(const IntersectionAdder& other) = delete;
89  IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
90 
91 public:
92 
93  int numIntersections;
94  int numInteriorIntersections;
95  int numProperIntersections;
96 
97  // testing only
98  int numTests;
99 
101  :
102  hasIntersectionVar(false),
103  hasProper(false),
104  hasProperInterior(false),
105  hasInterior(false),
106  properIntersectionPoint(nullptr),
107  li(newLi),
108  numIntersections(0),
109  numInteriorIntersections(0),
110  numProperIntersections(0),
111  numTests(0)
112  {}
113 
115  getLineIntersector()
116  {
117  return li;
118  }
119 
124  const geom::Coordinate*
126  {
127  return properIntersectionPoint;
128  }
129 
130  bool
131  hasIntersection()
132  {
133  return hasIntersectionVar;
134  }
135 
144  bool
146  {
147  return hasProper;
148  }
149 
155  bool
157  {
158  return hasProperInterior;
159  }
160 
165  bool
167  {
168  return hasInterior;
169  }
170 
171 
181  void processIntersections(
182  SegmentString* e0, size_t segIndex0,
183  SegmentString* e1, size_t segIndex1) override;
184 
185 
186  static bool
187  isAdjacentSegments(size_t i1, size_t i2)
188  {
189  return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
190  }
191 
197  bool
198  isDone() const override
199  {
200  return false;
201  }
202 };
203 
204 
205 } // namespace geos.noding
206 } // namespace geos
207 
208 #endif // GEOS_NODING_INTERSECTIONADDER_H
bool hasProperIntersection()
Definition: IntersectionAdder.h:145
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()
Definition: IntersectionAdder.h:166
bool isDone() const override
Definition: IntersectionAdder.h:198
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Definition: IntersectionAdder.h:58
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:48
bool hasProperInteriorIntersection()
Definition: IntersectionAdder.h:156
const geom::Coordinate * getProperIntersectionPoint()
Definition: IntersectionAdder.h:125