BufferSubgraph.h

00001 /**********************************************************************
00002  * $Id: BufferSubgraph.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_OP_BUFFER_BUFFERSUBGRAPH_H
00017 #define GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
00018 
00019 #include <vector>
00020 #include <set>
00021 
00022 #include <geos/operation/buffer/RightmostEdgeFinder.h> // for composition
00023 
00024 // Forward declarations
00025 namespace geos {
00026         namespace geom {
00027                 class Coordinate;
00028                 class Envelope;
00029         }
00030         namespace algorithm {
00031                 class CGAlgorithms;
00032         }
00033         namespace geomgraph {
00034                 class DirectedEdge;
00035                 class Node;
00036         }
00037 }
00038 
00039 namespace geos {
00040 namespace operation { // geos.operation
00041 namespace buffer { // geos.operation.buffer
00042 
00050 class BufferSubgraph {
00051 private:
00052         RightmostEdgeFinder finder;
00053 
00054         std::vector<geomgraph::DirectedEdge*> dirEdgeList;
00055 
00056         std::vector<geomgraph::Node*> nodes;
00057 
00058         geom::Coordinate *rightMostCoord;
00059 
00060         geom::Envelope *env;
00061 
00069         void addReachable(geomgraph::Node *startNode);
00070 
00072         //
00076         void add(geomgraph::Node* node, std::vector<geomgraph::Node*>* nodeStack);
00077 
00078         void clearVisitedEdges();
00079 
00086         // <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
00087         void computeDepths(geomgraph::DirectedEdge *startEdge);
00088 
00089         void computeNodeDepth(geomgraph::Node *n);
00090 
00091         void copySymDepths(geomgraph::DirectedEdge *de);
00092 
00093         bool contains(std::set<geomgraph::Node*>& nodes, geomgraph::Node *node);
00094 
00095 public:
00096 
00097         friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
00098 
00103         BufferSubgraph(algorithm::CGAlgorithms *cga=NULL);
00104 
00105         ~BufferSubgraph();
00106 
00107         std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
00108 
00109         std::vector<geomgraph::Node*>* getNodes();
00110 
00114         geom::Coordinate* getRightmostCoordinate();
00115 
00124         void create(geomgraph::Node *node);
00125 
00126         void computeDepth(int outsideDepth);
00127 
00139         void findResultEdges();
00140 
00155         int compareTo(BufferSubgraph *);
00156 
00163         geom::Envelope *getEnvelope();
00164 };
00165 
00166 std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
00167 
00168 // INLINES
00169 inline geom::Coordinate*
00170 BufferSubgraph::getRightmostCoordinate() {return rightMostCoord;}
00171 
00172 inline std::vector<geomgraph::Node*>*
00173 BufferSubgraph::getNodes() { return &nodes; }
00174 
00175 inline std::vector<geomgraph::DirectedEdge*>*
00176 BufferSubgraph::getDirectedEdges() {
00177         return &dirEdgeList;
00178 }
00179 
00180 bool BufferSubgraphGT(BufferSubgraph *first, BufferSubgraph *second);
00181 
00182 } // namespace geos::operation::buffer
00183 } // namespace geos::operation
00184 } // namespace geos
00185 
00186 #endif // ndef GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
00187 
00188 /**********************************************************************
00189  * $Log$
00190  * Revision 1.3  2006/03/15 11:45:06  strk
00191  * doxygen comments
00192  *
00193  * Revision 1.2  2006/03/14 14:16:52  strk
00194  * operator<< for BufferSubgraph, more debugging calls
00195  *
00196  * Revision 1.1  2006/03/14 00:19:40  strk
00197  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
00198  *
00199  **********************************************************************/
00200 

Generated on Fri Mar 27 04:52:35 2009 for GEOS by  doxygen 1.5.4