GEOS
3.4.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 00016 #ifndef GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H 00017 #define GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H 00018 00019 #include <geos/noding/SegmentIntersector.h> 00020 #include <geos/algorithm/LineIntersector.h> 00021 #include <geos/geom/Coordinate.h> 00022 #include <geos/geom/CoordinateSequence.h> 00023 #include <geos/noding/SegmentString.h> 00024 00025 using namespace geos::algorithm; 00026 00027 namespace geos { 00028 namespace noding { // geos::noding 00029 00043 class SegmentIntersectionDetector : public SegmentIntersector 00044 { 00045 private: 00046 LineIntersector * li; 00047 00048 bool findProper; 00049 bool findAllTypes; 00050 00051 bool _hasIntersection; 00052 bool _hasProperIntersection; 00053 bool _hasNonProperIntersection; 00054 00055 const geom::Coordinate * intPt; 00056 geom::CoordinateSequence * intSegments; 00057 00058 protected: 00059 public: 00060 SegmentIntersectionDetector( LineIntersector * li) 00061 : 00062 li( li), 00063 findProper(false), 00064 findAllTypes(false), 00065 _hasIntersection(false), 00066 _hasProperIntersection(false), 00067 _hasNonProperIntersection(false), 00068 intPt( NULL), 00069 intSegments( NULL) 00070 { } 00071 00072 ~SegmentIntersectionDetector() 00073 { 00074 //delete intPt; 00075 delete intSegments; 00076 } 00077 00078 00079 void setFindProper( bool findProper) 00080 { 00081 this->findProper = findProper; 00082 } 00083 00084 void setFindAllIntersectionTypes( bool findAllTypes) 00085 { 00086 this->findAllTypes = findAllTypes; 00087 } 00088 00094 bool hasIntersection() const 00095 { 00096 return _hasIntersection; 00097 } 00098 00104 bool hasProperIntersection() const 00105 { 00106 return _hasProperIntersection; 00107 } 00108 00114 bool hasNonProperIntersection() const 00115 { 00116 return _hasNonProperIntersection; 00117 } 00118 00125 const geom::Coordinate * const getIntersection() const 00126 { 00127 return intPt; 00128 } 00129 00130 00136 const geom::CoordinateSequence * getIntersectionSegments() const 00137 { 00138 return intSegments; 00139 } 00140 00141 bool isDone() const 00142 { 00143 // If finding all types, we can stop 00144 // when both possible types have been found. 00145 if (findAllTypes) 00146 return _hasProperIntersection && _hasNonProperIntersection; 00147 00148 // If searching for a proper intersection, only stop if one is found 00149 if (findProper) 00150 return _hasProperIntersection; 00151 00152 return _hasIntersection; 00153 } 00154 00163 void processIntersections( noding::SegmentString * e0, int segIndex0, 00164 noding::SegmentString * e1, int segIndex1 ); 00165 00166 }; 00167 00168 } // namespace geos::noding 00169 } // namespace geos 00170 00171 #endif // GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H