1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>set (with index)</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="../set.html" title="set"> 9<link rel="prev" href="set_2.html" title="set"> 10<link rel="next" href="set_from_radian_2.html" title="set_from_radian"> 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="set_2.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../set.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="set_from_radian_2.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.access.set.set_2_with_index"></a><a class="link" href="set_2_with_index.html" title="set (with index)">set 28 (with index)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635712397392"></a> 32set coordinate value of a Box / Segment 33 </p> 34<h6> 35<a name="geometry.reference.access.set.set_2_with_index.h0"></a> 36 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.description"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.description">Description</a> 37 </h6> 38<p> 39 The free functions <span class="bold"><strong>get</strong></span> and <span class="bold"><strong>set</strong></span> are two of the most important functions of 40 Boost.Geometry, both within the library, as also for the library user. 41 With these two functions you normally get and set coordinate values from 42 and for a point, box, segment or sphere. 43 </p> 44<h6> 45<a name="geometry.reference.access.set.set_2_with_index.h1"></a> 46 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.synopsis"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.synopsis">Synopsis</a> 47 </h6> 48<p> 49</p> 50<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Index</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Dimension</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">></span> 51<span class="keyword">void</span> <span class="identifier">set</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="keyword">typename</span> <span class="identifier">coordinate_type</span><span class="special"><</span> <span class="identifier">Geometry</span> <span class="special">>::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">)</span></pre> 52<p> 53 </p> 54<h6> 55<a name="geometry.reference.access.set.set_2_with_index.h2"></a> 56 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.parameters"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.parameters">Parameters</a> 57 </h6> 58<div class="informaltable"><table class="table"> 59<colgroup> 60<col> 61<col> 62<col> 63<col> 64</colgroup> 65<thead><tr> 66<th> 67 <p> 68 Type 69 </p> 70 </th> 71<th> 72 <p> 73 Concept 74 </p> 75 </th> 76<th> 77 <p> 78 Name 79 </p> 80 </th> 81<th> 82 <p> 83 Description 84 </p> 85 </th> 86</tr></thead> 87<tbody> 88<tr> 89<td> 90 <p> 91 Index 92 </p> 93 </td> 94<td> 95 <p> 96 Index, this template parameter is required. For a Box: either 97 min_corner or max_corner. For a Segment: either 0 or 1 for 98 first or last point. 99 </p> 100 </td> 101<td> 102 <p> 103 - 104 </p> 105 </td> 106<td> 107 <p> 108 Must be specified 109 </p> 110 </td> 111</tr> 112<tr> 113<td> 114 <p> 115 Dimension 116 </p> 117 </td> 118<td> 119 <p> 120 Dimension, this template parameter is required. Should contain 121 [0 .. n-1] for an n-dimensional geometry 122 </p> 123 </td> 124<td> 125 <p> 126 - 127 </p> 128 </td> 129<td> 130 <p> 131 Must be specified 132 </p> 133 </td> 134</tr> 135<tr> 136<td> 137 <p> 138 Geometry & 139 </p> 140 </td> 141<td> 142 <p> 143 Any type fulfilling a Box Concept or a Segment Concept 144 </p> 145 </td> 146<td> 147 <p> 148 geometry 149 </p> 150 </td> 151<td> 152 <p> 153 A model of the specified concept 154 </p> 155 </td> 156</tr> 157<tr> 158<td> 159 <p> 160 typename coordinate_type< Geometry >::type const & 161 </p> 162 </td> 163<td> 164 </td> 165<td> 166 <p> 167 value 168 </p> 169 </td> 170<td> 171 <p> 172 The coordinate value to set 173 </p> 174 </td> 175</tr> 176</tbody> 177</table></div> 178<h6> 179<a name="geometry.reference.access.set.set_2_with_index.h3"></a> 180 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.header"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.header">Header</a> 181 </h6> 182<p> 183 Either 184 </p> 185<p> 186 <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> 187 </p> 188<p> 189 Or 190 </p> 191<p> 192 <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">core</span><span class="special">/</span><span class="identifier">access</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 193 </p> 194<h6> 195<a name="geometry.reference.access.set.set_2_with_index.h4"></a> 196 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.behavior"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.behavior">Behavior</a> 197 </h6> 198<div class="informaltable"><table class="table"> 199<colgroup> 200<col> 201<col> 202</colgroup> 203<thead><tr> 204<th> 205 <p> 206 Case 207 </p> 208 </th> 209<th> 210 <p> 211 Behavior 212 </p> 213 </th> 214</tr></thead> 215<tbody> 216<tr> 217<td> 218 <p> 219 Box 220 </p> 221 </td> 222<td> 223 <p> 224 Sets the coordinate of a box (use min_corner, max_corner to 225 specify which of the points to set) 226 </p> 227 </td> 228</tr> 229<tr> 230<td> 231 <p> 232 Segment 233 </p> 234 </td> 235<td> 236 <p> 237 Sets the coordinate of a segment (use 0, 1 to specify which 238 of the two points to set) 239 </p> 240 </td> 241</tr> 242</tbody> 243</table></div> 244<h6> 245<a name="geometry.reference.access.set.set_2_with_index.h5"></a> 246 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.complexity"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.complexity">Complexity</a> 247 </h6> 248<p> 249 Constant 250 </p> 251<h6> 252<a name="geometry.reference.access.set.set_2_with_index.h6"></a> 253 <span class="phrase"><a name="geometry.reference.access.set.set_2_with_index.example"></a></span><a class="link" href="set_2_with_index.html#geometry.reference.access.set.set_2_with_index.example">Example</a> 254 </h6> 255<p> 256 Set the coordinate of a box 257 </p> 258<p> 259</p> 260<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 261 262<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> 263<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> 264 265<span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span> 266 267<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 268<span class="special">{</span> 269 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">box</span><span class="special"><</span><span class="identifier">bg</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">double</span><span class="special">></span> <span class="special">></span> <span class="identifier">box</span><span class="special">;</span> 270 271 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">min_corner</span><span class="special">,</span> <span class="number">0</span><span class="special">>(</span><span class="identifier">box</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span> 272 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">min_corner</span><span class="special">,</span> <span class="number">1</span><span class="special">>(</span><span class="identifier">box</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span> 273 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">max_corner</span><span class="special">,</span> <span class="number">0</span><span class="special">>(</span><span class="identifier">box</span><span class="special">,</span> <span class="number">4</span><span class="special">);</span> 274 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">max_corner</span><span class="special">,</span> <span class="number">1</span><span class="special">>(</span><span class="identifier">box</span><span class="special">,</span> <span class="number">5</span><span class="special">);</span> 275 276 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Extent: "</span> <span class="special"><<</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">box</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> 277 278 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 279<span class="special">}</span> 280</pre> 281<p> 282 </p> 283<p> 284 Output: 285 </p> 286<pre class="programlisting">Extent: ((0, 2), (4, 5)) 287</pre> 288</div> 289<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 290<td align="left"></td> 291<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 292 Wulkiewicz, Oracle and/or its affiliates<p> 293 Distributed under the Boost Software License, Version 1.0. (See accompanying 294 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>) 295 </p> 296</div></td> 297</tr></table> 298<hr> 299<div class="spirit-nav"> 300<a accesskey="p" href="set_2.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../set.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="set_from_radian_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 301</div> 302</body> 303</html> 304