GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2006 Refractions Research Inc. 00007 * 00008 * This is free software; you can redistribute and/or modify it under 00009 * the terms of the GNU Lesser General Public Licence as published 00010 * by the Free Software Foundation. 00011 * See the COPYING file for more information. 00012 * 00013 ********************************************************************** 00014 * 00015 * Last port: noding/IntersectionAdder.java rev. 1.6 (JTS-1.9) 00016 * 00017 **********************************************************************/ 00018 00019 #ifndef GEOS_NODING_INTERSECTIONADDER_H 00020 #define GEOS_NODING_INTERSECTIONADDER_H 00021 00022 #include <geos/export.h> 00023 00024 #include <vector> 00025 #include <iostream> 00026 #include <cstdlib> // for abs() 00027 00028 #include <geos/inline.h> 00029 00030 #include <geos/geom/Coordinate.h> 00031 #include <geos/noding/SegmentIntersector.h> // for inheritance 00032 00033 // Forward declarations 00034 namespace geos { 00035 namespace geom { 00036 class Coordinate; 00037 } 00038 namespace noding { 00039 class SegmentString; 00040 } 00041 namespace algorithm { 00042 class LineIntersector; 00043 } 00044 } 00045 00046 namespace geos { 00047 namespace noding { // geos.noding 00048 00058 class GEOS_DLL IntersectionAdder: public SegmentIntersector { 00059 00060 private: 00061 00066 bool hasIntersectionVar; 00067 bool hasProper; 00068 bool hasProperInterior; 00069 bool hasInterior; 00070 00071 // the proper intersection point found 00072 const geom::Coordinate* properIntersectionPoint; 00073 00074 algorithm::LineIntersector& li; 00075 bool isSelfIntersection; 00076 //bool intersectionFound; 00077 00084 bool isTrivialIntersection(const SegmentString* e0, int segIndex0, 00085 const SegmentString* e1, int segIndex1); 00086 00087 // Declare type as noncopyable 00088 IntersectionAdder(const IntersectionAdder& other); 00089 IntersectionAdder& operator=(const IntersectionAdder& rhs); 00090 00091 public: 00092 00093 int numIntersections; 00094 int numInteriorIntersections; 00095 int numProperIntersections; 00096 00097 // testing only 00098 int numTests; 00099 00100 IntersectionAdder(algorithm::LineIntersector& newLi) 00101 : 00102 hasIntersectionVar(false), 00103 hasProper(false), 00104 hasProperInterior(false), 00105 hasInterior(false), 00106 properIntersectionPoint(NULL), 00107 li(newLi), 00108 numIntersections(0), 00109 numInteriorIntersections(0), 00110 numProperIntersections(0), 00111 numTests(0) 00112 {} 00113 00114 algorithm::LineIntersector& getLineIntersector() { return li; } 00115 00120 const geom::Coordinate* getProperIntersectionPoint() { 00121 return properIntersectionPoint; 00122 } 00123 00124 bool hasIntersection() { return hasIntersectionVar; } 00125 00134 bool hasProperIntersection() { return hasProper; } 00135 00141 bool hasProperInteriorIntersection() { return hasProperInterior; } 00142 00147 bool hasInteriorIntersection() { return hasInterior; } 00148 00149 00159 void processIntersections( 00160 SegmentString* e0, int segIndex0, 00161 SegmentString* e1, int segIndex1); 00162 00163 00164 static bool isAdjacentSegments(int i1, int i2) { 00165 return std::abs(i1 - i2) == 1; 00166 } 00167 00173 virtual bool isDone() const { 00174 return false; 00175 } 00176 }; 00177 00178 00179 } // namespace geos.noding 00180 } // namespace geos 00181 00182 #endif // GEOS_NODING_INTERSECTIONADDER_H