Files
geometry/doc/doxygen_output/html/section__iterators_8hpp_source.html
Barend Gehrels 363580fbf6 Added old doxygen docs
[SVN r59777]
2010-02-20 15:57:12 +00:00

284 lines
23 KiB
HTML
Raw Blame History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Geometry (aka GGL, Generic Geometry Library)</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head>
<table cellpadding="2" width="100%">
<tbody>
<tr>
<td valign="top">
<img alt="Boost.Geometry" src="images/ggl-logo-big.png" height="80" width="200">
&nbsp;&nbsp;
</td>
<td valign="top" align="right">
<a href="http://www.boost.org">
<img alt="Boost C++ Libraries" src="images/accepted_by_boost.png" height="80" width="230" border="0">
</a>
</td>
</tr>
</tbody>
</table>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</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>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<h1>boost/geometry/iterators/section_iterators.hpp</h1><a href="section__iterators_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Boost.Geometry (aka GGL, Generic Geometry Library)</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
<a name="l00005"></a>00005 <span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
<a name="l00006"></a>00006 <span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
<a name="l00007"></a>00007 <span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="preprocessor">#ifndef BOOST_GEOMETRY_ITERATORS_SECTION_ITERATORS_HPP</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_GEOMETRY_ITERATORS_SECTION_ITERATORS_HPP</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;iterator&gt;</span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;<a class="code" href="access_8hpp.html">boost/geometry/core/access.hpp</a>&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;<a class="code" href="base_8hpp.html">boost/geometry/iterators/base.hpp</a>&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;<a class="code" href="overlaps_8hpp.html">boost/geometry/algorithms/overlaps.hpp</a>&gt;</span>
<a name="l00017"></a>00017
<a name="l00018"></a>00018
<a name="l00019"></a>00019 <span class="comment">// FILE WILL BE SPLITTED</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>geometry
<a name="l00022"></a>00022 {
<a name="l00023"></a><a class="code" href="namespaceboost_1_1geometry_1_1detail.html">00023</a> <span class="keyword">namespace </span>detail
<a name="l00024"></a>00024 {
<a name="l00025"></a>00025 <span class="keyword">template</span> &lt;<span class="keywordtype">size_t</span> D, <span class="keyword">typename</span> P, <span class="keyword">typename</span> B&gt;
<a name="l00026"></a><a class="code" href="namespaceboost_1_1geometry_1_1detail.html#5aa1ce446061b9a5655eddbdef75bfd4">00026</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceboost_1_1geometry_1_1detail.html#5aa1ce446061b9a5655eddbdef75bfd4">exceeding</a>(<span class="keywordtype">short</span> <span class="keywordtype">int</span> dir, <span class="keyword">const</span> P&amp; <a class="code" href="classboost_1_1geometry_1_1point.html" title="Basic point class, having coordinates defined in a neutral way.">point</a>, <span class="keyword">const</span> B&amp; <a class="code" href="classboost_1_1geometry_1_1box.html" title="Class box: defines a box made of two describing points.">box</a>)
<a name="l00027"></a>00027 {
<a name="l00028"></a>00028 <span class="keywordflow">return</span> (dir == 1 &amp;&amp; get&lt;D&gt;(point) &gt; get&lt;1, D&gt;(box))
<a name="l00029"></a>00029 || (dir == -1 &amp;&amp; get&lt;D&gt;(point) &lt; get&lt;0, D&gt;(box));
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keyword">template</span> &lt;<span class="keywordtype">size_t</span> D, <span class="keyword">typename</span> P, <span class="keyword">typename</span> B&gt;
<a name="l00033"></a><a class="code" href="namespaceboost_1_1geometry_1_1detail.html#cafc8f4ed09a5ac6f870fc52fd706625">00033</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceboost_1_1geometry_1_1detail.html#cafc8f4ed09a5ac6f870fc52fd706625">preceding</a>(<span class="keywordtype">short</span> <span class="keywordtype">int</span> dir, <span class="keyword">const</span> P&amp; <a class="code" href="classboost_1_1geometry_1_1point.html" title="Basic point class, having coordinates defined in a neutral way.">point</a>, <span class="keyword">const</span> B&amp; <a class="code" href="classboost_1_1geometry_1_1box.html" title="Class box: defines a box made of two describing points.">box</a>)
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035 <span class="keywordflow">return</span> (dir == 1 &amp;&amp; get&lt;D&gt;(point) &lt; get&lt;0, D&gt;(box))
<a name="l00036"></a>00036 || (dir == -1 &amp;&amp; get&lt;D&gt;(point) &gt; get&lt;1, D&gt;(box));
<a name="l00037"></a>00037 }
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="comment">// Iterator walking through ring/sections, delivering only those points of the ring</span>
<a name="l00042"></a>00042 <span class="comment">// which are inside the specified box (using the sections)</span>
<a name="l00043"></a>00043 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> G, <span class="keyword">typename</span> S, <span class="keyword">typename</span> B, <span class="keywordtype">size_t</span> D&gt;
<a name="l00044"></a><a class="code" href="structboost_1_1geometry_1_1section__iterator.html">00044</a> <span class="keyword">struct </span><a class="code" href="structboost_1_1geometry_1_1section__iterator.html">section_iterator</a> : <span class="keyword">public</span> detail::iterators::iterator_base&lt;
<a name="l00045"></a>00045 section_iterator&lt;G, S, B, D&gt;,
<a name="l00046"></a>00046 typename boost::range_const_iterator&lt;G&gt;::type
<a name="l00047"></a>00047 &gt;
<a name="l00048"></a>00048 {
<a name="l00049"></a><a class="code" href="structboost_1_1geometry_1_1section__iterator.html#c09f73e325921cc50ebcd96bed0f8096">00049</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structboost_1_1geometry_1_1section__iterator.html#c09f73e325921cc50ebcd96bed0f8096">boost::iterator_core_access</a>;
<a name="l00050"></a>00050
<a name="l00051"></a><a class="code" href="structboost_1_1geometry_1_1section__iterator.html#8607117c43a352ee0b8cdc56214dc75a">00051</a> <span class="keyword">inline</span> <a class="code" href="structboost_1_1geometry_1_1section__iterator.html#8607117c43a352ee0b8cdc56214dc75a">section_iterator</a>(<span class="keyword">const</span> G&amp; ring, <span class="keyword">const</span> S&amp; <a class="code" href="structboost_1_1geometry_1_1sections.html" title="Structure containing a collection of sections.">sections</a>, <span class="keyword">const</span> B&amp; <a class="code" href="classboost_1_1geometry_1_1box.html" title="Class box: defines a box made of two describing points.">box</a>)
<a name="l00052"></a>00052 : m_ring(ring)
<a name="l00053"></a>00053 , m_sections(sections)
<a name="l00054"></a>00054 , m_box(box)
<a name="l00055"></a>00055 , m_section_iterator(boost::begin(m_sections))
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 stay_within_box();
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="keyword">private</span> :
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="keyword">inline</span> <span class="keywordtype">void</span> increment()
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065 (this-&gt;base_reference())++;
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="comment">// If end or exceeding specified box, go to next section</span>
<a name="l00068"></a>00068 <span class="keywordflow">if</span> (this-&gt;base() == m_end
<a name="l00069"></a>00069 || detail::exceeding&lt;D&gt;(m_section_iterator-&gt;directions[0], *this-&gt;base(), m_box))
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071 m_section_iterator++;
<a name="l00072"></a>00072 stay_within_box();
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="comment">// Check if iterator is still in box and if not, go to the next section and advance until it is in box</span>
<a name="l00078"></a>00078 <span class="keywordtype">void</span> stay_within_box()
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 <span class="comment">// Find section having overlap with specified box</span>
<a name="l00081"></a>00081 <span class="keywordflow">while</span> (m_section_iterator != boost::end(m_sections)
<a name="l00082"></a>00082 &amp;&amp; ! <a class="code" href="group__overlaps.html#g8997503b86e1565f644ad0993d608caf" title="Determines overlap between two geometries.">overlaps</a>(m_section_iterator-&gt;bounding_box, m_box))
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084 m_section_iterator++;
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 <span class="keywordflow">if</span> (m_section_iterator != boost::end(m_sections))
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 this-&gt;base_reference() = boost::begin(m_ring) + m_section_iterator-&gt;begin_index;
<a name="l00089"></a>00089 m_end = boost::begin(m_ring) + m_section_iterator-&gt;end_index + 1;
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="comment">// While not yet at box, advance</span>
<a name="l00092"></a>00092 <span class="keywordflow">while</span>(this-&gt;base() != m_end
<a name="l00093"></a>00093 &amp;&amp; detail::preceding&lt;D&gt;(m_section_iterator-&gt;directions[0], *this-&gt;base(), m_box))
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 ++(this-&gt;base_reference());
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keywordflow">if</span> (this-&gt;base() == m_end)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100 <span class="comment">// This should actually not occur because of bbox check, but to be sure</span>
<a name="l00101"></a>00101 m_section_iterator++;
<a name="l00102"></a>00102 stay_within_box();
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 <span class="keywordflow">else</span>
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 this-&gt;base_reference() = boost::end(m_ring);
<a name="l00108"></a>00108 m_end = boost::end(m_ring);
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111
<a name="l00112"></a>00112
<a name="l00113"></a>00113 <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::range_const_iterator&lt;G&gt;::type IT;
<a name="l00114"></a>00114 <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::range_const_iterator&lt;S&gt;::type SIT;
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="keyword">const</span> G&amp; m_ring;
<a name="l00117"></a>00117 <span class="keyword">const</span> S&amp; m_sections;
<a name="l00118"></a>00118 <span class="keyword">const</span> B&amp; m_box;
<a name="l00119"></a>00119
<a name="l00120"></a>00120 IT m_end;
<a name="l00121"></a>00121 SIT m_section_iterator;
<a name="l00122"></a>00122 };
<a name="l00123"></a>00123
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="comment">// Iterator walking through ring/sections, delivering only those points of the ring</span>
<a name="l00126"></a>00126 <span class="comment">// which are inside the specified box (using the sections)</span>
<a name="l00127"></a>00127 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> G, <span class="keyword">typename</span> SEC, <span class="keyword">typename</span> B, <span class="keywordtype">size_t</span> D&gt;
<a name="l00128"></a><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html">00128</a> <span class="keyword">struct </span><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html">one_section_segment_iterator</a> : <span class="keyword">public</span> detail::iterators::iterator_base&lt;
<a name="l00129"></a>00129 one_section_segment_iterator&lt;G, SEC, B, D&gt;
<a name="l00130"></a>00130 , typename boost::range_const_iterator&lt;G&gt;::type&gt;
<a name="l00131"></a>00131 {
<a name="l00132"></a><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#c09f73e325921cc50ebcd96bed0f8096">00132</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#c09f73e325921cc50ebcd96bed0f8096">boost::iterator_core_access</a>;
<a name="l00133"></a><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#ab032a07b69424ec87f75c762e166692">00133</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::range_const_iterator&lt;G&gt;::type <a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#ab032a07b69424ec87f75c762e166692">normal_iterator</a>;
<a name="l00134"></a>00134
<a name="l00135"></a><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#c64329a8fa6c4ead4aabc9a226f26b98">00135</a> <span class="keyword">inline</span> <a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#c64329a8fa6c4ead4aabc9a226f26b98">one_section_segment_iterator</a>(<span class="keyword">const</span> G&amp; ring, <span class="keyword">const</span> SEC&amp; <a class="code" href="structboost_1_1geometry_1_1section.html" title="Structure containing section information.">section</a>, <span class="keyword">const</span> B&amp; <a class="code" href="classboost_1_1geometry_1_1box.html" title="Class box: defines a box made of two describing points.">box</a>)
<a name="l00136"></a>00136 : m_box(&amp;box)
<a name="l00137"></a>00137 , m_dir(section.directions[0])
<a name="l00138"></a>00138 {
<a name="l00139"></a>00139 init(section, ring);
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141
<a name="l00142"></a><a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#e3fbd0be6c15ece0226903df75524a4a">00142</a> <span class="keyword">inline</span> <a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#c64329a8fa6c4ead4aabc9a226f26b98">one_section_segment_iterator</a>(<a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#ab032a07b69424ec87f75c762e166692">normal_iterator</a> end)
<a name="l00143"></a>00143 : m_section_end(end)
<a name="l00144"></a>00144 , m_ring_end(end)
<a name="l00145"></a>00145 , m_box(NULL)
<a name="l00146"></a>00146 , m_dir(0)
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148 this-&gt;base_reference() = end;
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150
<a name="l00151"></a>00151
<a name="l00152"></a>00152 <span class="keyword">private</span> :
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <span class="keyword">inline</span> <span class="keywordtype">void</span> increment()
<a name="l00155"></a>00155 {
<a name="l00156"></a>00156 m_previous = (this-&gt;base_reference())++;
<a name="l00157"></a>00157
<a name="l00158"></a>00158 <span class="keywordflow">if</span> (this-&gt;base() == m_section_end
<a name="l00159"></a>00159 || detail::exceeding&lt;D&gt;(m_dir, *m_previous, *m_box))
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161 this-&gt;base_reference() = m_ring_end;
<a name="l00162"></a>00162 }
<a name="l00163"></a>00163 }
<a name="l00164"></a>00164
<a name="l00165"></a>00165 <span class="comment">// Check if iterator is still in box and if not, go to the next section and advance until it is in box</span>
<a name="l00166"></a>00166 <span class="keywordtype">void</span> init(<span class="keyword">const</span> SEC&amp; section, <span class="keyword">const</span> G&amp; ring)
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168 <span class="comment">//this-&gt;base_reference();</span>
<a name="l00169"></a>00169 m_section_end = boost::begin(ring) + section.end_index + 1;
<a name="l00170"></a>00170 m_ring_end = boost::end(ring);
<a name="l00171"></a>00171
<a name="l00172"></a>00172 this-&gt;base_reference() = boost::begin(ring) + section.begin_index;
<a name="l00173"></a>00173
<a name="l00174"></a>00174 <span class="comment">/* Performance, TO BE CHECKED!</span>
<a name="l00175"></a>00175 <span class="comment"> normal_iterator next = boost::begin(ring) + section.begin_index;</span>
<a name="l00176"></a>00176 <span class="comment"> if (next != m_section_end &amp;&amp; next != m_ring_end)</span>
<a name="l00177"></a>00177 <span class="comment"> {</span>
<a name="l00178"></a>00178 <span class="comment"></span>
<a name="l00179"></a>00179 <span class="comment"> // While (not end and) not yet at box, advance</span>
<a name="l00180"></a>00180 <span class="comment"> normal_iterator it = next++;</span>
<a name="l00181"></a>00181 <span class="comment"> while(next != m_section_end &amp;&amp; next != m_ring_end</span>
<a name="l00182"></a>00182 <span class="comment"> &amp;&amp; detail::preceding&lt;D&gt;(m_dir, *next, *m_box))</span>
<a name="l00183"></a>00183 <span class="comment"> {</span>
<a name="l00184"></a>00184 <span class="comment"> it = next++;</span>
<a name="l00185"></a>00185 <span class="comment"> }</span>
<a name="l00186"></a>00186 <span class="comment"></span>
<a name="l00187"></a>00187 <span class="comment"></span>
<a name="l00188"></a>00188 <span class="comment"> if (it == m_section_end)</span>
<a name="l00189"></a>00189 <span class="comment"> {</span>
<a name="l00190"></a>00190 <span class="comment"> this-&gt;base_reference() = m_ring_end;</span>
<a name="l00191"></a>00191 <span class="comment"> }</span>
<a name="l00192"></a>00192 <span class="comment"> else</span>
<a name="l00193"></a>00193 <span class="comment"> {</span>
<a name="l00194"></a>00194 <span class="comment"> this-&gt;base_reference() = it;</span>
<a name="l00195"></a>00195 <span class="comment"> }</span>
<a name="l00196"></a>00196 <span class="comment"> }</span>
<a name="l00197"></a>00197 <span class="comment"> else</span>
<a name="l00198"></a>00198 <span class="comment"> {</span>
<a name="l00199"></a>00199 <span class="comment"> this-&gt;base_reference() = m_ring_end;</span>
<a name="l00200"></a>00200 <span class="comment"> }</span>
<a name="l00201"></a>00201 <span class="comment"> */</span>
<a name="l00202"></a>00202
<a name="l00203"></a>00203 m_previous = this-&gt;base();
<a name="l00204"></a>00204 }
<a name="l00205"></a>00205
<a name="l00206"></a>00206
<a name="l00207"></a>00207 <span class="keyword">const</span> B* m_box;
<a name="l00208"></a>00208 <span class="keywordtype">short</span> <span class="keywordtype">int</span> m_dir;
<a name="l00209"></a>00209
<a name="l00210"></a>00210 <a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#ab032a07b69424ec87f75c762e166692">normal_iterator</a> m_previous;
<a name="l00211"></a>00211 <a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#ab032a07b69424ec87f75c762e166692">normal_iterator</a> m_section_end;
<a name="l00212"></a>00212 <a class="code" href="structboost_1_1geometry_1_1one__section__segment__iterator.html#ab032a07b69424ec87f75c762e166692">normal_iterator</a> m_ring_end;
<a name="l00213"></a>00213 };
<a name="l00214"></a>00214
<a name="l00215"></a>00215 }} <span class="comment">// namespace boost::geometry</span>
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="preprocessor">#endif // BOOST_GEOMETRY_ITERATORS_SECTION_ITERATORS_HPP</span>
</pre></div></div>
<hr size="1">
<table width="100%">
<tbody>
<tr>
<td align="left"><small>
<p>December 1, 2009</p>
</small></td>
<td align="right">
<small>Copyright <20> 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
Copyright <20> 2008-2009 Bruno Lalande, Paris<br>
Copyright <20> 2009 Mateusz Loskot, Cadcorp, London<br>
</small>
</td>
</tr>
</tbody>
</table>
<address style="text-align: right;"><small>
Documentation is generated by&nbsp;<a href="http://www.doxygen.org/index.html">Doxygen</a>
</small></address>
</body>
</html>