]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/polygon/doc/gtl_connectivity_extraction_usage.htm
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / polygon / doc / gtl_connectivity_extraction_usage.htm
1 <html>
2
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
5 <title>Connectivity Extraction Usage</title>
6 </head>
7
8 <body>
9
10 <p><font face="Courier New">#include &lt;boost/polygon/polygon.hpp&gt;<br>
11 #include &lt;cassert&gt;<br>
12 namespace gtl = boost::polygon;<br>
13 <br>
14 //This function works with both the 90 and 45 versions<br>
15 //of connectivity extraction algroithm<br>
16 template &lt;typename ce_type&gt;<br>
17 void test_ce() {<br>
18 &nbsp; //first we create an object to do the connectivity extraction<br>
19 &nbsp; ce_type ce;<br>
20 <br>
21 &nbsp; //create some test data<br>
22 &nbsp; std::vector&lt;gtl::rectangle_data&lt;int&gt; &gt; test_data;<br>
23 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(10, 10, 90, 90));<br>
24 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(0, 0, 20, 20));<br>
25 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(80, 0, 100, 20));<br>
26 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(0, 80, 20, 100));<br>
27 &nbsp; test_data.push_back(gtl::rectangle_data&lt;int&gt;(80, 80, 100, 100));<br>
28 &nbsp; //There is one big square and four little squares covering each<br>
29 &nbsp; //of its corners.<br>
30 <br>
31 &nbsp; for(unsigned int i = 0; i &lt; test_data.size(); ++i) {<br>
32 &nbsp;&nbsp;&nbsp; //insert returns an id starting at zero and incrementing<br>
33 &nbsp;&nbsp;&nbsp; //with each call<br>
34 &nbsp;&nbsp;&nbsp; assert(ce.insert(test_data[i]) == i);<br>
35 &nbsp; }<br>
36 &nbsp; //notice that ids returned by ce.insert happen to match<br>
37 &nbsp; //index into vector of inputs in this case<br>
38 <br>
39 &nbsp; //make sure the vector graph has elements for our nodes<br>
40 &nbsp; std::vector&lt;std::set&lt;int&gt; &gt; graph(test_data.size());<br>
41 <br>
42 &nbsp; //populate the graph with edge data<br>
43 &nbsp; ce.extract(graph);<br>
44 <br>
45 &nbsp; //make a map type graph to compare results<br>
46 &nbsp; std::map&lt;int, std::set&lt;int&gt; &gt; map_graph;<br>
47 &nbsp; ce.extract(map_graph);<br>
48 <br>
49 &nbsp; assert(map_graph.size() &amp;&amp; map_graph.size() == graph.size());<br>
50 &nbsp; for(unsigned int i = 0; i &lt; graph.size(); ++i) {<br>
51 &nbsp;&nbsp;&nbsp; assert(graph[i] == map_graph[i]);<br>
52 &nbsp;&nbsp;&nbsp; if(i == 0)<br>
53 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert(graph[i].size() == 4); //four little
54 squares<br>
55 &nbsp;&nbsp;&nbsp; else<br>
56 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert(graph[i].size() == 1); //each little
57 toches the big square<br>
58 &nbsp; }<br>
59 }<br>
60 <br>
61 int main() {<br>
62 &nbsp; test_ce&lt;gtl::connectivity_extraction_90&lt;int&gt; &gt;();<br>
63 &nbsp; test_ce&lt;gtl::connectivity_extraction_45&lt;int&gt; &gt;();<br>
64 &nbsp; return 0;<br>
65 }<br>
66 <br>
67 //Now you know how to use the connectivity extraction algorithm<br>
68 //to extract the connectivity graph for overlapping geometry<br>
69 &nbsp;</font></p>
70
71
72 <table class="docinfo" rules="none" frame="void" id="table1">
73 <colgroup>
74 <col class="docinfo-name"><col class="docinfo-content">
75 </colgroup>
76 <tbody vAlign="top">
77 <tr>
78 <th class="docinfo-name">Copyright:</th>
79 <td>Copyright © Intel Corporation 2008-2010.</td>
80 </tr>
81 <tr class="field">
82 <th class="docinfo-name">License:</th>
83 <td class="field-body">Distributed under the Boost Software License,
84 Version 1.0. (See accompanying file <tt class="literal">
85 <span class="pre">LICENSE_1_0.txt</span></tt> or copy at
86 <a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
87 http://www.boost.org/LICENSE_1_0.txt</a>)</td>
88 </tr>
89 </table>
90
91 </body>
92
93 </html>