GEOS  3.4.2
EdgeIntersectionList.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
00007  * Copyright (C) 2005-2006 Refractions Research Inc.
00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: geomgraph/EdgeIntersectionList.java r428 (JTS-1.12+)
00018  *
00019  **********************************************************************/
00020 
00021 
00022 #ifndef GEOS_GEOMGRAPH_EDGEINTERSECTIONLIST_H
00023 #define GEOS_GEOMGRAPH_EDGEINTERSECTIONLIST_H
00024 
00025 #include <geos/export.h>
00026 #include <vector>
00027 #include <set>
00028 #include <string>
00029 
00030 #include <geos/geomgraph/EdgeIntersection.h> // for EdgeIntersectionLessThen
00031 #include <geos/geom/Coordinate.h> // for CoordinateLessThen
00032 
00033 #include <geos/inline.h>
00034 
00035 #ifdef _MSC_VER
00036 #pragma warning(push)
00037 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00038 #endif
00039 
00040 // Forward declarations
00041 namespace geos {
00042         namespace geom {
00043                 class Coordinate;
00044         }
00045         namespace geomgraph {
00046                 class Edge;
00047         }
00048 }
00049 
00050 namespace geos {
00051 namespace geomgraph { // geos.geomgraph
00052 
00053 
00059 class GEOS_DLL EdgeIntersectionList{
00060 public:
00061         typedef std::set<EdgeIntersection *, EdgeIntersectionLessThen> container;
00062         typedef container::iterator iterator;
00063         typedef container::const_iterator const_iterator;
00064 
00065 private:
00066         container nodeMap;
00067 
00068 public:
00069 
00070         Edge *edge;
00071         EdgeIntersectionList(Edge *edge);
00072         ~EdgeIntersectionList();
00073 
00074         /*
00075          * Adds an intersection into the list, if it isn't already there.
00076          * The input segmentIndex and dist are expected to be normalized.
00077          * @return the EdgeIntersection found or added
00078          */
00079         EdgeIntersection* add(const geom::Coordinate& coord,
00080                 int segmentIndex, double dist);
00081 
00082         iterator begin() { return nodeMap.begin(); }
00083         iterator end() { return nodeMap.end(); }
00084         const_iterator begin() const { return nodeMap.begin(); }
00085         const_iterator end() const { return nodeMap.end(); }
00086 
00087         bool isEmpty() const;
00088         bool isIntersection(const geom::Coordinate& pt) const;
00089 
00090         /*
00091          * Adds entries for the first and last points of the edge to the list
00092          */
00093         void addEndpoints();
00094 
00103         void addSplitEdges(std::vector<Edge*> *edgeList);
00104 
00105         Edge *createSplitEdge(EdgeIntersection *ei0, EdgeIntersection *ei1);
00106         std::string print() const;
00107 
00108 };
00109 
00110 std::ostream& operator<< (std::ostream&, const EdgeIntersectionList&);
00111 
00112 } // namespace geos.geomgraph
00113 } // namespace geos
00114 
00115 #ifdef _MSC_VER
00116 #pragma warning(pop)
00117 #endif
00118 
00119 #endif // ifndef GEOS_GEOMGRAPH_EDGEINTERSECTIONLIST_H
00120