1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Boost.Range sliced</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="reversed.html" title="Boost.Range reversed"> 10<link rel="next" href="strided.html" title="Boost.Range strided"> 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="reversed.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="strided.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.sliced"></a><a class="link" href="sliced.html" title="Boost.Range sliced">Boost.Range 28 sliced</a> 29</h5></div></div></div> 30<p> 31 Boost.Range sliced range adaptor is adapted to Boost.Geometry 32 </p> 33<h6> 34<a name="geometry.reference.adapted.boost_range.sliced.h0"></a> 35 <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.description"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.description">Description</a> 36 </h6> 37<p> 38 Boost.Range sliced range adaptor creates a slice of a range (usually 39 a linestring) 40 </p> 41<h6> 42<a name="geometry.reference.adapted.boost_range.sliced.h1"></a> 43 <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.model_of"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.model_of">Model 44 of</a> 45 </h6> 46<p> 47 The Boost.Range sliced 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.sliced.h2"></a> 69 <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.header"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.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">sliced</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.sliced.h3"></a> 80 <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.example"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.example">Example</a> 81 </h6> 82<p> 83 Shows how to use a Boost.Geometry linestring, sliced 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">linestring</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">point_xy</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">sliced</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.sliced.c0" href="sliced.html#geometry.reference.adapted.boost_range.sliced.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 101 <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> 102 <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">linestring</span><span class="special"><</span><span class="identifier">xy</span><span class="special">></span> <span class="identifier">line</span><span class="special">;</span> 103 <span class="identifier">line</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> 104 <span class="identifier">line</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">1</span><span class="special">);</span> 105 <span class="identifier">line</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> 106 <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span> 107 <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="number">4</span><span class="special">);</span> 108 109 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> 110 <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">line</span> <span class="special">|</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">sliced</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">3</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> 111 112 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 113<span class="special">}</span> 114</pre> 115<p> 116 </p> 117<div class="calloutlist"><table border="0" summary="Callout list"><tr> 118<td width="5%" valign="top" align="left"><p><a name="geometry.reference.adapted.boost_range.sliced.c1"></a><a href="#geometry.reference.adapted.boost_range.sliced.c0"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> 119<td valign="top" align="left"><p> 120 At the end to avoid conflicts with Boost.QVM 121 </p></td> 122</tr></table></div> 123<p> 124 Output: 125 </p> 126<pre class="programlisting">((1, 1), (2, 2)) 127</pre> 128</div> 129<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 130<td align="left"></td> 131<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 132 Wulkiewicz, Oracle and/or its affiliates<p> 133 Distributed under the Boost Software License, Version 1.0. (See accompanying 134 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>) 135 </p> 136</div></td> 137</tr></table> 138<hr> 139<div class="spirit-nav"> 140<a accesskey="p" href="reversed.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="strided.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 141</div> 142</body> 143</html> 144