1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>assign_points</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="../assign.html" title="assign"> 9<link rel="prev" href="assign_inverse.html" title="assign_inverse"> 10<link rel="next" href="assign_values_3_2_coordinate_values.html" title="assign_values (2 coordinate values)"> 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="assign_inverse.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../assign.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="assign_values_3_2_coordinate_values.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.algorithms.assign.assign_points"></a><a class="link" href="assign_points.html" title="assign_points">assign_points</a> 28</h5></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635707367216"></a> 31Assign a range of points to a linestring, ring or polygon. 32 </p> 33<h6> 34<a name="geometry.reference.algorithms.assign.assign_points.h0"></a> 35 <span class="phrase"><a name="geometry.reference.algorithms.assign.assign_points.synopsis"></a></span><a class="link" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.synopsis">Synopsis</a> 36 </h6> 37<p> 38</p> 39<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Range</span><span class="special">></span> 40<span class="keyword">void</span> <span class="identifier">assign_points</span><span class="special">(</span><span class="identifier">Geometry</span> <span class="special">&</span> <span class="identifier">geometry</span><span class="special">,</span> <span class="identifier">Range</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">range</span><span class="special">)</span></pre> 41<p> 42 </p> 43<h6> 44<a name="geometry.reference.algorithms.assign.assign_points.h1"></a> 45 <span class="phrase"><a name="geometry.reference.algorithms.assign.assign_points.parameters"></a></span><a class="link" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.parameters">Parameters</a> 46 </h6> 47<div class="informaltable"><table class="table"> 48<colgroup> 49<col> 50<col> 51<col> 52<col> 53</colgroup> 54<thead><tr> 55<th> 56 <p> 57 Type 58 </p> 59 </th> 60<th> 61 <p> 62 Concept 63 </p> 64 </th> 65<th> 66 <p> 67 Name 68 </p> 69 </th> 70<th> 71 <p> 72 Description 73 </p> 74 </th> 75</tr></thead> 76<tbody> 77<tr> 78<td> 79 <p> 80 Geometry & 81 </p> 82 </td> 83<td> 84 <p> 85 Any type fulfilling a Geometry Concept 86 </p> 87 </td> 88<td> 89 <p> 90 geometry 91 </p> 92 </td> 93<td> 94 <p> 95 A model of the specified concept 96 </p> 97 </td> 98</tr> 99<tr> 100<td> 101 <p> 102 Range const & 103 </p> 104 </td> 105<td> 106 <p> 107 Any type fulfilling a Range Concept where it range_value type 108 fulfills the Point Concept 109 </p> 110 </td> 111<td> 112 <p> 113 range 114 </p> 115 </td> 116<td> 117 <p> 118 A range containg points fulfilling range and point concepts 119 </p> 120 </td> 121</tr> 122</tbody> 123</table></div> 124<h6> 125<a name="geometry.reference.algorithms.assign.assign_points.h2"></a> 126 <span class="phrase"><a name="geometry.reference.algorithms.assign.assign_points.header"></a></span><a class="link" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.header">Header</a> 127 </h6> 128<p> 129 Either 130 </p> 131<p> 132 <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">hpp</span><span class="special">></span></code> 133 </p> 134<p> 135 Or 136 </p> 137<p> 138 <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">algorithms</span><span class="special">/</span><span class="identifier">assign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 139 </p> 140<h6> 141<a name="geometry.reference.algorithms.assign.assign_points.h3"></a> 142 <span class="phrase"><a name="geometry.reference.algorithms.assign.assign_points.notes"></a></span><a class="link" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.notes">Notes</a> 143 </h6> 144<div class="note"><table border="0" summary="Note"> 145<tr> 146<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td> 147<th align="left">Note</th> 148</tr> 149<tr><td align="left" valign="top"><p> 150 Assign automatically clears the geometry before assigning (use append 151 if you don't want that) 152 </p></td></tr> 153</table></div> 154<h6> 155<a name="geometry.reference.algorithms.assign.assign_points.h4"></a> 156 <span class="phrase"><a name="geometry.reference.algorithms.assign.assign_points.example"></a></span><a class="link" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.example">Example</a> 157 </h6> 158<p> 159 Shows usage of Boost.Geometry's assign, Boost.Assign, and Boost.Range 160 to assign ranges of a linestring 161 </p> 162<p> 163</p> 164<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 165 166<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> 167<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> 168<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_tuple</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 169 170<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> 171<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">filtered</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 172 173<span class="identifier">BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS</span><span class="special">(</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">)</span> 174 175<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span> 176<span class="keyword">struct</span> <span class="identifier">x_between</span> 177<span class="special">{</span> 178 <span class="identifier">x_between</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">b</span><span class="special">)</span> 179 <span class="special">:</span> <span class="identifier">fa</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span> <span class="identifier">fb</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> 180 <span class="special">{}</span> 181 182 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">P</span><span class="special">></span> 183 <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">P</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">p</span><span class="special">)</span> <span class="keyword">const</span> 184 <span class="special">{</span> 185 <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">get</span><span class="special"><</span><span class="number">0</span><span class="special">>(</span><span class="identifier">p</span><span class="special">)</span> <span class="special">>=</span> <span class="identifier">fa</span> 186 <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">get</span><span class="special"><</span><span class="number">0</span><span class="special">>(</span><span class="identifier">p</span><span class="special">)</span> <span class="special"><=</span> <span class="identifier">fb</span><span class="special">;</span> 187 <span class="special">}</span> 188<span class="keyword">private</span> <span class="special">:</span> 189 <span class="identifier">T</span> <span class="identifier">fa</span><span class="special">,</span> <span class="identifier">fb</span><span class="special">;</span> 190<span class="special">};</span> 191 192 193<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 194<span class="special">{</span> 195 <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> 196 197 <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">linestring</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tuple</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">ls</span><span class="special">;</span> 198 199 <span class="identifier">ls</span> <span class="identifier">line1</span><span class="special">,</span> <span class="identifier">line2</span><span class="special">,</span> <span class="identifier">line3</span><span class="special">;</span> 200 201 <span class="identifier">line1</span> <span class="special">=</span> <span class="identifier">tuple_list_of</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">)(</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">)(</span><span class="number">4</span><span class="special">,</span> <span class="number">0</span><span class="special">)(</span><span class="number">6</span><span class="special">,</span> <span class="number">3</span><span class="special">)(</span><span class="number">8</span><span class="special">,</span> <span class="number">0</span><span class="special">)(</span><span class="number">10</span><span class="special">,</span> <span class="number">3</span><span class="special">)(</span><span class="number">12</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span> <a class="co" name="geometry.reference.algorithms.assign.assign_points.c0" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.c1"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> 202 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">assign_points</span><span class="special">(</span><span class="identifier">line2</span><span class="special">,</span> <span class="identifier">tuple_list_of</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">)(</span><span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">)(</span><span class="number">4</span><span class="special">,</span> <span class="number">0</span><span class="special">)(</span><span class="number">6</span><span class="special">,</span> <span class="number">2</span><span class="special">)(</span><span class="number">8</span><span class="special">,</span> <span class="number">0</span><span class="special">));</span> <a class="co" name="geometry.reference.algorithms.assign.assign_points.c2" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.c3"><img src="../../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> 203 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">assign_points</span><span class="special">(</span><span class="identifier">line3</span><span class="special">,</span> <span class="identifier">line1</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">filtered</span><span class="special">(</span><span class="identifier">x_between</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="number">4</span><span class="special">,</span> <span class="number">8</span><span class="special">)));</span> <a class="co" name="geometry.reference.algorithms.assign.assign_points.c4" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.c5"><img src="../../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> 204 205 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"line 1: "</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">line1</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> 206 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"line 2: "</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">line2</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> 207 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"line 3: "</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">line3</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> 208 209 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 210<span class="special">}</span> 211</pre> 212<p> 213 </p> 214<div class="calloutlist"><table border="0" summary="Callout list"> 215<tr> 216<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.assign.assign_points.c1"></a><a href="#geometry.reference.algorithms.assign.assign_points.c0"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> 217<td valign="top" align="left"><p> 218 tuple_list_of is part of Boost.Assign and can be used for Boost.Geometry 219 if points are tuples 220 </p></td> 221</tr> 222<tr> 223<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.assign.assign_points.c3"></a><a href="#geometry.reference.algorithms.assign.assign_points.c2"><img src="../../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> 224<td valign="top" align="left"><p> 225 tuple_list_of delivers a range and can therefore be used in boost::geometry::assign 226 </p></td> 227</tr> 228<tr> 229<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.assign.assign_points.c5"></a><a href="#geometry.reference.algorithms.assign.assign_points.c4"><img src="../../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td> 230<td valign="top" align="left"><p> 231 Boost.Range adaptors can also be used in boost::geometry::assign 232 </p></td> 233</tr> 234</table></div> 235<p> 236 Output: 237 </p> 238<pre class="programlisting">line 1: ((0, 0), (2, 3), (4, 0), (6, 3), (8, 0), (10, 3), (12, 0)) 239line 2: ((0, 0), (2, 2), (4, 0), (6, 2), (8, 0)) 240line 3: ((4, 0), (6, 3), (8, 0)) 241</pre> 242<h6> 243<a name="geometry.reference.algorithms.assign.assign_points.h5"></a> 244 <span class="phrase"><a name="geometry.reference.algorithms.assign.assign_points.see_also"></a></span><a class="link" href="assign_points.html#geometry.reference.algorithms.assign.assign_points.see_also">See 245 also</a> 246 </h6> 247<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 248 <a class="link" href="../append.html" title="append">append</a> 249 </li></ul></div> 250</div> 251<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 252<td align="left"></td> 253<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 254 Wulkiewicz, Oracle and/or its affiliates<p> 255 Distributed under the Boost Software License, Version 1.0. (See accompanying 256 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>) 257 </p> 258</div></td> 259</tr></table> 260<hr> 261<div class="spirit-nav"> 262<a accesskey="p" href="assign_inverse.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../assign.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="assign_values_3_2_coordinate_values.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 263</div> 264</body> 265</html> 266