• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>make (2 coordinate values)</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="../make.html" title="make">
9<link rel="prev" href="../make.html" title="make">
10<link rel="next" href="make_3_3_coordinate_values.html" title="make (3 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="../make.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../make.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="make_3_3_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.make.make_2_2_coordinate_values"></a><a class="link" href="make_2_2_coordinate_values.html" title="make (2 coordinate values)">make
28          (2 coordinate values)</a>
29</h5></div></div></div>
30<p>
31            <a class="indexterm" name="idm45635692362544"></a>
32Construct a geometry.
33          </p>
34<h6>
35<a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.h0"></a>
36            <span class="phrase"><a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.synopsis"></a></span><a class="link" href="make_2_2_coordinate_values.html#geometry.reference.algorithms.make.make_2_2_coordinate_values.synopsis">Synopsis</a>
37          </h6>
38<p>
39</p>
40<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Type</span><span class="special">&gt;</span>
41<span class="identifier">Geometry</span> <span class="identifier">make</span><span class="special">(</span><span class="identifier">Type</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">c1</span><span class="special">,</span> <span class="identifier">Type</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">c2</span><span class="special">)</span></pre>
42<p>
43          </p>
44<h6>
45<a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.h1"></a>
46            <span class="phrase"><a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.parameters"></a></span><a class="link" href="make_2_2_coordinate_values.html#geometry.reference.algorithms.make.make_2_2_coordinate_values.parameters">Parameters</a>
47          </h6>
48<div class="informaltable"><table class="table">
49<colgroup>
50<col>
51<col>
52<col>
53<col>
54</colgroup>
55<thead><tr>
56<th>
57                    <p>
58                      Type
59                    </p>
60                  </th>
61<th>
62                    <p>
63                      Concept
64                    </p>
65                  </th>
66<th>
67                    <p>
68                      Name
69                    </p>
70                  </th>
71<th>
72                    <p>
73                      Description
74                    </p>
75                  </th>
76</tr></thead>
77<tbody>
78<tr>
79<td>
80                    <p>
81                      Geometry
82                    </p>
83                  </td>
84<td>
85                    <p>
86                      Any type fulfilling a Geometry Concept
87                    </p>
88                  </td>
89<td>
90                    <p>
91                      -
92                    </p>
93                  </td>
94<td>
95                    <p>
96                      Must be specified
97                    </p>
98                  </td>
99</tr>
100<tr>
101<td>
102                    <p>
103                      Type const &amp;
104                    </p>
105                  </td>
106<td>
107                    <p>
108                      numerical type (int, double, ttmath, ...) to specify the coordinates
109                    </p>
110                  </td>
111<td>
112                    <p>
113                      c1
114                    </p>
115                  </td>
116<td>
117                    <p>
118                      First coordinate (usually x-coordinate)
119                    </p>
120                  </td>
121</tr>
122<tr>
123<td>
124                    <p>
125                      Type const &amp;
126                    </p>
127                  </td>
128<td>
129                    <p>
130                      numerical type (int, double, ttmath, ...) to specify the coordinates
131                    </p>
132                  </td>
133<td>
134                    <p>
135                      c2
136                    </p>
137                  </td>
138<td>
139                    <p>
140                      Second coordinate (usually y-coordinate)
141                    </p>
142                  </td>
143</tr>
144</tbody>
145</table></div>
146<h6>
147<a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.h2"></a>
148            <span class="phrase"><a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.returns"></a></span><a class="link" href="make_2_2_coordinate_values.html#geometry.reference.algorithms.make.make_2_2_coordinate_values.returns">Returns</a>
149          </h6>
150<p>
151            The constructed geometry, here: a 2D point
152          </p>
153<h6>
154<a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.h3"></a>
155            <span class="phrase"><a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.header"></a></span><a class="link" href="make_2_2_coordinate_values.html#geometry.reference.algorithms.make.make_2_2_coordinate_values.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">algorithms</span><span class="special">/</span><span class="identifier">make</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
168          </p>
169<h6>
170<a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.h4"></a>
171            <span class="phrase"><a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.example"></a></span><a class="link" href="make_2_2_coordinate_values.html#geometry.reference.algorithms.make.make_2_2_coordinate_values.example">Example</a>
172          </h6>
173<p>
174            Shows the usage of make as a generic constructor for different point
175            types
176          </p>
177<p>
178</p>
179<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
180
181<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>
182<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>
183<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="keyword">register</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
184<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">adapted</span><span class="special">/</span><span class="identifier">boost_tuple</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
185<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">adapted</span><span class="special">/</span><span class="identifier">boost_polygon</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
186
187<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>
188
189<span class="keyword">struct</span> <span class="identifier">mypoint</span> <span class="special">{</span> <span class="keyword">float</span> <span class="identifier">_x</span><span class="special">,</span> <span class="identifier">_y</span><span class="special">;</span> <span class="special">};</span>
190
191<span class="identifier">BOOST_GEOMETRY_REGISTER_POINT_2D</span><span class="special">(</span><span class="identifier">mypoint</span><span class="special">,</span> <span class="keyword">float</span><span class="special">,</span> <span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">,</span> <span class="identifier">_x</span><span class="special">,</span> <span class="identifier">_y</span><span class="special">)</span>
192
193<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Point</span><span class="special">&gt;</span>
194<span class="keyword">void</span> <span class="identifier">construct_and_display</span><span class="special">()</span>
195<span class="special">{</span>
196    <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">make</span><span class="special">;</span>
197    <span class="keyword">using</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>
198
199    <span class="identifier">Point</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">make</span><span class="special">&lt;</span><span class="identifier">Point</span><span class="special">&gt;(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span>
200
201    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"x="</span> <span class="special">&lt;&lt;</span> <span class="identifier">get</span><span class="special">&lt;</span><span class="number">0</span><span class="special">&gt;(</span><span class="identifier">p</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">" y="</span> <span class="special">&lt;&lt;</span> <span class="identifier">get</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;(</span><span class="identifier">p</span><span class="special">)</span>
202        <span class="special">&lt;&lt;</span> <span class="string">" ("</span> <span class="special">&lt;&lt;</span> <span class="keyword">typeid</span><span class="special">(</span><span class="identifier">Point</span><span class="special">).</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">")"</span>
203        <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
204<span class="special">}</span>
205
206<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
207<span class="special">{</span>
208    <span class="identifier">construct_and_display</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">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="special">&gt;();</span>
209    <span class="identifier">construct_and_display</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">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">int</span><span class="special">&gt;</span> <span class="special">&gt;();</span>
210    <span class="identifier">construct_and_display</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tuple</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="special">&gt;();</span>
211    <span class="identifier">construct_and_display</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">point_data</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="special">&gt;();</span>
212    <span class="identifier">construct_and_display</span><span class="special">&lt;</span><span class="identifier">mypoint</span><span class="special">&gt;();</span>
213    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
214<span class="special">}</span>
215</pre>
216<p>
217          </p>
218<p>
219            Output (compiled using gcc):
220          </p>
221<pre class="programlisting">x=1 y=2 (N5boost8geometry5model2d28point_xyIdNS0_2cs9cartesianEEE)
222x=1 y=2 (N5boost8geometry5model2d28point_xyIiNS0_2cs9cartesianEEE)
223x=1 y=2 (N5boost6tuples5tupleIddNS0_9null_typeES2_S2_S2_S2_S2_S2_S2_EE)
224x=1 y=2 (N5boost7polygon10point_dataIiEE)
225x=1 y=2 (7mypoint)
226</pre>
227<h6>
228<a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.h5"></a>
229            <span class="phrase"><a name="geometry.reference.algorithms.make.make_2_2_coordinate_values.see_also"></a></span><a class="link" href="make_2_2_coordinate_values.html#geometry.reference.algorithms.make.make_2_2_coordinate_values.see_also">See
230            also</a>
231          </h6>
232<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
233                <a class="link" href="../assign/assign_values_3_2_coordinate_values.html" title="assign_values (2 coordinate values)">assign</a>
234              </li></ul></div>
235</div>
236<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
237<td align="left"></td>
238<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
239      Wulkiewicz, Oracle and/or its affiliates<p>
240        Distributed under the Boost Software License, Version 1.0. (See accompanying
241        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>)
242      </p>
243</div></td>
244</tr></table>
245<hr>
246<div class="spirit-nav">
247<a accesskey="p" href="../make.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../make.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="make_3_3_coordinate_values.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
248</div>
249</body>
250</html>
251