• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

SegmentIntersectionDetector.h

00001 /**********************************************************************
00002  * $Id: SegmentIntersectionDetector.h 2263 2009-01-29 18:56:00Z mloskot $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  *
00015  **********************************************************************/
00016 
00017 #ifndef GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
00018 #define GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
00019 
00020 #include <geos/noding/SegmentIntersector.h>
00021 #include <geos/algorithm/LineIntersector.h>
00022 #include <geos/geom/Coordinate.h>
00023 #include <geos/geom/CoordinateSequence.h>
00024 #include <geos/noding/SegmentString.h>
00025 
00026 using namespace geos::algorithm;
00027 
00028 namespace geos {
00029 namespace noding { // geos::noding
00030 
00044 class SegmentIntersectionDetector : public SegmentIntersector 
00045 {
00046 private:
00047         LineIntersector * li;
00048 
00049         bool findProper;
00050         bool findAllTypes;
00051 
00052         bool _hasIntersection;
00053         bool _hasProperIntersection;
00054         bool _hasNonProperIntersection;
00055 
00056         const geom::Coordinate * intPt;
00057         geom::CoordinateSequence * intSegments;
00058 
00059 protected:
00060 public:
00061         SegmentIntersectionDetector( LineIntersector * li) 
00062                 :
00063                 li( li),
00064                 findProper(false),
00065                 findAllTypes(false),
00066                 _hasIntersection(false),
00067                 _hasProperIntersection(false),
00068                 _hasNonProperIntersection(false),
00069                 intPt( NULL),
00070                 intSegments( NULL)
00071         { }
00072 
00073         ~SegmentIntersectionDetector()
00074         {
00075                 //delete intPt;
00076                 delete intSegments;
00077         }
00078 
00079 
00080         void setFindProper( bool findProper)
00081         {
00082                 this->findProper = findProper;
00083         }
00084   
00085         void setFindAllIntersectionTypes( bool findAllTypes)
00086         {
00087                 this->findAllTypes = findAllTypes;
00088         }
00089   
00095         bool hasIntersection() const
00096         { 
00097                 return _hasIntersection; 
00098         }
00099   
00105         bool hasProperIntersection() const 
00106         { 
00107                 return _hasProperIntersection; 
00108         }
00109   
00115         bool hasNonProperIntersection() const
00116         { 
00117                 return _hasNonProperIntersection; 
00118         }
00119   
00126         const geom::Coordinate * const getIntersection()  const
00127         {    
00128                 return intPt;  
00129         }
00130 
00131 
00137         const geom::CoordinateSequence * getIntersectionSegments() const
00138         {
00139                 return intSegments;
00140         }
00141   
00142         bool isDone() const
00143         { 
00144                 // If finding all types, we can stop
00145                 // when both possible types have been found.
00146                 if (findAllTypes)
00147                         return _hasProperIntersection && _hasNonProperIntersection;
00148 
00149                 // If searching for a proper intersection, only stop if one is found
00150                 if (findProper)
00151                         return _hasProperIntersection;
00152 
00153                 return _hasIntersection;
00154         }
00155 
00164         void processIntersections(      noding::SegmentString * e0, int segIndex0,
00165                                                                 noding::SegmentString * e1, int segIndex1 );
00166   
00167 };
00168 
00169 } // namespace geos::noding
00170 } // namespace geos
00171 
00172 #endif // GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H
00173 /**********************************************************************
00174  * $Log$
00175  **********************************************************************/
00176 
00177 

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1