GEOS  3.4.2
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 <vector>
21 
22 #include <geos/geom/Coordinate.h> // for composition
23 
24 #ifdef _MSC_VER
25 #pragma warning(push)
26 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
27 #endif
28 
29 // Forward declarations
30 namespace geos {
31  namespace algorithm {
32  class LineIntersector;
33  }
34  namespace geomgraph {
35  class Node;
36  class Edge;
37  }
38 }
39 
40 namespace geos {
41 namespace geomgraph { // geos::geomgraph
42 namespace index { // geos::geomgraph::index
43 
44 
45 class GEOS_DLL SegmentIntersector{
46 
47 private:
48 
53  bool hasIntersectionVar;
54 
55  bool hasProper;
56 
57  bool hasProperInterior;
58 
59  // the proper intersection point found
60  geom::Coordinate properIntersectionPoint;
61 
62  algorithm::LineIntersector *li;
63 
64  bool includeProper;
65 
66  bool recordIsolated;
67 
68  //bool isSelfIntersection;
69 
70  //bool intersectionFound;
71 
72  int numIntersections;
73 
75  std::vector<std::vector<Node*>*> bdyNodes;
76 
77  bool isTrivialIntersection(Edge *e0,int segIndex0,Edge *e1, int segIndex1);
78 
79  bool isBoundaryPoint(algorithm::LineIntersector *li,
80  std::vector<std::vector<Node*>*>& tstBdyNodes);
81 
82  bool isBoundaryPoint(algorithm::LineIntersector *li,
83  std::vector<Node*> *tstBdyNodes);
84 
85 public:
86 
87  static bool isAdjacentSegments(int i1,int i2);
88 
89  // testing only
90  int numTests;
91 
92  //SegmentIntersector();
93 
94  virtual ~SegmentIntersector() {}
95 
96  SegmentIntersector(algorithm::LineIntersector *newLi,
97  bool newIncludeProper, bool newRecordIsolated)
98  :
99  hasIntersectionVar(false),
100  hasProper(false),
101  hasProperInterior(false),
102  li(newLi),
103  includeProper(newIncludeProper),
104  recordIsolated(newRecordIsolated),
105  numIntersections(0),
106  bdyNodes(2),
107  numTests(0)
108  {}
109 
113  void setBoundaryNodes(std::vector<Node*> *bdyNodes0,
114  std::vector<Node*> *bdyNodes1);
115 
116  geom::Coordinate& getProperIntersectionPoint();
117 
118  bool hasIntersection();
119 
120  bool hasProperIntersection();
121 
122  bool hasProperInteriorIntersection();
123 
124  void addIntersections(Edge *e0, int segIndex0, Edge *e1, int segIndex1);
125 
126 };
127 
128 } // namespace geos.geomgraph.index
129 } // namespace geos.geomgraph
130 } // namespace geos
131 
132 #ifdef _MSC_VER
133 #pragma warning(pop)
134 #endif
135 
136 #endif
137