1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Boost.Range strided</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../index.html" title="Chapter 1. Geometry"> 8<link rel="up" href="../boost_range.html" title="Boost.Range"> 9<link rel="prev" href="sliced.html" title="Boost.Range sliced"> 10<link rel="next" href="../register.html" title="Macro's for adaption"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="sliced.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_range.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../register.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="geometry.reference.adapted.boost_range.strided"></a><a class="link" href="strided.html" title="Boost.Range strided">Boost.Range 28 strided</a> 29</h5></div></div></div> 30<p> 31 Boost.Range strided range adaptor is adapted to Boost.Geometry 32 </p> 33<h6> 34<a name="geometry.reference.adapted.boost_range.strided.h0"></a> 35 <span class="phrase"><a name="geometry.reference.adapted.boost_range.strided.description"></a></span><a class="link" href="strided.html#geometry.reference.adapted.boost_range.strided.description">Description</a> 36 </h6> 37<p> 38 Boost.Range strided range adaptor makes a strided range (usually begin 39 a linestring or ring) such that traversal is performed in steps of n. 40 </p> 41<h6> 42<a name="geometry.reference.adapted.boost_range.strided.h1"></a> 43 <span class="phrase"><a name="geometry.reference.adapted.boost_range.strided.model_of"></a></span><a class="link" href="strided.html#geometry.reference.adapted.boost_range.strided.model_of">Model 44 of</a> 45 </h6> 46<p> 47 The Boost.Range strided range adaptor takes over the model of the original 48 geometry, which might be: 49 </p> 50<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 51<li class="listitem"> 52 a linestring 53 </li> 54<li class="listitem"> 55 a ring 56 </li> 57<li class="listitem"> 58 a multi_point 59 </li> 60<li class="listitem"> 61 a multi_linestring 62 </li> 63<li class="listitem"> 64 a multi_polygon 65 </li> 66</ul></div> 67<h6> 68<a name="geometry.reference.adapted.boost_range.strided.h2"></a> 69 <span class="phrase"><a name="geometry.reference.adapted.boost_range.strided.header"></a></span><a class="link" href="strided.html#geometry.reference.adapted.boost_range.strided.header">Header</a> 70 </h6> 71<p> 72 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_range</span><span class="special">/</span><span class="identifier">strided</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 73 </p> 74<p> 75 The standard header <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span></code> 76 does not include this header. 77 </p> 78<h6> 79<a name="geometry.reference.adapted.boost_range.strided.h3"></a> 80 <span class="phrase"><a name="geometry.reference.adapted.boost_range.strided.example"></a></span><a class="link" href="strided.html#geometry.reference.adapted.boost_range.strided.example">Example</a> 81 </h6> 82<p> 83 Shows how to use a Boost.Geometry ring, strided by Boost.Range adaptor 84 </p> 85<p> 86</p> 87<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 88 89<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 90<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 91<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">ring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 92<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_range</span><span class="special">/</span><span class="identifier">strided</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 93 94<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">assign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <a class="co" name="geometry.reference.adapted.boost_range.strided.c0" href="strided.html#geometry.reference.adapted.boost_range.strided.c1"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> 95 96 97<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 98<span class="special">{</span> 99 <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">assign</span><span class="special">;</span> 100 <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">strided</span><span class="special">;</span> 101 102 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">d2</span><span class="special">::</span><span class="identifier">point_xy</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="identifier">xy</span><span class="special">;</span> 103 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">ring</span><span class="special"><</span><span class="identifier">xy</span><span class="special">></span> <span class="identifier">ring</span><span class="special">;</span> 104 <span class="identifier">ring</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span> 105 <span class="identifier">ring</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span> 106 <span class="identifier">ring</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span> 107 <span class="identifier">ring</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span> 108 <span class="identifier">ring</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span> 109 <span class="identifier">ring</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span> 110 111 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">correct</span><span class="special">(</span><span class="identifier">ring</span><span class="special">);</span> 112 113 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> 114 <span class="special"><<</span> <span class="string">"Normal : "</span> <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">ring</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> 115 <span class="special"><<</span> <span class="string">"Strided: "</span> <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">ring</span> <span class="special">|</span> <span class="identifier">strided</span><span class="special">(</span><span class="number">2</span><span class="special">))</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 116 117 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 118<span class="special">}</span> 119</pre> 120<p> 121 </p> 122<div class="calloutlist"><table border="0" summary="Callout list"><tr> 123<td width="5%" valign="top" align="left"><p><a name="geometry.reference.adapted.boost_range.strided.c1"></a><a href="#geometry.reference.adapted.boost_range.strided.c0"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> 124<td valign="top" align="left"><p> 125 At the end to avoid conflicts with Boost.QVM 126 </p></td> 127</tr></table></div> 128<p> 129 Output: 130 </p> 131<pre class="programlisting">Normal : ((0, 0), (0, 1), (0, 2), (1, 2), (2, 2), (2, 0), (0, 0)) 132Strided: ((0, 0), (0, 2), (2, 2), (0, 0)) 133</pre> 134</div> 135<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 136<td align="left"></td> 137<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 138 Wulkiewicz, Oracle and/or its affiliates<p> 139 Distributed under the Boost Software License, Version 1.0. (See accompanying 140 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 141 </p> 142</div></td> 143</tr></table> 144<hr> 145<div class="spirit-nav"> 146<a accesskey="p" href="sliced.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_range.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../register.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 147</div> 148</body> 149</html> 150