IntersectionAdder.h

00001 /**********************************************************************
00002  * $Id: IntersectionAdder.h 1820 2006-09-06 16:54:23Z 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 #ifndef GEOS_NODING_INTERSECTIONADDER_H
00017 #define GEOS_NODING_INTERSECTIONADDER_H
00018 
00019 #include <vector>
00020 #include <iostream>
00021 #include <cmath> // for abs()
00022 #include <cstdlib> // for abs()
00023 
00024 #include <geos/inline.h>
00025 
00026 #include <geos/geom/Coordinate.h>
00027 #include <geos/noding/SegmentIntersector.h> // for inheritance
00028 
00029 // Forward declarations
00030 namespace geos {
00031         namespace geom {
00032                 class Coordinate;
00033         }
00034         namespace noding {
00035                 class SegmentString;
00036         }
00037         namespace algorithm {
00038                 class LineIntersector;
00039         }
00040 }
00041 
00042 namespace geos {
00043 namespace noding { // geos.noding
00044 
00056 class IntersectionAdder: public SegmentIntersector {
00057 
00058 private:
00059 
00064         bool hasIntersectionVar;
00065         bool hasProper;
00066         bool hasProperInterior;
00067         bool hasInterior;
00068 
00069         // the proper intersection point found
00070         const geom::Coordinate* properIntersectionPoint;
00071 
00072         algorithm::LineIntersector& li;
00073         bool isSelfIntersection;
00074         //bool intersectionFound;
00075 
00082         bool isTrivialIntersection(const SegmentString* e0, int segIndex0,
00083                         const SegmentString* e1, int segIndex1);
00084  
00085  
00086 
00087 public:
00088 
00089         int numIntersections;
00090         int numInteriorIntersections;
00091         int numProperIntersections;
00092 
00093         // testing only
00094         int numTests;
00095 
00096         IntersectionAdder(algorithm::LineIntersector& newLi)
00097                 :
00098                 hasIntersectionVar(false),
00099                 hasProper(false),
00100                 hasProperInterior(false),
00101                 hasInterior(false),
00102                 properIntersectionPoint(NULL),
00103                 li(newLi),
00104                 numIntersections(0),
00105                 numInteriorIntersections(0),
00106                 numProperIntersections(0),
00107                 numTests(0)
00108         {}
00109 
00110         algorithm::LineIntersector& getLineIntersector() { return li; }
00111 
00116         const geom::Coordinate* getProperIntersectionPoint()  {
00117                 return properIntersectionPoint;
00118         }
00119 
00120         bool hasIntersection() { return hasIntersectionVar; }
00121 
00130         bool hasProperIntersection() { return hasProper; }
00131 
00137         bool hasProperInteriorIntersection() { return hasProperInterior; }
00138 
00143         bool hasInteriorIntersection() { return hasInterior; }
00144 
00145 
00155         void processIntersections(
00156                 SegmentString* e0,  int segIndex0,
00157                 SegmentString* e1,  int segIndex1);
00158 
00159  
00160         static bool isAdjacentSegments(int i1, int i2) {
00161                 return abs(i1 - i2) == 1;
00162         }
00163 
00164 };
00165  
00166 
00167 } // namespace geos.noding
00168 } // namespace geos
00169 
00170 //#ifdef GEOS_INLINE
00171 //# include "geos/noding/IntersectionAdder.inl"
00172 //#endif
00173 
00174 #endif // GEOS_NODING_INTERSECTIONADDER_H
00175 
00176 /**********************************************************************
00177  * $Log$
00178  * Revision 1.2  2006/03/24 09:52:41  strk
00179  * USE_INLINE => GEOS_INLINE
00180  *
00181  * Revision 1.1  2006/03/09 16:46:49  strk
00182  * geos::geom namespace definition, first pass at headers split
00183  *
00184  **********************************************************************/
00185 

Generated on Fri Aug 15 07:58:19 2008 for GEOS by  doxygen 1.5.1