]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/polygon/doc/gtl_polygon_set_usage.htm
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / polygon / doc / gtl_polygon_set_usage.htm
1 <html>
2
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
5 <title>Polygon Set 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>&nbsp; &nbsp;
22 //lets declare ourselves a polygon set<br>&nbsp; &nbsp;
23 using namespace gtl; //because of operators<br>&nbsp; &nbsp;
24 typedef std::vector&lt;polygon_data&lt;int&gt; &gt; PolygonSet;<br>&nbsp; &nbsp;
25 PolygonSet ps;<br>&nbsp; &nbsp;
26 <br>&nbsp; &nbsp;
27 //lets put some data in<br>&nbsp; &nbsp;
28 ps += rectangle_data&lt;int&gt;(0, 0, 10, 10);<br>&nbsp; &nbsp;
29 <br>&nbsp; &nbsp;
30 //now lets do something interesting<br>&nbsp; &nbsp;
31 PolygonSet ps2;<br>&nbsp; &nbsp;
32 ps2 += rectangle_data&lt;int&gt;(5, 5, 15, 15);<br>&nbsp; &nbsp;
33 PolygonSet ps3;<br>&nbsp; &nbsp;
34 assign(ps3, ps * ps2); //woah, I just felt the room flex around me<br>&nbsp; &nbsp;
35 PolygonSet ps4;<br>&nbsp; &nbsp;
36 ps4 += ps + ps2;<br>&nbsp; &nbsp;
37 <br>&nbsp; &nbsp;
38 //assert that area of result is equal to sum of areas<br>&nbsp; &nbsp;
39 //of input geometry minus the area of overlap between inputs<br>&nbsp; &nbsp;
40 assert(area(ps4) == area(ps) + area(ps2) - area(ps3));<br>&nbsp; &nbsp;
41 <br>&nbsp; &nbsp;
42 //I don't even see the code anymore, all<br>&nbsp; &nbsp;
43 //I see is bounding box...interval...triangle<br>&nbsp; &nbsp;
44 <br>&nbsp; &nbsp;
45 //lets try that again in slow motion shall we?<br>&nbsp;&nbsp;&nbsp;
46 assert(equivalence((ps + ps2) - (ps * ps2), ps ^ ps2));<br>
47 <br>
48 &nbsp;&nbsp;&nbsp; //hmm, subtracting the intersection from the union<br>
49 &nbsp;&nbsp;&nbsp; //is equivalent to the xor, all this in one line of code,<br>
50 &nbsp;&nbsp;&nbsp; //now we're programming in bullet time<br>
51 &nbsp;&nbsp;&nbsp; //(by the way, xor is implemented as one pass, not
52 composition)&nbsp; <br>&nbsp; &nbsp;
53 <br>&nbsp; &nbsp;
54 //just for fun<br>&nbsp; &nbsp;
55 rectangle_data&lt;int&gt; rect;<br>&nbsp; &nbsp;
56 assert(extents(rect, ps ^ ps2));<br>&nbsp; &nbsp;
57 assert(area(rect) == 225);<br>&nbsp; &nbsp;
58 assert(area(rect ^ (ps ^ ps2)) == area(rect) - area(ps ^ ps2)); <br>&nbsp; &nbsp;
59 return 0;<br>}<br>&nbsp; &nbsp;
60 <br>//Now you know how to use the polygon set concept with library polygons<br>&nbsp; &nbsp;
61 &nbsp;</font></p>
62
63
64 <table class="docinfo" rules="none" frame="void" id="table1">
65 <colgroup>
66 <col class="docinfo-name"><col class="docinfo-content">
67 </colgroup>
68 <tbody vAlign="top">
69 <tr>
70 <th class="docinfo-name">Copyright:</th>
71 <td>Copyright © Intel Corporation 2008-2010.</td>
72 </tr>
73 <tr class="field">
74 <th class="docinfo-name">License:</th>
75 <td class="field-body">Distributed under the Boost Software License,
76 Version 1.0. (See accompanying file <tt class="literal">
77 <span class="pre">LICENSE_1_0.txt</span></tt> or copy at
78 <a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
79 http://www.boost.org/LICENSE_1_0.txt</a>)</td>
80 </tr>
81 </table>
82
83 </body>
84
85 </html>