]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/polygon/doc/gtl_property_merge_usage.htm
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / polygon / doc / gtl_property_merge_usage.htm
1 <html>
2
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
5 <title>Property Merge 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>
21 <br>//just a little meta-programming to get things off on the right foot<br>
22 template &lt;typename T&gt;<br>
23 struct lookup_polygon_set_type { typedef gtl::polygon_set_data&lt;int&gt; type; };<br>
24 template &lt;typename T, typename T2&gt;<br>
25 struct lookup_polygon_set_type&lt;gtl::property_merge_90&lt;T, T2&gt; &gt; { <br>
26 &nbsp; typedef gtl::polygon_90_set_data&lt;int&gt; type; };<br>
27 <br>
28 //This function works with both the 90 and general versions<br>
29 //of property merge/map overlay algorithm<br>
30 template &lt;typename pm_type&gt;<br>
31 void test_pm() {<br>
32 &nbsp; std::vector&lt;gtl::rectangle_data&lt;int&gt; &gt; test_data;<br>
33 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(11, 10, 31, 30));<br>
34 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(1, 0, 21, 20));<br>
35 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(6, 15, 16, 25));<br>
36 <br>
37 &nbsp; pm_type pm;<br>
38 <br>
39 &nbsp; //insert our test geometry into the property merge algorithm<br>
40 &nbsp; for(unsigned int i = 0; i &lt; test_data.size(); ++i) {<br>
41 &nbsp;&nbsp;&nbsp; pm.insert(test_data[i], i); //notice I use the index as the
42 property value<br>
43 &nbsp; }<br>
44 <br>
45 &nbsp; typedef typename lookup_polygon_set_type&lt;pm_type&gt;::type polygon_set_type;<br>
46 &nbsp; typedef std::map&lt;std::set&lt;int&gt;, polygon_set_type&gt;
47 property_merge_result_type;<br>
48 <br>
49 &nbsp; std::set&lt;int&gt; key;<br>
50 <br>
51 &nbsp; //There are 8 different combinations of our input geometries<br>
52 &nbsp; //null combination is not interesting, so really 7<br>
53 <br>
54 &nbsp; property_merge_result_type result;<br>
55 &nbsp; pm.merge(result);<br>
56 <br>
57 &nbsp; //lets enumerate boolean combinations of inputs (hold onto your hats)<br>
58 &nbsp; for(unsigned int i = 0; i &lt; 8; ++i) {<br>
59 &nbsp;&nbsp;&nbsp; bool bits[3] = {i &amp; 1, i &amp; 2, i &amp; 4}; //break out bit array<br>
60 &nbsp;&nbsp;&nbsp; polygon_set_type test_set;<br>
61 &nbsp;&nbsp;&nbsp; std::set&lt;int&gt; key;<br>
62 &nbsp;&nbsp;&nbsp; for(unsigned int j = 0; j &lt; 3; ++j) {<br>
63 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(bits[j]) {<br>
64 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key.insert(key.end(), j);<br>
65 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; test_set += test_data[j];<br>
66 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
67 &nbsp;&nbsp;&nbsp; }<br>
68 &nbsp;&nbsp;&nbsp; for(unsigned int j = 0; j &lt; 3; ++j) {<br>
69 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(bits[j]) {<br>
70 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; test_set *= test_data[j];<br>
71 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
72 &nbsp;&nbsp;&nbsp; }<br>
73 &nbsp;&nbsp;&nbsp; for(unsigned int j = 0; j &lt; 3; ++j) {<br>
74 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!bits[j])<br>
75 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; test_set -= test_data[j];<br>
76 &nbsp;&nbsp;&nbsp; }<br>
77 &nbsp;&nbsp;&nbsp; if(test_set.empty()) {<br>
78 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //only the null combination should not exist<br>
79 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert(i == 0);<br>
80 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //a combination that does not exist should not<br>
81 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //be present in result<br>
82 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert(result.find(key) == result.end());<br>
83 &nbsp;&nbsp;&nbsp; } else {<br>
84 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert(gtl::equivalence(result[key], test_set));<br>
85 &nbsp;&nbsp;&nbsp; }<br>
86 &nbsp; }<br>
87 <br>
88 &nbsp; //Notice that we have to do O(2^n) booleans to compose the same<br>
89 &nbsp; //result that is produced in one pass of property merge<br>
90 &nbsp; //given n input layers (8 = 2^3 in this example)<br>
91 }<br>
92 <br>
93 int main() {<br>
94 &nbsp;
95 test_pm&lt;gtl::property_merge_90&lt;int, int&gt; &gt;();<br>
96 &nbsp;
97 test_pm&lt;gtl::property_merge&lt;int, int&gt; &gt;();<br>
98 &nbsp;
99 return 0;<br>
100 }<br>
101 //Now you know how to use the manhattan and arbitrary angle property<br>
102 //merge algorithms to perform map overlay on n layers of input geometry<br>
103 &nbsp;</font></p>
104
105
106 <table class="docinfo" rules="none" frame="void" id="table1">
107 <colgroup>
108 <col class="docinfo-name"><col class="docinfo-content">
109 </colgroup>
110 <tbody vAlign="top">
111 <tr>
112 <th class="docinfo-name">Copyright:</th>
113 <td>Copyright © Intel Corporation 2008-2010.</td>
114 </tr>
115 <tr class="field">
116 <th class="docinfo-name">License:</th>
117 <td class="field-body">Distributed under the Boost Software License,
118 Version 1.0. (See accompanying file <tt class="literal">
119 <span class="pre">LICENSE_1_0.txt</span></tt> or copy at
120 <a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
121 http://www.boost.org/LICENSE_1_0.txt</a>)</td>
122 </tr>
123 </table>
124
125 </body>
126
127 </html>