GEOS  3.3.3
IntersectionAdder.h
1 /**********************************************************************
2  * $Id: IntersectionAdder.h 2778 2009-12-03 19:44:00Z mloskot $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2006 Refractions Research 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  * Last port: noding/IntersectionAdder.java rev. 1.6 (JTS-1.9)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_NODING_INTERSECTIONADDER_H
21 #define GEOS_NODING_INTERSECTIONADDER_H
22 
23 #include <geos/export.h>
24 
25 #include <vector>
26 #include <iostream>
27 #include <cstdlib> // for abs()
28 
29 #include <geos/inline.h>
30 
31 #include <geos/geom/Coordinate.h>
32 #include <geos/noding/SegmentIntersector.h> // for inheritance
33 
34 // Forward declarations
35 namespace geos {
36  namespace geom {
37  class Coordinate;
38  }
39  namespace noding {
40  class SegmentString;
41  }
42  namespace algorithm {
43  class LineIntersector;
44  }
45 }
46 
47 namespace geos {
48 namespace noding { // geos.noding
49 
59 class GEOS_DLL IntersectionAdder: public SegmentIntersector {
60 
61 private:
62 
67  bool hasIntersectionVar;
68  bool hasProper;
69  bool hasProperInterior;
70  bool hasInterior;
71 
72  // the proper intersection point found
73  const geom::Coordinate* properIntersectionPoint;
74 
76  bool isSelfIntersection;
77  //bool intersectionFound;
78 
85  bool isTrivialIntersection(const SegmentString* e0, int segIndex0,
86  const SegmentString* e1, int segIndex1);
87 
88  // Declare type as noncopyable
90  IntersectionAdder& operator=(const IntersectionAdder& rhs);
91 
92 public:
93 
94  int numIntersections;
95  int numInteriorIntersections;
96  int numProperIntersections;
97 
98  // testing only
99  int numTests;
100 
102  :
103  hasIntersectionVar(false),
104  hasProper(false),
105  hasProperInterior(false),
106  hasInterior(false),
107  properIntersectionPoint(NULL),
108  li(newLi),
109  numIntersections(0),
110  numInteriorIntersections(0),
111  numProperIntersections(0),
112  numTests(0)
113  {}
114 
115  algorithm::LineIntersector& getLineIntersector() { return li; }
116 
122  return properIntersectionPoint;
123  }
124 
125  bool hasIntersection() { return hasIntersectionVar; }
126 
135  bool hasProperIntersection() { return hasProper; }
136 
142  bool hasProperInteriorIntersection() { return hasProperInterior; }
143 
148  bool hasInteriorIntersection() { return hasInterior; }
149 
150 
160  void processIntersections(
161  SegmentString* e0, int segIndex0,
162  SegmentString* e1, int segIndex1);
163 
164 
165  static bool isAdjacentSegments(int i1, int i2) {
166  return std::abs(i1 - i2) == 1;
167  }
168 
174  virtual bool isDone() const {
175  return false;
176  }
177 };
178 
179 
180 } // namespace geos.noding
181 } // namespace geos
182 
183 //#ifdef GEOS_INLINE
184 //# include "geos/noding/IntersectionAdder.inl"
185 //#endif
186 
187 #endif // GEOS_NODING_INTERSECTIONADDER_H
188 
189 /**********************************************************************
190  * $Log$
191  * Revision 1.2 2006/03/24 09:52:41 strk
192  * USE_INLINE => GEOS_INLINE
193  *
194  * Revision 1.1 2006/03/09 16:46:49 strk
195  * geos::geom namespace definition, first pass at headers split
196  *
197  **********************************************************************/
198