GEOS  3.13.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 #pragma once
20 
21 #include <geos/export.h>
22 
23 #include <vector>
24 #include <iostream>
25 #include <cstdlib> // for abs()
26 
27 #include <geos/geom/Coordinate.h>
28 #include <geos/noding/SegmentIntersector.h> // for inheritance
29 
30 // Forward declarations
31 namespace geos {
32 namespace noding {
33 class SegmentString;
34 }
35 namespace algorithm {
36 class LineIntersector;
37 }
38 }
39 
40 namespace geos {
41 namespace noding { // geos.noding
42 
54 class GEOS_DLL IntersectionAdder: public SegmentIntersector {
55 
56 private:
57 
62  bool hasIntersectionVar;
63  bool hasProper;
64  bool hasProperInterior;
65  bool hasInterior;
66 
67  // the proper intersection point found
68  geom::CoordinateXYZM properIntersectionPoint;
69 
71  // bool isSelfIntersection;
72  // bool intersectionFound;
73 
80  bool isTrivialIntersection(const SegmentString* e0, std::size_t segIndex0,
81  const SegmentString* e1, std::size_t segIndex1);
82 
83  // Declare type as noncopyable
84  IntersectionAdder(const IntersectionAdder& other) = delete;
85  IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
86 
87 public:
88 
89  int numIntersections;
90  int numInteriorIntersections;
91  int numProperIntersections;
92 
93  // testing only
94  int numTests;
95 
97  :
98  hasIntersectionVar(false),
99  hasProper(false),
100  hasProperInterior(false),
101  hasInterior(false),
102  properIntersectionPoint(),
103  li(newLi),
104  numIntersections(0),
105  numInteriorIntersections(0),
106  numProperIntersections(0),
107  numTests(0)
108  {}
109 
111  getLineIntersector()
112  {
113  return li;
114  }
115 
120  const geom::CoordinateXYZM&
122  {
123  return properIntersectionPoint;
124  }
125 
126  bool
127  hasIntersection()
128  {
129  return hasIntersectionVar;
130  }
131 
141  bool
143  {
144  return hasProper;
145  }
146 
151  bool
153  {
154  return hasProperInterior;
155  }
156 
161  bool
163  {
164  return hasInterior;
165  }
166 
167 
177  SegmentString* e0, std::size_t segIndex0,
178  SegmentString* e1, std::size_t segIndex1) override;
179 
180 
181  static bool
182  isAdjacentSegments(std::size_t i1, std::size_t i2)
183  {
184  return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
185  }
186 
192  bool
193  isDone() const override
194  {
195  return false;
196  }
197 };
198 
199 
200 } // namespace geos.noding
201 } // namespace geos
202 
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:53
Computes the intersections between two line segments in SegmentString and adds them to each string.
Definition: IntersectionAdder.h:54
bool hasInteriorIntersection()
An interior intersection is an intersection which is in the interior of some segment.
Definition: IntersectionAdder.h:162
void processIntersections(SegmentString *e0, std::size_t segIndex0, SegmentString *e1, std::size_t segIndex1) override
This method is called by clients of the SegmentIntersector class to process intersections for two seg...
const geom::CoordinateXYZM & getProperIntersectionPoint()
Definition: IntersectionAdder.h:121
bool hasProperInteriorIntersection()
A proper interior intersection is a proper intersection which is not contained in the set of boundary...
Definition: IntersectionAdder.h:152
bool isDone() const override
Always process all intersections.
Definition: IntersectionAdder.h:193
bool hasProperIntersection()
A proper intersection is an intersection which is interior to at least two line segments.
Definition: IntersectionAdder.h:142
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:45
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:47
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25