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