GEOS  3.9.1
geomgraph/index/SegmentIntersector.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions 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 #ifndef GEOS_GEOMGRAPH_INDEX_SEGMENTINTERSECTOR_H
17 #define GEOS_GEOMGRAPH_INDEX_SEGMENTINTERSECTOR_H
18 
19 #include <geos/export.h>
20 #include <array>
21 #include <vector>
22 
23 #include <geos/geom/Coordinate.h> // for composition
24 
25 #ifdef _MSC_VER
26 #pragma warning(push)
27 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
28 #endif
29 
30 // Forward declarations
31 namespace geos {
32 namespace algorithm {
33 class LineIntersector;
34 }
35 namespace geomgraph {
36 class Node;
37 class Edge;
38 }
39 }
40 
41 namespace geos {
42 namespace geomgraph { // geos::geomgraph
43 namespace index { // geos::geomgraph::index
44 
47 class GEOS_DLL SegmentIntersector {
48 
49 private:
50 
55  bool hasIntersectionVar;
56 
57  bool hasProper;
58 
59  bool hasProperInterior;
60 
61  bool isDone;
62 
63  bool isDoneWhenProperInt;
64 
65  // the proper intersection point found
66  geom::Coordinate properIntersectionPoint;
67 
69 
70  bool includeProper;
71 
72  bool recordIsolated;
73 
74  //bool isSelfIntersection;
75 
76  //bool intersectionFound;
77 
78  int numIntersections;
79 
81  std::array<std::vector<Node*>*, 2> bdyNodes;
82 
83  bool isTrivialIntersection(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1);
84 
85  bool isBoundaryPoint(algorithm::LineIntersector* li,
86  std::array<std::vector<Node*>*, 2>& tstBdyNodes);
87 
88  bool isBoundaryPoint(algorithm::LineIntersector* li,
89  std::vector<Node*>* tstBdyNodes);
90 
91 public:
92 
93  static bool isAdjacentSegments(size_t i1, size_t i2);
94 
95  // testing only
96  int numTests;
97 
98  //SegmentIntersector();
99 
100  virtual
101  ~SegmentIntersector() {}
102 
104  bool newIncludeProper, bool newRecordIsolated)
105  :
106  hasIntersectionVar(false),
107  hasProper(false),
108  hasProperInterior(false),
109  isDone(false),
110  isDoneWhenProperInt(false),
111  li(newLi),
112  includeProper(newIncludeProper),
113  recordIsolated(newRecordIsolated),
114  numIntersections(0),
115  bdyNodes{nullptr, nullptr},
116  numTests(0)
117  {}
118 
122  void setBoundaryNodes(std::vector<Node*>* bdyNodes0,
123  std::vector<Node*>* bdyNodes1);
124 
125  geom::Coordinate& getProperIntersectionPoint();
126 
127  bool hasIntersection();
128 
129  bool hasProperIntersection();
130 
131  bool hasProperInteriorIntersection();
132 
133  void addIntersections(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1);
134 
135  void setIsDoneIfProperInt(bool isDoneWhenProperInt);
136 
137  bool getIsDone();
138 
139 };
140 
141 } // namespace geos.geomgraph.index
142 } // namespace geos.geomgraph
143 } // namespace geos
144 
145 #ifdef GEOS_INLINE
146 #include <geos/geomgraph/index/SegmentIntersector.inl>
147 #endif
148 
149 #ifdef _MSC_VER
150 #pragma warning(pop)
151 #endif
152 
153 #endif
154 
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Definition: geomgraph/Edge.h:66
Computes the intersection of line segments, and adds the intersection to the edges containing the seg...
Definition: geomgraph/index/SegmentIntersector.h:47
void setBoundaryNodes(std::vector< Node * > *bdyNodes0, std::vector< Node * > *bdyNodes1)
Parameters are externally owned. Make sure they live for the whole lifetime of this object.
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26