- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# GeometryGraph.h

    00001 /**********************************************************************
    00002  * $Id: GeometryGraph.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) 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
    00018 #ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
    00019 #define GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
    00020
    00021 #include <map>
    00022 #include <vector>
    00023 #include <memory>
    00024
    00025 #include <geos/geom/Coordinate.h>
    00026 #include <geos/geom/CoordinateSequence.h> // for auto_ptr<CoordinateSequence>
    00027 #include <geos/geomgraph/PlanarGraph.h>
    00028 #include <geos/geom/LineString.h> // for LineStringLT
    00029
    00030 #include <geos/inline.h>
    00031
    00032 // Forward declarations
    00033 namespace geos {
    00034         namespace geom {
    00035                 class LineString;
    00036                 class LinearRing;
    00037                 class Polygon;
    00038                 class Geometry;
    00039                 class GeometryCollection;
    00040                 class Point;
    00041         }
    00042         namespace algorithm {
    00043                 class LineIntersector;
    00044         }
    00045         namespace geomgraph {
    00046                 class Edge;
    00047                 class Node;
    00048                 namespace index {
    00049                         class SegmentIntersector;
    00050                         class EdgeSetIntersector;
    00051                 }
    00052         }
    00053 }
    00054
    00055 namespace geos {
    00056 namespace geomgraph { // geos.geomgraph
    00057
    00058 class GeometryGraph: public PlanarGraph {
    00059 using PlanarGraph::add;
    00060 using PlanarGraph::findEdge;
    00061
    00062 private:
    00063
    00064         const geom::Geometry* parentGeom;
    00065
    00074 //std::map<const geom::LineString*,Edge*,geom::LineStringLT> lineEdgeMap;
    00075         std::map<const geom::LineString*, Edge*> lineEdgeMap;
    00076
    00081         bool useBoundaryDeterminationRule;
    00082
    00087         int argIndex;
    00088
    00090         std::auto_ptr< geom::CoordinateSequence > boundaryPoints;
    00091
    00092         std::auto_ptr< std::vector<Node*> > boundaryNodes;
    00093
    00094         bool hasTooFewPointsVar;
    00095
    00096         geom::Coordinate invalidPoint;
    00097
    00098         std::vector<index::SegmentIntersector*> newSegmentIntersectors;
    00099
    00101         index::EdgeSetIntersector* createEdgeSetIntersector();
    00102
    00103         void add(const geom::Geometry *g);
    00104                 // throw(UnsupportedOperationException);
    00105
    00106         void addCollection(const geom::GeometryCollection *gc);
    00107
    00108         void addPoint(const geom::Point *p);
    00109
    00110         void addPolygonRing(const geom::LinearRing *lr,
    00111                         int cwLeft, int cwRight);
    00112
    00113         void addPolygon(const geom::Polygon *p);
    00114
    00115         void addLineString(const geom::LineString *line);
    00116
    00117         void insertPoint(int argIndex, const geom::Coordinate& coord,
    00118                         int onLocation);
    00119
    00120         void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
    00121
    00122         void addSelfIntersectionNodes(int argIndex);
    00123
    00131         void addSelfIntersectionNode(int argIndex,
    00132                 const geom::Coordinate& coord, int loc);
    00133
    00134 public:
    00135
    00136         static bool isInBoundary(int boundaryCount);
    00137
    00138         static int determineBoundary(int boundaryCount);
    00139
    00140         GeometryGraph();
    00141
    00142         GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
    00143
    00144         virtual ~GeometryGraph();
    00145
    00146
    00147         const geom::Geometry* getGeometry();
    00148
    00150         std::vector<Node*>* getBoundaryNodes();
    00151
    00152         void getBoundaryNodes(std::vector<Node*>&bdyNodes);
    00153
    00155         geom::CoordinateSequence* getBoundaryPoints();
    00156
    00157         Edge* findEdge(const geom::LineString *line);
    00158
    00159         void computeSplitEdges(std::vector<Edge*> *edgelist);
    00160
    00161         void addEdge(Edge *e);
    00162
    00163         void addPoint(geom::Coordinate& pt);
    00164
    00180         index::SegmentIntersector* computeSelfNodes(
    00181                         algorithm::LineIntersector *li,
    00182                         bool computeRingSelfNodes);
    00183
    00184         // Quick inline calling the function above, the above should probably
    00185         // be deprecated.
    00186         index::SegmentIntersector* computeSelfNodes(
    00187                         algorithm::LineIntersector& li,
    00188                         bool computeRingSelfNodes);
    00189
    00190         index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
    00191                 algorithm::LineIntersector *li, bool includeProper);
    00192
    00193         std::vector<Edge*> *getEdges();
    00194
    00195         bool hasTooFewPoints();
    00196
    00197         const geom::Coordinate& getInvalidPoint();
    00198
    00199 };
    00200
    00201
    00202 } // namespace geos.geomgraph
    00203 } // namespace geos
    00204
    00205 #ifdef GEOS_INLINE
    00206 # include "geos/geomgraph/GeometryGraph.inl"
    00207 #endif
    00208
    00209 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
    00210
    00211 /**********************************************************************
    00212  * $Log$
    00213  * Revision 1.4  2006/06/13 22:00:26  strk
    00214  * Changed GeometryGraph::lineEdgeMap set comparison function to be pointer-based. Should be safe and much faster. Available tests all succeed.
    00215  *
    00216  * Revision 1.3  2006/03/29 15:23:49  strk
    00217  * Moved GeometryGraph inlines from .h to .inl file
    00218  *
    00219  * Revision 1.2  2006/03/24 09:52:41  strk
    00220  * USE_INLINE => GEOS_INLINE
    00221  *
    00222  * Revision 1.1  2006/03/09 16:46:49  strk
    00223  * geos::geom namespace definition, first pass at headers split
    00224  *
    00225  **********************************************************************/
    00226