GEOS 3.3.1
BufferSubgraph.h
00001 /**********************************************************************
00002  * $Id: BufferSubgraph.h 3301 2011-04-27 09:42:31Z strk $
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  * Last port: operation/buffer/BufferSubgraph.java r378 (JTS-1.12)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
00021 #define GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
00022 
00023 #include <geos/export.h>
00024 
00025 #include <geos/operation/buffer/RightmostEdgeFinder.h> // for composition
00026 
00027 #include <vector>
00028 #include <set>
00029 
00030 #ifdef _MSC_VER
00031 #pragma warning(push)
00032 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00033 #endif
00034 
00035 // Forward declarations
00036 namespace geos {
00037         namespace geom {
00038                 class Coordinate;
00039                 class Envelope;
00040         }
00041         namespace algorithm {
00042                 class CGAlgorithms;
00043         }
00044         namespace geomgraph {
00045                 class DirectedEdge;
00046                 class Node;
00047         }
00048 }
00049 
00050 namespace geos {
00051 namespace operation { // geos.operation
00052 namespace buffer { // geos.operation.buffer
00053 
00062 class GEOS_DLL BufferSubgraph {
00063 private:
00064         RightmostEdgeFinder finder;
00065 
00066         std::vector<geomgraph::DirectedEdge*> dirEdgeList;
00067 
00068         std::vector<geomgraph::Node*> nodes;
00069 
00070         geom::Coordinate *rightMostCoord;
00071 
00072         geom::Envelope *env;
00073 
00081         void addReachable(geomgraph::Node *startNode);
00082 
00084         //
00088         void add(geomgraph::Node* node, std::vector<geomgraph::Node*>* nodeStack);
00089 
00090         void clearVisitedEdges();
00091 
00098         // <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
00099         void computeDepths(geomgraph::DirectedEdge *startEdge);
00100 
00101         void computeNodeDepth(geomgraph::Node *n);
00102 
00103         void copySymDepths(geomgraph::DirectedEdge *de);
00104 
00105         bool contains(std::set<geomgraph::Node*>& nodes, geomgraph::Node *node);
00106 
00107 public:
00108 
00109         friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
00110 
00111         BufferSubgraph(); 
00112 
00113         ~BufferSubgraph();
00114 
00115         std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
00116 
00117         std::vector<geomgraph::Node*>* getNodes();
00118 
00122         geom::Coordinate* getRightmostCoordinate();
00123 
00132         void create(geomgraph::Node *node);
00133 
00134         void computeDepth(int outsideDepth);
00135 
00147         void findResultEdges();
00148 
00163         int compareTo(BufferSubgraph *);
00164 
00171         geom::Envelope *getEnvelope();
00172 };
00173 
00174 std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
00175 
00176 // INLINES
00177 inline geom::Coordinate*
00178 BufferSubgraph::getRightmostCoordinate() {return rightMostCoord;}
00179 
00180 inline std::vector<geomgraph::Node*>*
00181 BufferSubgraph::getNodes() { return &nodes; }
00182 
00183 inline std::vector<geomgraph::DirectedEdge*>*
00184 BufferSubgraph::getDirectedEdges() {
00185         return &dirEdgeList;
00186 }
00187 
00188 bool BufferSubgraphGT(BufferSubgraph *first, BufferSubgraph *second);
00189 
00190 } // namespace geos::operation::buffer
00191 } // namespace geos::operation
00192 } // namespace geos
00193 
00194 #ifdef _MSC_VER
00195 #pragma warning(pop)
00196 #endif
00197 
00198 #endif // ndef GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
00199 
00200 /**********************************************************************
00201  * $Log$
00202  * Revision 1.3  2006/03/15 11:45:06  strk
00203  * doxygen comments
00204  *
00205  * Revision 1.2  2006/03/14 14:16:52  strk
00206  * operator<< for BufferSubgraph, more debugging calls
00207  *
00208  * Revision 1.1  2006/03/14 00:19:40  strk
00209  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
00210  *
00211  **********************************************************************/
00212