Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

GeometryGraph.h

00001 /**********************************************************************
00002  * $Id: GeometryGraph.h 2557 2009-06-08 09:30:55Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
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/GeometryGraph.java rev. 1.9 (JTS-1.10)
00018  *
00019  **********************************************************************/
00020 
00021 
00022 #ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
00023 #define GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
00024 
00025 #include <geos/export.h>
00026 #include <map>
00027 #include <vector>
00028 #include <memory>
00029 
00030 #include <geos/geom/Coordinate.h>
00031 #include <geos/geom/CoordinateSequence.h> // for auto_ptr<CoordinateSequence>
00032 #include <geos/geomgraph/PlanarGraph.h>
00033 #include <geos/geom/LineString.h> // for LineStringLT
00034 
00035 #include <geos/inline.h>
00036 
00037 // Forward declarations
00038 namespace geos {
00039         namespace geom {
00040                 class LineString;
00041                 class LinearRing;
00042                 class Polygon;
00043                 class Geometry;
00044                 class GeometryCollection;
00045                 class Point;
00046         }
00047         namespace algorithm {
00048                 class LineIntersector;
00049                 class BoundaryNodeRule;
00050         }
00051         namespace geomgraph {
00052                 class Edge;
00053                 class Node;
00054                 namespace index {
00055                         class SegmentIntersector;
00056                         class EdgeSetIntersector;
00057                 }
00058         }
00059 }
00060 
00061 namespace geos {
00062 namespace geomgraph { // geos.geomgraph
00063 
00064 class GEOS_DLL GeometryGraph: public PlanarGraph
00065 {
00066 using PlanarGraph::add;
00067 using PlanarGraph::findEdge;
00068 
00069 private:
00070 
00071         const geom::Geometry* parentGeom;
00072 
00081 //std::map<const geom::LineString*,Edge*,geom::LineStringLT> lineEdgeMap;
00082         std::map<const geom::LineString*, Edge*> lineEdgeMap;
00083 
00088         bool useBoundaryDeterminationRule;
00089 
00090         const algorithm::BoundaryNodeRule& boundaryNodeRule;
00091 
00096         int argIndex;
00097 
00099         std::auto_ptr< geom::CoordinateSequence > boundaryPoints;
00100 
00101         std::auto_ptr< std::vector<Node*> > boundaryNodes;
00102 
00103         bool hasTooFewPointsVar;
00104 
00105         geom::Coordinate invalidPoint; 
00106 
00107         std::vector<index::SegmentIntersector*> newSegmentIntersectors;
00108 
00110         index::EdgeSetIntersector* createEdgeSetIntersector();
00111 
00112         void add(const geom::Geometry *g);
00113                 // throw(UnsupportedOperationException);
00114 
00115         void addCollection(const geom::GeometryCollection *gc);
00116 
00117         void addPoint(const geom::Point *p);
00118 
00119         void addPolygonRing(const geom::LinearRing *lr,
00120                         int cwLeft, int cwRight);
00121 
00122         void addPolygon(const geom::Polygon *p);
00123 
00124         void addLineString(const geom::LineString *line);
00125 
00126         void insertPoint(int argIndex, const geom::Coordinate& coord,
00127                         int onLocation);
00128 
00136         void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
00137 
00138         void addSelfIntersectionNodes(int argIndex);
00139 
00147         void addSelfIntersectionNode(int argIndex,
00148                 const geom::Coordinate& coord, int loc);
00149 
00150 public:
00151 
00152         static bool isInBoundary(int boundaryCount);
00153 
00154         static int determineBoundary(int boundaryCount);
00155 
00156         static int determineBoundary(
00157                      const algorithm::BoundaryNodeRule& boundaryNodeRule,
00158                                                     int boundaryCount);
00159 
00160         GeometryGraph();
00161 
00162         GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
00163 
00164         GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom,
00165                       const algorithm::BoundaryNodeRule& boundaryNodeRule);
00166 
00167         virtual ~GeometryGraph();
00168 
00169 
00170         const geom::Geometry* getGeometry();
00171 
00173         std::vector<Node*>* getBoundaryNodes();
00174 
00175         void getBoundaryNodes(std::vector<Node*>&bdyNodes);
00176 
00178         geom::CoordinateSequence* getBoundaryPoints();
00179 
00180         Edge* findEdge(const geom::LineString *line);
00181 
00182         void computeSplitEdges(std::vector<Edge*> *edgelist);
00183 
00184         void addEdge(Edge *e);
00185 
00186         void addPoint(geom::Coordinate& pt);
00187 
00203         index::SegmentIntersector* computeSelfNodes(
00204                         algorithm::LineIntersector *li,
00205                         bool computeRingSelfNodes);
00206 
00207         // Quick inline calling the function above, the above should probably
00208         // be deprecated.
00209         index::SegmentIntersector* computeSelfNodes(
00210                         algorithm::LineIntersector& li,
00211                         bool computeRingSelfNodes);
00212 
00213         index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
00214                 algorithm::LineIntersector *li, bool includeProper);
00215 
00216         std::vector<Edge*> *getEdges();
00217 
00218         bool hasTooFewPoints();
00219 
00220         const geom::Coordinate& getInvalidPoint(); 
00221 
00222         const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
00223         { return boundaryNodeRule; }
00224 
00225 };
00226 
00227 
00228 } // namespace geos.geomgraph
00229 } // namespace geos
00230 
00231 #ifdef GEOS_INLINE
00232 # include "geos/geomgraph/GeometryGraph.inl"
00233 #endif
00234 
00235 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
00236 
00237 /**********************************************************************
00238  * $Log$
00239  * Revision 1.4  2006/06/13 22:00:26  strk
00240  * Changed GeometryGraph::lineEdgeMap set comparison function to be pointer-based. Should be safe and much faster. Available tests all succeed.
00241  *
00242  * Revision 1.3  2006/03/29 15:23:49  strk
00243  * Moved GeometryGraph inlines from .h to .inl file
00244  *
00245  * Revision 1.2  2006/03/24 09:52:41  strk
00246  * USE_INLINE => GEOS_INLINE
00247  *
00248  * Revision 1.1  2006/03/09 16:46:49  strk
00249  * geos::geom namespace definition, first pass at headers split
00250  *
00251  **********************************************************************/
00252 

Generated on Thu Jun 11 06:17:01 2009 for GEOS by  doxygen 1.4.4