GEOS  3.8.0
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 
45 
46 class GEOS_DLL SegmentIntersector {
47 
48 private:
49 
54  bool hasIntersectionVar;
55 
56  bool hasProper;
57 
58  bool hasProperInterior;
59 
60  bool isDone;
61 
62  bool isDoneWhenProperInt;
63 
64  // the proper intersection point found
65  geom::Coordinate properIntersectionPoint;
66 
67  algorithm::LineIntersector* li;
68 
69  bool includeProper;
70 
71  bool recordIsolated;
72 
73  //bool isSelfIntersection;
74 
75  //bool intersectionFound;
76 
77  int numIntersections;
78 
80  std::array<std::vector<Node*>*, 2> bdyNodes;
81 
82  bool isTrivialIntersection(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1);
83 
84  bool isBoundaryPoint(algorithm::LineIntersector* li,
85  std::array<std::vector<Node*>*, 2>& tstBdyNodes);
86 
87  bool isBoundaryPoint(algorithm::LineIntersector* li,
88  std::vector<Node*>* tstBdyNodes);
89 
90 public:
91 
92  static bool isAdjacentSegments(size_t i1, size_t i2);
93 
94  // testing only
95  int numTests;
96 
97  //SegmentIntersector();
98 
99  virtual
100  ~SegmentIntersector() {}
101 
102  SegmentIntersector(algorithm::LineIntersector* newLi,
103  bool newIncludeProper, bool newRecordIsolated)
104  :
105  hasIntersectionVar(false),
106  hasProper(false),
107  hasProperInterior(false),
108  isDone(false),
109  isDoneWhenProperInt(false),
110  li(newLi),
111  includeProper(newIncludeProper),
112  recordIsolated(newRecordIsolated),
113  numIntersections(0),
114  bdyNodes{nullptr, nullptr},
115  numTests(0)
116  {}
117 
121  void setBoundaryNodes(std::vector<Node*>* bdyNodes0,
122  std::vector<Node*>* bdyNodes1);
123 
124  geom::Coordinate& getProperIntersectionPoint();
125 
126  bool hasIntersection();
127 
128  bool hasProperIntersection();
129 
130  bool hasProperInteriorIntersection();
131 
132  void addIntersections(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1);
133 
134  void setIsDoneIfProperInt(bool isDoneWhenProperInt);
135 
136  bool getIsDone();
137 
138 };
139 
140 } // namespace geos.geomgraph.index
141 } // namespace geos.geomgraph
142 } // namespace geos
143 
144 #ifdef GEOS_INLINE
145 #include <geos/geomgraph/index/SegmentIntersector.inl>
146 #endif
147 
148 #ifdef _MSC_VER
149 #pragma warning(pop)
150 #endif
151 
152 #endif
153 
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25