• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Boost.Tuple</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="../adapted.html" title="Adapted models">
9<link rel="prev" href="boost_fusion.html" title="Boost.Fusion">
10<link rel="next" href="boost_polygon.html" title="Boost.Polygon">
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="boost_fusion.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../adapted.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="boost_polygon.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="geometry.reference.adapted.boost_tuple"></a><a class="link" href="boost_tuple.html" title="Boost.Tuple">Boost.Tuple</a>
28</h4></div></div></div>
29<p>
30          Boost.Tuple tuples with arithmetic elements can be used as points within
31          Boost.Geometry
32        </p>
33<h6>
34<a name="geometry.reference.adapted.boost_tuple.h0"></a>
35          <span class="phrase"><a name="geometry.reference.adapted.boost_tuple.description"></a></span><a class="link" href="boost_tuple.html#geometry.reference.adapted.boost_tuple.description">Description</a>
36        </h6>
37<p>
38          Boost.Tuple fixed sized collections, such as boost::tuple&lt;double, double&gt;,
39          are (optionally) adapted to the Boost.Geometry point concept.
40        </p>
41<p>
42          Boost.Tuple pairs or triples might have mutually different types, such
43          as a boost::tuple&lt;float, double&gt;. Boost.Geometry reports the first
44          type as its <a class="link" href="../core/coordinate_type.html" title="coordinate_type">coordinate_type</a>.
45        </p>
46<p>
47          Boost.Geometry supports Boost.Tuple pairs, triples, quadruples, etc up
48          to tuples with 10 elements (though most algorithms do not support so many
49          dimensions).
50        </p>
51<p>
52          A tuple can be the point type used by the models linestring, polygon, segment,
53          box, and ring.
54        </p>
55<h6>
56<a name="geometry.reference.adapted.boost_tuple.h1"></a>
57          <span class="phrase"><a name="geometry.reference.adapted.boost_tuple.model_of"></a></span><a class="link" href="boost_tuple.html#geometry.reference.adapted.boost_tuple.model_of">Model
58          of</a>
59        </h6>
60<p>
61          <a class="link" href="../concepts/concept_point.html" title="Point Concept">Point Concept</a>
62        </p>
63<h6>
64<a name="geometry.reference.adapted.boost_tuple.h2"></a>
65          <span class="phrase"><a name="geometry.reference.adapted.boost_tuple.header"></a></span><a class="link" href="boost_tuple.html#geometry.reference.adapted.boost_tuple.header">Header</a>
66        </h6>
67<p>
68          <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">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></code>
69        </p>
70<p>
71          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>
72          does not include this header.
73        </p>
74<h6>
75<a name="geometry.reference.adapted.boost_tuple.h3"></a>
76          <span class="phrase"><a name="geometry.reference.adapted.boost_tuple.example"></a></span><a class="link" href="boost_tuple.html#geometry.reference.adapted.boost_tuple.example">Example</a>
77        </h6>
78<p>
79          Shows how to use Boost.Tuple points in Boost.Geometry
80        </p>
81<p>
82          Working with Boost.Tuples in Boost.Geometry is straightforward and shown
83          in various other examples as well.
84        </p>
85<p>
86</p>
87<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
88
89<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>
90<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">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
91<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>
92
93<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>
94
95<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
96<span class="special">{</span>
97    <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">polygon</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> <span class="identifier">poly</span><span class="special">;</span>
98    <span class="identifier">poly</span><span class="special">.</span><span class="identifier">outer</span><span class="special">().</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_tuple</span><span class="special">(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">));</span>
99    <span class="identifier">poly</span><span class="special">.</span><span class="identifier">outer</span><span class="special">().</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_tuple</span><span class="special">(</span><span class="number">6.0</span><span class="special">,</span> <span class="number">4.0</span><span class="special">));</span>
100    <span class="identifier">poly</span><span class="special">.</span><span class="identifier">outer</span><span class="special">().</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_tuple</span><span class="special">(</span><span class="number">5.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">));</span>
101    <span class="identifier">poly</span><span class="special">.</span><span class="identifier">outer</span><span class="special">().</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_tuple</span><span class="special">(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">));</span>
102
103    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Area: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">area</span><span class="special">(</span><span class="identifier">poly</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>
104    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Contains (1.5, 2.5): "</span>
105        <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span>
106        <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">within</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_tuple</span><span class="special">(</span><span class="number">1.5</span><span class="special">,</span> <span class="number">2.5</span><span class="special">),</span> <span class="identifier">poly</span><span class="special">)</span>
107        <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
108
109    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
110<span class="special">}</span>
111</pre>
112<p>
113        </p>
114<p>
115          Output:
116        </p>
117<pre class="programlisting">Area: 6.5
118Contains (1.5, 2.5): false
119</pre>
120</div>
121<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
122<td align="left"></td>
123<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
124      Wulkiewicz, Oracle and/or its affiliates<p>
125        Distributed under the Boost Software License, Version 1.0. (See accompanying
126        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>)
127      </p>
128</div></td>
129</tr></table>
130<hr>
131<div class="spirit-nav">
132<a accesskey="p" href="boost_fusion.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../adapted.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="boost_polygon.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
133</div>
134</body>
135</html>
136