]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
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>
11Copyright 2008 Intel Corporation<br>
12<br>
13Use, modification and distribution are subject to the Boost Software License,<br>
14Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at<br>
15http://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>
19namespace gtl = boost::polygon;<br>
20using namespace boost::polygon::operators;<br><br>
21int main() {<br>&nbsp; &nbsp;
22//lets declare ourselves a polygon set<br>&nbsp; &nbsp;
23using namespace gtl; //because of operators<br>&nbsp; &nbsp;
24typedef std::vector&lt;polygon_data&lt;int&gt; &gt; PolygonSet;<br>&nbsp; &nbsp;
25PolygonSet ps;<br>&nbsp; &nbsp;
26<br>&nbsp; &nbsp;
27//lets put some data in<br>&nbsp; &nbsp;
28ps += 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;
31PolygonSet ps2;<br>&nbsp; &nbsp;
32ps2 += rectangle_data&lt;int&gt;(5, 5, 15, 15);<br>&nbsp; &nbsp;
33PolygonSet ps3;<br>&nbsp; &nbsp;
34assign(ps3, ps * ps2); //woah, I just felt the room flex around me<br>&nbsp; &nbsp;
35PolygonSet ps4;<br>&nbsp; &nbsp;
36ps4 += 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;
40assert(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;
46assert(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
52composition)&nbsp; <br>&nbsp; &nbsp;
53<br>&nbsp; &nbsp;
54//just for fun<br>&nbsp; &nbsp;
55rectangle_data&lt;int&gt; rect;<br>&nbsp; &nbsp;
56assert(extents(rect, ps ^ ps2));<br>&nbsp; &nbsp;
57assert(area(rect) == 225);<br>&nbsp; &nbsp;
58assert(area(rect ^ (ps ^ ps2)) == area(rect) - area(ps ^ ps2)); <br>&nbsp; &nbsp;
59return 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