]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/polygon/doc/gtl_polygon_usage.htm
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / polygon / doc / gtl_polygon_usage.htm
1 <html>
2
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
5 <title>Polygon Usage</title>
6 </head>
7
8 <body>
9
10 <p><font face="Courier New">/*<br>
11 Copyright 2008 Intel Corporation<br>
12 <br>
13 Use, modification and distribution are subject to the Boost Software License,<br>
14 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at<br>
15 http://www.boost.org/LICENSE_1_0.txt).<br>
16 */<br>
17 #include &lt;boost/polygon/polygon.hpp&gt;<br>
18 #include &lt;cassert&gt;<br>
19 namespace gtl = boost::polygon;<br>
20 using namespace boost::polygon::operators;<br><br>
21 int main() {<br>
22 &nbsp;&nbsp;&nbsp; //lets construct a 10x10 rectangle shaped polygon<br>
23 &nbsp;&nbsp;&nbsp; typedef gtl::polygon_data&lt;int&gt; Polygon;<br>
24 &nbsp;&nbsp;&nbsp; typedef gtl::polygon_traits&lt;Polygon&gt;::point_type Point;<br>
25 &nbsp;&nbsp;&nbsp; Point pts[] = {gtl::construct&lt;Point&gt;(0, 0),<br>
26 &nbsp;&nbsp;&nbsp; gtl::construct&lt;Point&gt;(10, 0),<br>
27 &nbsp;&nbsp;&nbsp; gtl::construct&lt;Point&gt;(10, 10),<br>
28 &nbsp;&nbsp;&nbsp; gtl::construct&lt;Point&gt;(0, 10) };<br>
29 &nbsp;&nbsp;&nbsp; Polygon poly;<br>
30 &nbsp;&nbsp;&nbsp; gtl::set_points(poly, pts, pts+4);<br>
31 <br>
32 &nbsp;&nbsp;&nbsp; //now lets see what we can do with this polygon<br>
33 &nbsp;&nbsp;&nbsp; assert(gtl::area(poly) == 100.0f);<br>
34 &nbsp;&nbsp;&nbsp; assert(gtl::contains(poly, gtl::construct&lt;Point&gt;(5, 5)));<br>
35 &nbsp;&nbsp;&nbsp; assert(!gtl::contains(poly, gtl::construct&lt;Point&gt;(15, 5)));<br>
36 &nbsp;&nbsp;&nbsp; gtl::rectangle_data&lt;int&gt; rect;<br>
37 &nbsp;&nbsp;&nbsp; assert(gtl::extents(rect, poly)); //get bounding box of poly<br>
38 &nbsp;&nbsp;&nbsp; assert(gtl::equivalence(rect, poly)); //hey, that's slick<br>
39 &nbsp;&nbsp;&nbsp; assert(gtl::winding(poly) == gtl::COUNTERCLOCKWISE);<br>
40 &nbsp;&nbsp;&nbsp; assert(gtl::perimeter(poly) == 40.0f);<br>
41 <br>
42 &nbsp;&nbsp;&nbsp; //add 5 to all coords of poly<br>
43 &nbsp;&nbsp;&nbsp; gtl::convolve(poly, gtl::construct&lt;Point&gt;(5, 5));<br>
44 &nbsp;&nbsp;&nbsp; //multiply all coords of poly by 2<br>
45 &nbsp;&nbsp;&nbsp; gtl::scale_up(poly, 2);<br>
46 &nbsp;&nbsp;&nbsp; gtl::set_points(rect, gtl::point_data&lt;int&gt;(10, 10),<br>
47 &nbsp;&nbsp;&nbsp; gtl::point_data&lt;int&gt;(30, 30));<br>
48 &nbsp;&nbsp;&nbsp; assert(gtl::equivalence(poly, rect));<br>
49 &nbsp;&nbsp;&nbsp; return 0;<br>
50 }<br>
51 //Now you know how to use the built in polygon data type<br>
52 &nbsp;</font></p>
53
54
55 <table class="docinfo" rules="none" frame="void" id="table1">
56 <colgroup>
57 <col class="docinfo-name"><col class="docinfo-content">
58 </colgroup>
59 <tbody vAlign="top">
60 <tr>
61 <th class="docinfo-name">Copyright:</th>
62 <td>Copyright © Intel Corporation 2008-2010.</td>
63 </tr>
64 <tr class="field">
65 <th class="docinfo-name">License:</th>
66 <td class="field-body">Distributed under the Boost Software License,
67 Version 1.0. (See accompanying file <tt class="literal">
68 <span class="pre">LICENSE_1_0.txt</span></tt> or copy at
69 <a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
70 http://www.boost.org/LICENSE_1_0.txt</a>)</td>
71 </tr>
72 </table>
73
74 </body>
75
76 </html>