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

- File List

# GeometryGraph.h

    00001 /**********************************************************************
    00002  * $Id: GeometryGraph.h 2773 2009-12-03 19:36:17Z 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  * 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     // Declare type as noncopyable
    00151     GeometryGraph(const GeometryGraph& other);
    00152     GeometryGraph& operator=(const GeometryGraph& rhs);
    00153
    00154 public:
    00155
    00156         static bool isInBoundary(int boundaryCount);
    00157
    00158         static int determineBoundary(int boundaryCount);
    00159
    00160         static int determineBoundary(
    00161                      const algorithm::BoundaryNodeRule& boundaryNodeRule,
    00162                                                     int boundaryCount);
    00163
    00164         GeometryGraph();
    00165
    00166         GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
    00167
    00168         GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom,
    00169                       const algorithm::BoundaryNodeRule& boundaryNodeRule);
    00170
    00171         virtual ~GeometryGraph();
    00172
    00173
    00174         const geom::Geometry* getGeometry();
    00175
    00177         std::vector<Node*>* getBoundaryNodes();
    00178
    00179         void getBoundaryNodes(std::vector<Node*>&bdyNodes);
    00180
    00182         geom::CoordinateSequence* getBoundaryPoints();
    00183
    00184         Edge* findEdge(const geom::LineString *line);
    00185
    00186         void computeSplitEdges(std::vector<Edge*> *edgelist);
    00187
    00188         void addEdge(Edge *e);
    00189
    00190         void addPoint(geom::Coordinate& pt);
    00191
    00207         index::SegmentIntersector* computeSelfNodes(
    00208                         algorithm::LineIntersector *li,
    00209                         bool computeRingSelfNodes);
    00210
    00211         // Quick inline calling the function above, the above should probably
    00212         // be deprecated.
    00213         index::SegmentIntersector* computeSelfNodes(
    00214                         algorithm::LineIntersector& li,
    00215                         bool computeRingSelfNodes);
    00216
    00217         index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
    00218                 algorithm::LineIntersector *li, bool includeProper);
    00219
    00220         std::vector<Edge*> *getEdges();
    00221
    00222         bool hasTooFewPoints();
    00223
    00224         const geom::Coordinate& getInvalidPoint();
    00225
    00226         const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
    00227         { return boundaryNodeRule; }
    00228
    00229 };
    00230
    00231
    00232 } // namespace geos.geomgraph
    00233 } // namespace geos
    00234
    00235 #ifdef GEOS_INLINE
    00236 # include "geos/geomgraph/GeometryGraph.inl"
    00237 #endif
    00238
    00239 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
    00240
    00241 /**********************************************************************
    00242  * $Log$
    00243  * Revision 1.4  2006/06/13 22:00:26  strk
    00244  * Changed GeometryGraph::lineEdgeMap set comparison function to be pointer-based. Should be safe and much faster. Available tests all succeed.
    00245  *
    00246  * Revision 1.3  2006/03/29 15:23:49  strk
    00247  * Moved GeometryGraph inlines from .h to .inl file
    00248  *
    00249  * Revision 1.2  2006/03/24 09:52:41  strk
    00250  * USE_INLINE => GEOS_INLINE
    00251  *
    00252  * Revision 1.1  2006/03/09 16:46:49  strk
    00253  * geos::geom namespace definition, first pass at headers split
    00254  *
    00255  **********************************************************************/
    00256