<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GEOS: PlanarGraph.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>PlanarGraph.h</h1> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**********************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> * $Id: PlanarGraph.h 2733 2009-11-20 19:58:33Z strk $</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * GEOS - Geometry Engine Open Source</span> <a name="l00005"></a>00005 <span class="comment"> * http://geos.refractions.net</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2005-2006 Refractions Research Inc.</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * This is free software; you can redistribute and/or modify it under</span> <a name="l00010"></a>00010 <span class="comment"> * the terms of the GNU Lesser General Public Licence as published</span> <a name="l00011"></a>00011 <span class="comment"> * by the Free Software Foundation. </span> <a name="l00012"></a>00012 <span class="comment"> * See the COPYING file for more information.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> **********************************************************************/</span> <a name="l00015"></a>00015 <a name="l00016"></a>00016 <span class="preprocessor">#ifndef GEOS_PLANARGRAPH_PLANARGRAPH_H</span> <a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor">#define GEOS_PLANARGRAPH_PLANARGRAPH_H</span> <a name="l00018"></a>00018 <span class="preprocessor"></span> <a name="l00019"></a>00019 <span class="preprocessor">#include <geos/export.h></span> <a name="l00020"></a>00020 <span class="preprocessor">#include <geos/planargraph/NodeMap.h></span> <span class="comment">// for composition</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include <vector></span> <span class="comment">// for typedefs</span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="comment">// Forward declarations</span> <a name="l00025"></a>00025 <span class="keyword">namespace </span>geos { <a name="l00026"></a>00026 <span class="keyword">namespace </span>geom { <a name="l00027"></a>00027 <span class="keyword">class </span>Coordinate; <a name="l00028"></a>00028 } <a name="l00029"></a>00029 <span class="keyword">namespace </span>planargraph { <a name="l00030"></a>00030 <span class="keyword">class </span>DirectedEdge; <a name="l00031"></a>00031 <span class="keyword">class </span>Edge; <a name="l00032"></a>00032 <span class="keyword">class </span>Node; <a name="l00033"></a>00033 } <a name="l00034"></a>00034 } <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="keyword">namespace </span>geos { <a name="l00037"></a>00037 <span class="keyword">namespace </span>planargraph { <span class="comment">// geos.planargraph</span> <a name="l00038"></a>00038 <a name="l00052"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html">00052</a> <span class="keyword">class </span>GEOS_DLL <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html" title="Represents a directed graph which is embeddable in a planar surface.">PlanarGraph</a> { <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="keyword">protected</span>: <a name="l00055"></a>00055 <a name="l00056"></a>00056 std::vector<Edge*> edges; <a name="l00057"></a>00057 std::vector<DirectedEdge*> dirEdges; <a name="l00058"></a>00058 <a class="code" href="classgeos_1_1planargraph_1_1NodeMap.html" title="A map of Node, indexed by the coordinate of the node.">NodeMap</a> nodeMap; <a name="l00059"></a>00059 <a name="l00069"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a930a3d2e45f4a2caef6cb86cbe7fd731">00069</a> <span class="keywordtype">void</span> <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a930a3d2e45f4a2caef6cb86cbe7fd731" title="Adds a node to the std::map, replacing any that is already at that location.">add</a>(<a class="code" href="classgeos_1_1planargraph_1_1Node.html" title="A node in a PlanarGraph is a location where 0 or more Edge meet.">Node</a> *node) { <a name="l00070"></a>00070 nodeMap.add(node); <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00082"></a>00082 <span class="keywordtype">void</span> add(<a class="code" href="classgeos_1_1planargraph_1_1Edge.html" title="Represents an undirected edge of a PlanarGraph.">Edge</a> *edge); <a name="l00083"></a>00083 <a name="l00091"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a92507cdab36f99269e388d190b01e227">00091</a> <span class="keywordtype">void</span> <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a92507cdab36f99269e388d190b01e227" title="Adds the Edge to this PlanarGraph.">add</a>(<a class="code" href="classgeos_1_1planargraph_1_1DirectedEdge.html" title="Represents a directed edge in a PlanarGraph.">DirectedEdge</a> *dirEdge) { <a name="l00092"></a>00092 dirEdges.push_back(dirEdge); <a name="l00093"></a>00093 } <a name="l00094"></a>00094 <a name="l00095"></a>00095 <span class="keyword">public</span>: <a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="keyword">typedef</span> std::vector<Edge *> EdgeContainer; <a name="l00098"></a>00098 <span class="keyword">typedef</span> EdgeContainer::iterator EdgeIterator; <a name="l00099"></a>00099 <a name="l00100"></a>00100 <a name="l00105"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a01eaae76182f6582461a7a6e391269bc">00105</a> <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a01eaae76182f6582461a7a6e391269bc" title="Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes.">PlanarGraph</a>() {} <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="keyword">virtual</span> ~<a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html" title="Represents a directed graph which is embeddable in a planar surface.">PlanarGraph</a>() {} <a name="l00108"></a>00108 <a name="l00114"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a08ddec6cb0d67c5837227475058ebdd4">00114</a> <a class="code" href="classgeos_1_1planargraph_1_1Node.html" title="A node in a PlanarGraph is a location where 0 or more Edge meet.">Node</a>* <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a08ddec6cb0d67c5837227475058ebdd4" title="Returns the Node at the given location, or null if no Node was there.">findNode</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& pt) { <a name="l00115"></a>00115 <span class="keywordflow">return</span> nodeMap.find(pt); <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00122"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a5e041772de46fbd0d04b9adced4eddc4">00122</a> NodeMap::container::iterator <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a5e041772de46fbd0d04b9adced4eddc4" title="Returns an Iterator over the Nodes in this PlanarGraph.">nodeIterator</a>() { <a name="l00123"></a>00123 <span class="keywordflow">return</span> nodeMap.begin(); <a name="l00124"></a>00124 } <a name="l00125"></a>00125 <a name="l00126"></a>00126 NodeMap::container::iterator nodeBegin() { <a name="l00127"></a>00127 <span class="keywordflow">return</span> nodeMap.begin(); <a name="l00128"></a>00128 } <a name="l00129"></a>00129 <a name="l00130"></a>00130 NodeMap::container::const_iterator nodeBegin()<span class="keyword"> const </span>{ <a name="l00131"></a>00131 <span class="keywordflow">return</span> nodeMap.begin(); <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <a name="l00134"></a>00134 NodeMap::container::iterator nodeEnd() { <a name="l00135"></a>00135 <span class="keywordflow">return</span> nodeMap.end(); <a name="l00136"></a>00136 } <a name="l00137"></a>00137 <a name="l00138"></a>00138 NodeMap::container::const_iterator nodeEnd()<span class="keyword"> const </span>{ <a name="l00139"></a>00139 <span class="keywordflow">return</span> nodeMap.end(); <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00148"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#ae2a0cbc53de6ee7191cf2a19156f7053">00148</a> <span class="keywordtype">void</span> <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#ae2a0cbc53de6ee7191cf2a19156f7053" title="Returns the Nodes in this PlanarGraph.">getNodes</a>(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); } <a name="l00149"></a>00149 <a name="l00158"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a3acaf9fdbb54655fdf1e097462dc49d6">00158</a> std::vector<DirectedEdge*>::iterator <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a3acaf9fdbb54655fdf1e097462dc49d6" title="Returns an Iterator over the DirectedEdges in this PlanarGraph, in the order in which they were added...">dirEdgeIterator</a>() { <a name="l00159"></a>00159 <span class="keywordflow">return</span> dirEdges.begin(); <a name="l00160"></a>00160 } <a name="l00161"></a>00161 <a name="l00163"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a90498ae812494e804effb9f244679212">00163</a> std::vector<Edge*>::iterator <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a90498ae812494e804effb9f244679212" title="Alias for edgeBegin().">edgeIterator</a>() { <a name="l00164"></a>00164 <span class="keywordflow">return</span> edges.begin(); <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <a name="l00168"></a>00168 <span class="comment">//</span> <a name="l00172"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#aab2c1afdc638406f50b88c33aa592d86">00172</a> <span class="comment"></span> std::vector<Edge*>::iterator <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#aab2c1afdc638406f50b88c33aa592d86" title="Returns an iterator to first Edge in this graph.">edgeBegin</a>() { <a name="l00173"></a>00173 <span class="keywordflow">return</span> edges.begin(); <a name="l00174"></a>00174 } <a name="l00175"></a>00175 <a name="l00177"></a>00177 <span class="comment">//</span> <a name="l00181"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#abf4facc89036fbd09552c3edc8ab8d57">00181</a> <span class="comment"></span> std::vector<Edge*>::iterator <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#abf4facc89036fbd09552c3edc8ab8d57" title="Returns an iterator to one-past last Edge in this graph.">edgeEnd</a>() { <a name="l00182"></a>00182 <span class="keywordflow">return</span> edges.end(); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00190"></a><a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a46c8a6e3d8f79b1eab86fa542c073157">00190</a> std::vector<Edge*>* <a class="code" href="classgeos_1_1planargraph_1_1PlanarGraph.html#a46c8a6e3d8f79b1eab86fa542c073157" title="Returns the Edges that have been added to this PlanarGraph.">getEdges</a>() { <a name="l00191"></a>00191 <span class="keywordflow">return</span> &edges; <a name="l00192"></a>00192 } <a name="l00193"></a>00193 <a name="l00203"></a>00203 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="classgeos_1_1planargraph_1_1Edge.html" title="Represents an undirected edge of a PlanarGraph.">Edge</a> *edge); <a name="l00204"></a>00204 <a name="l00214"></a>00214 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="classgeos_1_1planargraph_1_1DirectedEdge.html" title="Represents a directed edge in a PlanarGraph.">DirectedEdge</a> *de); <a name="l00215"></a>00215 <a name="l00221"></a>00221 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="classgeos_1_1planargraph_1_1Node.html" title="A node in a PlanarGraph is a location where 0 or more Edge meet.">Node</a> *node); <a name="l00222"></a>00222 <a name="l00228"></a>00228 std::vector<Node*>* findNodesOfDegree(<span class="keywordtype">size_t</span> degree); <a name="l00229"></a>00229 }; <a name="l00230"></a>00230 <a name="l00231"></a>00231 } <span class="comment">// namespace geos::planargraph</span> <a name="l00232"></a>00232 } <span class="comment">// namespace geos</span> <a name="l00233"></a>00233 <a name="l00234"></a>00234 <span class="preprocessor">#endif // GEOS_PLANARGRAPH_PLANARGRAPH_H</span> <a name="l00235"></a>00235 <span class="preprocessor"></span> <a name="l00236"></a>00236 <span class="comment">/**********************************************************************</span> <a name="l00237"></a>00237 <span class="comment"> * $Log$</span> <a name="l00238"></a>00238 <span class="comment"> * Revision 1.2 2006/06/12 10:49:43 strk</span> <a name="l00239"></a>00239 <span class="comment"> * unsigned int => size_t</span> <a name="l00240"></a>00240 <span class="comment"> *</span> <a name="l00241"></a>00241 <span class="comment"> * Revision 1.1 2006/03/21 21:42:54 strk</span> <a name="l00242"></a>00242 <span class="comment"> * planargraph.h header split, planargraph:: classes renamed to match JTS symbols</span> <a name="l00243"></a>00243 <span class="comment"> *</span> <a name="l00244"></a>00244 <span class="comment"> **********************************************************************/</span> <a name="l00245"></a>00245 </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Thu Jul 22 2010 for GEOS by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address> </body> </html>