<!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>OMPL: src/ompl/datastructures/GridN.h Source File</title> <meta name="author" content="Ioan A. Șucan, Mark Moll, Lydia E. Kavraki"> <link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="../css/print.css" type="text/css" media="print"> <!--[if lt IE 7]> <script type="text/javascript" src="../js/jquery/jquery.js"></script> <script type="text/javascript" src="../js/jquery/jquery.dropdown.js"></script> <![endif]--> <script type="text/javaScript" src="search/search.js"></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-9156598-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body onload='searchBox.OnSelectItem(0);'> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search API'); --></script> <div class="navigation" id="top"> <div class="tabs" id="ompltitle"> <ul class="tablist"> <li>The Open Motion Planning Library</li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search API" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <ul id="nav" class="dropdown"> <li class="first"><a href="index.html">Home</a></li> <li><a href="download.html">Download</a></li> <li><a href="documentation.html">Documentation</a></li> <li><span class="dir">Code API</span> <ul> <li><a href="api_overview.html">API Overview</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="annotated.html">Classes</a></li> <li><a href="files.html">Files</a></li> <li><a href="dirs.html">Directories</a></li> </ul> </li> <li><span class="dir">Community</span> <ul> <li><a href="developers.html">Developers</a></li> <li><a href="thirdparty.html">Contributions</a></li> <li><a href="education.html">Education</a></li> <li><a href="gallery.html">Gallery</a></li> </ul> </li> <li><span class="dir">About</span> <ul> <li><a href="license.html">License</a></li> <li><a href="citations.html">Citations</a></li> <li><a href="acknowledgements.html">Acknowledgments</a></li> <li><a href="contact.html">Contact Us</a></li> </ul> </li> </ul> </div> <!--- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="" frameborder="0"name="MSearchResults" id="MSearchResults"></iframe> </div> <div class="container"> <div class="span-22 push-2 first last"> <div> <!-- Generated by Doxygen 1.7.4 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_f5421e52a658cd938113ed6044324834.html">src</a> </li> <li class="navelem"><a class="el" href="dir_ae92c2ff78847f0cb49b545f9089bbbc.html">ompl</a> </li> <li class="navelem"><a class="el" href="dir_bcc018587a1660af6e54d7cc713e88f2.html">datastructures</a> </li> </ul> </div> </div> <div class="header"> <div class="headertitle"> <div class="title">GridN.h</div> </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">* Software License Agreement (BSD License)</span> <a name="l00003"></a>00003 <span class="comment">*</span> <a name="l00004"></a>00004 <span class="comment">* Copyright (c) 2010, Rice University</span> <a name="l00005"></a>00005 <span class="comment">* All rights reserved.</span> <a name="l00006"></a>00006 <span class="comment">*</span> <a name="l00007"></a>00007 <span class="comment">* Redistribution and use in source and binary forms, with or without</span> <a name="l00008"></a>00008 <span class="comment">* modification, are permitted provided that the following conditions</span> <a name="l00009"></a>00009 <span class="comment">* are met:</span> <a name="l00010"></a>00010 <span class="comment">*</span> <a name="l00011"></a>00011 <span class="comment">* * Redistributions of source code must retain the above copyright</span> <a name="l00012"></a>00012 <span class="comment">* notice, this list of conditions and the following disclaimer.</span> <a name="l00013"></a>00013 <span class="comment">* * Redistributions in binary form must reproduce the above</span> <a name="l00014"></a>00014 <span class="comment">* copyright notice, this list of conditions and the following</span> <a name="l00015"></a>00015 <span class="comment">* disclaimer in the documentation and/or other materials provided</span> <a name="l00016"></a>00016 <span class="comment">* with the distribution.</span> <a name="l00017"></a>00017 <span class="comment">* * Neither the name of the Rice University nor the names of its</span> <a name="l00018"></a>00018 <span class="comment">* contributors may be used to endorse or promote products derived</span> <a name="l00019"></a>00019 <span class="comment">* from this software without specific prior written permission.</span> <a name="l00020"></a>00020 <span class="comment">*</span> <a name="l00021"></a>00021 <span class="comment">* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span> <a name="l00022"></a>00022 <span class="comment">* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span> <a name="l00023"></a>00023 <span class="comment">* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS</span> <a name="l00024"></a>00024 <span class="comment">* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE</span> <a name="l00025"></a>00025 <span class="comment">* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,</span> <a name="l00026"></a>00026 <span class="comment">* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span> <a name="l00027"></a>00027 <span class="comment">* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span> <a name="l00028"></a>00028 <span class="comment">* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span> <a name="l00029"></a>00029 <span class="comment">* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span> <a name="l00030"></a>00030 <span class="comment">* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN</span> <a name="l00031"></a>00031 <span class="comment">* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span> <a name="l00032"></a>00032 <span class="comment">* POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00033"></a>00033 <span class="comment">*********************************************************************/</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="comment">/* Author: Ioan Sucan */</span> <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="preprocessor">#ifndef OMPL_DATASTRUCTURES_GRID_N_</span> <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#define OMPL_DATASTRUCTURES_GRID_N_</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00040"></a>00040 <span class="preprocessor">#include "ompl/datastructures/Grid.h"</span> <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="keyword">namespace </span>ompl <a name="l00043"></a>00043 { <a name="l00044"></a>00044 <a name="l00046"></a>00046 <span class="keyword">template</span> <<span class="keyword">typename</span> _T> <a name="l00047"></a><a class="code" href="classompl_1_1GridN.html">00047</a> <span class="keyword">class </span><a class="code" href="classompl_1_1GridN.html" title="Representation of a grid where cells keep track of how many neighbors they have.">GridN</a> : <span class="keyword">public</span> <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid</a><_T> <a name="l00048"></a>00048 { <a name="l00049"></a>00049 <span class="keyword">public</span>: <a name="l00050"></a>00050 <a name="l00052"></a><a class="code" href="classompl_1_1GridN.html#aa26d52609e9a958a0dee1c774d817f34">00052</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structompl_1_1Grid_1_1Cell.html" title="Definition of a cell in this grid.">Grid<_T>::Cell</a> <a class="code" href="classompl_1_1GridN.html#aa26d52609e9a958a0dee1c774d817f34" title="Datatype for cell in base class.">BaseCell</a>; <a name="l00053"></a>00053 <a name="l00055"></a><a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877">00055</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="classompl_1_1Grid.html#a75eda082fd346c84697130d347c1eb2f" title="The datatype for arrays of cells.">Grid<_T>::CellArray</a> <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a>; <a name="l00056"></a>00056 <a name="l00058"></a><a class="code" href="classompl_1_1GridN.html#ae15a0d9d76a01bc9f98afbed8ce23342">00058</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Grid<_T>::Coord</a> <a class="code" href="classompl_1_1GridN.html#ae15a0d9d76a01bc9f98afbed8ce23342" title="Datatype for cell coordinates.">Coord</a>; <a name="l00059"></a>00059 <a name="l00061"></a><a class="code" href="structompl_1_1GridN_1_1Cell.html">00061</a> <span class="keyword">struct </span><a class="code" href="structompl_1_1Grid_1_1Cell.html" title="Definition of a cell in this grid.">Cell</a> : <span class="keyword">public</span> <a class="code" href="structompl_1_1Grid_1_1Cell.html" title="Definition of a cell in this grid.">BaseCell</a> <a name="l00062"></a>00062 { <a name="l00064"></a><a class="code" href="structompl_1_1GridN_1_1Cell.html#ab454d9ba57e23ae1687e34bde67a4cae">00064</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structompl_1_1GridN_1_1Cell.html#ab454d9ba57e23ae1687e34bde67a4cae" title="The number of neighbors.">neighbors</a>; <a name="l00065"></a>00065 <a name="l00067"></a><a class="code" href="structompl_1_1GridN_1_1Cell.html#adb46d818fb6457e25c0c9455591048c0">00067</a> <span class="keywordtype">bool</span> <a class="code" href="structompl_1_1GridN_1_1Cell.html#adb46d818fb6457e25c0c9455591048c0" title="A flag indicating whether this cell is on the border or not.">border</a>; <a name="l00068"></a>00068 <a name="l00069"></a>00069 <a class="code" href="structompl_1_1Grid_1_1Cell.html" title="Definition of a cell in this grid.">Cell</a>(<span class="keywordtype">void</span>) : <a class="code" href="structompl_1_1Grid_1_1Cell.html" title="Definition of a cell in this grid.">BaseCell</a>(), <a class="code" href="structompl_1_1GridN_1_1Cell.html#ab454d9ba57e23ae1687e34bde67a4cae" title="The number of neighbors.">neighbors</a>(0), <a class="code" href="structompl_1_1GridN_1_1Cell.html#adb46d818fb6457e25c0c9455591048c0" title="A flag indicating whether this cell is on the border or not.">border</a>(true) <a name="l00070"></a>00070 { <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="keyword">virtual</span> ~<a class="code" href="structompl_1_1Grid_1_1Cell.html" title="Definition of a cell in this grid.">Cell</a>(<span class="keywordtype">void</span>) <a name="l00074"></a>00074 { <a name="l00075"></a>00075 } <a name="l00076"></a>00076 }; <a name="l00077"></a>00077 <a name="l00079"></a><a class="code" href="classompl_1_1GridN.html#a44c57859eaebc6bdc3c9c453662ac252">00079</a> <span class="keyword">typedef</span> std::vector<Cell*> <a class="code" href="classompl_1_1GridN.html#a44c57859eaebc6bdc3c9c453662ac252" title="The datatype for arrays of cells.">CellArray</a>; <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a name="l00083"></a>00083 <span class="keyword">explicit</span> <a name="l00084"></a><a class="code" href="classompl_1_1GridN.html#a19056d56c0b54dd8ef2c3c9d483f1211">00084</a> <a class="code" href="classompl_1_1GridN.html#a19056d56c0b54dd8ef2c3c9d483f1211" title="The constructor takes the dimension of the grid as argument.">GridN</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dimension) : <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid</a><_T>(dimension) <a name="l00085"></a>00085 { <a name="l00086"></a>00086 <a class="code" href="classompl_1_1GridN.html#ace239cb56364f32748d8c4a66ec8b31f" title="Flag indicating whether bounds are in effect for this grid.">hasBounds_</a> = <span class="keyword">false</span>; <a name="l00087"></a>00087 <a class="code" href="classompl_1_1GridN.html#a1e9cc38ff1df4dca6c9969f73dcad61e">overrideCellNeighborsLimit_</a> = <span class="keyword">false</span>; <a name="l00088"></a>00088 <a class="code" href="classompl_1_1GridN.html#a8f301e691e48294e1e216d1c7971aa9d">setDimension</a>(dimension); <a name="l00089"></a>00089 } <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="keyword">virtual</span> ~<a class="code" href="classompl_1_1GridN.html" title="Representation of a grid where cells keep track of how many neighbors they have.">GridN</a>(<span class="keywordtype">void</span>) <a name="l00092"></a>00092 { <a name="l00093"></a>00093 } <a name="l00094"></a>00094 <a name="l00097"></a><a class="code" href="classompl_1_1GridN.html#a8f301e691e48294e1e216d1c7971aa9d">00097</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#a8f301e691e48294e1e216d1c7971aa9d">setDimension</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dimension) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 assert(<a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::empty</a>() == <span class="keyword">true</span>); <a name="l00100"></a>00100 <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::dimension_</a> = dimension; <a name="l00101"></a>00101 <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::maxNeighbors_</a> = 2 * dimension; <a name="l00102"></a>00102 <span class="keywordflow">if</span> (!<a class="code" href="classompl_1_1GridN.html#a1e9cc38ff1df4dca6c9969f73dcad61e">overrideCellNeighborsLimit_</a>) <a name="l00103"></a>00103 <a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a> = <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::maxNeighbors_</a>; <a name="l00104"></a>00104 } <a name="l00105"></a>00105 <a name="l00106"></a>00106 <a name="l00115"></a><a class="code" href="classompl_1_1GridN.html#ae69767d44f200c28b21683ac76d1624d">00115</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#ae69767d44f200c28b21683ac76d1624d">setBounds</a>(<span class="keyword">const</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> &low, <span class="keyword">const</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> &up) <a name="l00116"></a>00116 { <a name="l00117"></a>00117 <a class="code" href="classompl_1_1GridN.html#acdf65b3cd4603c5d25597e62064751d8" title="If bounds are set, this defines the lower corner cell.">lowBound_</a> = low; <a name="l00118"></a>00118 <a class="code" href="classompl_1_1GridN.html#a422a9ee23538f070a2d9704e2ca70ead" title="If bounds are set, this defines the upper corner cell.">upBound_</a> = up; <a name="l00119"></a>00119 <a class="code" href="classompl_1_1GridN.html#ace239cb56364f32748d8c4a66ec8b31f" title="Flag indicating whether bounds are in effect for this grid.">hasBounds_</a> = <span class="keyword">true</span>; <a name="l00120"></a>00120 } <a name="l00121"></a>00121 <a name="l00124"></a><a class="code" href="classompl_1_1GridN.html#ae5d42e023d6aa00ac1d479dad46d7144">00124</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#ae5d42e023d6aa00ac1d479dad46d7144">setInteriorCellNeighborLimit</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> count) <a name="l00125"></a>00125 { <a name="l00126"></a>00126 <a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a> = count; <a name="l00127"></a>00127 assert(<a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a> > 0); <a name="l00128"></a>00128 <a class="code" href="classompl_1_1GridN.html#a1e9cc38ff1df4dca6c9969f73dcad61e">overrideCellNeighborsLimit_</a> = <span class="keyword">true</span>; <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00132"></a><a class="code" href="classompl_1_1GridN.html#a55b24fea201c89c9dab91c8624cec4e5">00132</a> Cell* <a class="code" href="classompl_1_1GridN.html#a55b24fea201c89c9dab91c8624cec4e5" title="Get the cell at a specified coordinate.">getCell</a>(<span class="keyword">const</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> &coord)<span class="keyword"> const</span> <a name="l00133"></a>00133 <span class="keyword"> </span>{ <a name="l00134"></a>00134 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span>Cell*<span class="keyword">></span>(<a class="code" href="classompl_1_1GridN.html#a55b24fea201c89c9dab91c8624cec4e5" title="Get the cell at a specified coordinate.">Grid<_T>::getCell</a>(coord)); <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <a name="l00138"></a><a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b">00138</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">neighbors</a>(<span class="keyword">const</span> Cell* cell, <a class="code" href="classompl_1_1Grid.html#a75eda082fd346c84697130d347c1eb2f" title="The datatype for arrays of cells.">CellArray</a>& list)<span class="keyword"> const</span> <a name="l00139"></a>00139 <span class="keyword"> </span>{ <a name="l00140"></a>00140 <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> test = cell->coord; <a name="l00141"></a>00141 <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">neighbors</a>(test, list); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <a name="l00145"></a><a class="code" href="classompl_1_1GridN.html#a1ba55b0907ff580f04447d58af044de0">00145</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">neighbors</a>(<span class="keyword">const</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a>& coord, <a class="code" href="classompl_1_1Grid.html#a75eda082fd346c84697130d347c1eb2f" title="The datatype for arrays of cells.">CellArray</a>& list)<span class="keyword"> const</span> <a name="l00146"></a>00146 <span class="keyword"> </span>{ <a name="l00147"></a>00147 <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> test = coord; <a name="l00148"></a>00148 <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">neighbors</a>(test, list); <a name="l00149"></a>00149 } <a name="l00150"></a>00150 <a name="l00152"></a><a class="code" href="classompl_1_1GridN.html#a6833ae9f28a7b57275faee82437255d9">00152</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">neighbors</a>(<a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a>& coord, <a class="code" href="classompl_1_1Grid.html#a75eda082fd346c84697130d347c1eb2f" title="The datatype for arrays of cells.">CellArray</a>& list)<span class="keyword"> const</span> <a name="l00153"></a>00153 <span class="keyword"> </span>{ <a name="l00154"></a>00154 <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a> baselist; <a name="l00155"></a>00155 <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">Grid<_T>::neighbors</a>(coord, baselist); <a name="l00156"></a>00156 list.reserve(list.size() + baselist.size()); <a name="l00157"></a>00157 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0 ; i < baselist.size() ; ++i) <a name="l00158"></a>00158 list.push_back(static_cast<Cell*>(baselist[i])); <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00166"></a><a class="code" href="classompl_1_1GridN.html#a5e226b31313bbb3887cc5a7be02a17a2">00166</a> <span class="keyword">virtual</span> <a class="code" href="classompl_1_1GridN.html#aa26d52609e9a958a0dee1c774d817f34" title="Datatype for cell in base class.">BaseCell</a>* <a class="code" href="classompl_1_1GridN.html#a5e226b31313bbb3887cc5a7be02a17a2">createCell</a>(<span class="keyword">const</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a>& coord, <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a> *nbh = NULL) <a name="l00167"></a>00167 { <a name="l00168"></a>00168 Cell *cell = <span class="keyword">new</span> Cell(); <a name="l00169"></a>00169 cell->coord = coord; <a name="l00170"></a>00170 <a name="l00171"></a>00171 <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a> *list = nbh ? nbh : <span class="keyword">new</span> <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a>(); <a name="l00172"></a>00172 <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">Grid<_T>::neighbors</a>(cell->coord, *list); <a name="l00173"></a>00173 <a name="l00174"></a>00174 <span class="keywordflow">for</span> (<span class="keyword">typename</span> BaseCellArray::iterator cl = list->begin() ; cl != list->end() ; ++cl) <a name="l00175"></a>00175 { <a name="l00176"></a>00176 Cell* c = <span class="keyword">static_cast<</span>Cell*<span class="keyword">></span>(*cl); <a name="l00177"></a>00177 c->neighbors++; <a name="l00178"></a>00178 <span class="keywordflow">if</span> (c->border && c->neighbors >= <a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a>) <a name="l00179"></a>00179 c->border = <span class="keyword">false</span>; <a name="l00180"></a>00180 } <a name="l00181"></a>00181 <a name="l00182"></a>00182 cell->neighbors = <a class="code" href="classompl_1_1GridN.html#ab065311737237a3731d41e0cbc4e1b76" title="Compute how many sides of a coordinate touch the boundaries of the grid.">numberOfBoundaryDimensions</a>(cell->coord) + list->size(); <a name="l00183"></a>00183 <span class="keywordflow">if</span> (cell->border && cell->neighbors >= <a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a>) <a name="l00184"></a>00184 cell->border = <span class="keyword">false</span>; <a name="l00185"></a>00185 <a name="l00186"></a>00186 <span class="keywordflow">if</span> (!nbh) <a name="l00187"></a>00187 <span class="keyword">delete</span> list; <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="keywordflow">return</span> cell; <a name="l00190"></a>00190 } <a name="l00191"></a>00191 <a name="l00194"></a><a class="code" href="classompl_1_1GridN.html#abafef2aa6c3f2e6c35ef1a82f10f97c8">00194</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<a class="code" href="classompl_1_1GridN.html#aa26d52609e9a958a0dee1c774d817f34" title="Datatype for cell in base class.">BaseCell</a> *cell) <a name="l00195"></a>00195 { <a name="l00196"></a>00196 <span class="keywordflow">if</span> (cell) <a name="l00197"></a>00197 { <a name="l00198"></a>00198 <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a> *list = <span class="keyword">new</span> <a class="code" href="classompl_1_1GridN.html#a4b26a5015ed43cb79442a1d7041ca877" title="Datatype for array of cells in base class.">BaseCellArray</a>(); <a name="l00199"></a>00199 <a class="code" href="classompl_1_1GridN.html#adfe8ed73a5dc1ce935e9abf51d91682b" title="Get the list of neighbors for a given cell.">Grid<_T>::neighbors</a>(cell->coord, *list); <a name="l00200"></a>00200 <span class="keywordflow">for</span> (<span class="keyword">typename</span> BaseCellArray::iterator cl = list->begin() ; cl != list->end() ; ++cl) <a name="l00201"></a>00201 { <a name="l00202"></a>00202 Cell* c = <span class="keyword">static_cast<</span>Cell*<span class="keyword">></span>(*cl); <a name="l00203"></a>00203 c->neighbors--; <a name="l00204"></a>00204 <span class="keywordflow">if</span> (!c->border && c->neighbors < <a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a>) <a name="l00205"></a>00205 c->border = <span class="keyword">true</span>; <a name="l00206"></a>00206 } <a name="l00207"></a>00207 <span class="keyword">delete</span> list; <a name="l00208"></a>00208 <span class="keyword">typename</span> <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::CoordHash::iterator</a> pos = <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::hash_</a>.find(&cell->coord); <a name="l00209"></a>00209 <span class="keywordflow">if</span> (pos != <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::hash_</a>.<a class="code" href="classompl_1_1Grid.html#ac5d360c8fa02bd6ec58aa8cbbc450dd7" title="Return the end() iterator for the grid.">end</a>()) <a name="l00210"></a>00210 { <a name="l00211"></a>00211 <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::hash_</a>.erase(pos); <a name="l00212"></a>00212 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00213"></a>00213 } <a name="l00214"></a>00214 } <a name="l00215"></a>00215 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00216"></a>00216 } <a name="l00217"></a>00217 <a name="l00219"></a><a class="code" href="classompl_1_1GridN.html#a1bc2efb9f3533a98381ee2e12da28117">00219</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1GridN.html#a1bc2efb9f3533a98381ee2e12da28117" title="Get the set of instantiated cells in the grid.">getCells</a>(<a class="code" href="classompl_1_1Grid.html#a75eda082fd346c84697130d347c1eb2f" title="The datatype for arrays of cells.">CellArray</a> &cells)<span class="keyword"> const</span> <a name="l00220"></a>00220 <span class="keyword"> </span>{ <a name="l00221"></a>00221 <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::CoordHash::const_iterator</a> i = <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::hash_</a>.<a class="code" href="classompl_1_1Grid.html#ad74c5df97cf3d54a1a15eff55596973c" title="Return the begin() iterator for the grid.">begin</a>() ; <a name="l00222"></a>00222 i != <a class="code" href="classompl_1_1Grid.html" title="Representation of a simple grid.">Grid<_T>::hash_</a>.<a class="code" href="classompl_1_1Grid.html#ac5d360c8fa02bd6ec58aa8cbbc450dd7" title="Return the end() iterator for the grid.">end</a>() ; ++i) <a name="l00223"></a>00223 cells.push_back(static_cast<Cell*>(i->second)); <a name="l00224"></a>00224 } <a name="l00225"></a>00225 <a name="l00226"></a>00226 <span class="keyword">protected</span>: <a name="l00227"></a>00227 <a name="l00229"></a><a class="code" href="classompl_1_1GridN.html#ab065311737237a3731d41e0cbc4e1b76">00229</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classompl_1_1GridN.html#ab065311737237a3731d41e0cbc4e1b76" title="Compute how many sides of a coordinate touch the boundaries of the grid.">numberOfBoundaryDimensions</a>(<span class="keyword">const</span> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> &coord)<span class="keyword"> const</span> <a name="l00230"></a>00230 <span class="keyword"> </span>{ <a name="l00231"></a>00231 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> result = 0; <a name="l00232"></a>00232 <span class="keywordflow">if</span> (<a class="code" href="classompl_1_1GridN.html#ace239cb56364f32748d8c4a66ec8b31f" title="Flag indicating whether bounds are in effect for this grid.">hasBounds_</a>) <a name="l00233"></a>00233 { <a name="l00234"></a>00234 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0 ; i < Grid<_T>::dimension_ ; ++i) <a name="l00235"></a>00235 <span class="keywordflow">if</span> (coord[i] == <a class="code" href="classompl_1_1GridN.html#acdf65b3cd4603c5d25597e62064751d8" title="If bounds are set, this defines the lower corner cell.">lowBound_</a>[i] || coord[i] == <a class="code" href="classompl_1_1GridN.html#a422a9ee23538f070a2d9704e2ca70ead" title="If bounds are set, this defines the upper corner cell.">upBound_</a>[i]) <a name="l00236"></a>00236 result++; <a name="l00237"></a>00237 } <a name="l00238"></a>00238 <span class="keywordflow">return</span> result; <a name="l00239"></a>00239 } <a name="l00240"></a>00240 <a name="l00242"></a><a class="code" href="classompl_1_1GridN.html#ace239cb56364f32748d8c4a66ec8b31f">00242</a> <span class="keywordtype">bool</span> <a class="code" href="classompl_1_1GridN.html#ace239cb56364f32748d8c4a66ec8b31f" title="Flag indicating whether bounds are in effect for this grid.">hasBounds_</a>; <a name="l00243"></a>00243 <a name="l00245"></a><a class="code" href="classompl_1_1GridN.html#acdf65b3cd4603c5d25597e62064751d8">00245</a> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> <a class="code" href="classompl_1_1GridN.html#acdf65b3cd4603c5d25597e62064751d8" title="If bounds are set, this defines the lower corner cell.">lowBound_</a>; <a name="l00246"></a>00246 <a name="l00248"></a><a class="code" href="classompl_1_1GridN.html#a422a9ee23538f070a2d9704e2ca70ead">00248</a> <a class="code" href="classompl_1_1Grid.html#ada6a72bd91ec78dd8a0806c00055d917" title="Definition of a coordinate within this grid.">Coord</a> <a class="code" href="classompl_1_1GridN.html#a422a9ee23538f070a2d9704e2ca70ead" title="If bounds are set, this defines the upper corner cell.">upBound_</a>; <a name="l00249"></a>00249 <a name="l00253"></a><a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">00253</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classompl_1_1GridN.html#a035b9527b8cfd98a6e4f4d7472e668a1">interiorCellNeighborsLimit_</a>; <a name="l00254"></a>00254 <a name="l00257"></a><a class="code" href="classompl_1_1GridN.html#a1e9cc38ff1df4dca6c9969f73dcad61e">00257</a> <span class="keywordtype">bool</span> <a class="code" href="classompl_1_1GridN.html#a1e9cc38ff1df4dca6c9969f73dcad61e">overrideCellNeighborsLimit_</a>; <a name="l00258"></a>00258 }; <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <a name="l00261"></a>00261 <span class="preprocessor">#endif</span> </pre></div></div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> </div> <div class="footer span-22 push-2 last"> <a href="http://www.kavrakilab.org">Physical and Biological Computing Group</a> • <a href="http://www.cs.rice.edu">Department of Computer Science</a> • <a href="http://www.rice.edu">Rice University</a><br> <div class="gray">Generated on Sun Oct 9 2011 23:04:40 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.7.4</div> </div> </div> </body> </html>