46e399eb59
[SVN r62301]
94 lines
3.4 KiB
HTML
94 lines
3.4 KiB
HTML
<html>
|
||
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||
<title>Connectivity Extraction Usage</title>
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<p><font face="Courier New">#include <boost/polygon/polygon.hpp><br>
|
||
#include <cassert><br>
|
||
namespace gtl = boost::polygon;<br>
|
||
<br>
|
||
//This function works with both the 90 and 45 versions<br>
|
||
//of connectivity extraction algroithm<br>
|
||
template <typename ce_type><br>
|
||
void test_ce() {<br>
|
||
//first we create an object to do the connectivity extraction<br>
|
||
ce_type ce;<br>
|
||
<br>
|
||
//create some test data<br>
|
||
std::vector<gtl::rectangle_data<int> > test_data;<br>
|
||
test_data.push_back(gtl::rectangle_data<int>(10, 10, 90, 90));<br>
|
||
test_data.push_back(gtl::rectangle_data<int>(0, 0, 20, 20));<br>
|
||
test_data.push_back(gtl::rectangle_data<int>(80, 0, 100, 20));<br>
|
||
test_data.push_back(gtl::rectangle_data<int>(0, 80, 20, 100));<br>
|
||
test_data.push_back(gtl::rectangle_data<int>(80, 80, 100, 100));<br>
|
||
//There is one big square and four little squares covering each<br>
|
||
//of its corners.<br>
|
||
<br>
|
||
for(unsigned int i = 0; i < test_data.size(); ++i) {<br>
|
||
//insert returns an id starting at zero and incrementing<br>
|
||
//with each call<br>
|
||
assert(ce.insert(test_data[i]) == i);<br>
|
||
}<br>
|
||
//notice that ids returned by ce.insert happen to match<br>
|
||
//index into vector of inputs in this case<br>
|
||
<br>
|
||
//make sure the vector graph has elements for our nodes<br>
|
||
std::vector<std::set<int> > graph(test_data.size());<br>
|
||
<br>
|
||
//populate the graph with edge data<br>
|
||
ce.extract(graph);<br>
|
||
<br>
|
||
//make a map type graph to compare results<br>
|
||
std::map<int, std::set<int> > map_graph;<br>
|
||
ce.extract(map_graph);<br>
|
||
<br>
|
||
assert(map_graph.size() && map_graph.size() == graph.size());<br>
|
||
for(unsigned int i = 0; i < graph.size(); ++i) {<br>
|
||
assert(graph[i] == map_graph[i]);<br>
|
||
if(i == 0)<br>
|
||
assert(graph[i].size() == 4); //four little
|
||
squares<br>
|
||
else<br>
|
||
assert(graph[i].size() == 1); //each little
|
||
toches the big square<br>
|
||
}<br>
|
||
}<br>
|
||
<br>
|
||
int main() {<br>
|
||
test_ce<gtl::connectivity_extraction_90<int> >();<br>
|
||
test_ce<gtl::connectivity_extraction_45<int> >();<br>
|
||
return 0;<br>
|
||
}<br>
|
||
<br>
|
||
//Now you know how to use the connectivity extraction algorithm<br>
|
||
//to extract the connectivity graph for overlapping geometry<br>
|
||
</font></p>
|
||
|
||
|
||
<table class="docinfo" rules="none" frame="void" id="table1">
|
||
<colgroup>
|
||
<col class="docinfo-name"><col class="docinfo-content">
|
||
</colgroup>
|
||
<tbody vAlign="top">
|
||
<tr>
|
||
<th class="docinfo-name">Copyright:</th>
|
||
<td>Copyright <20> Intel Corporation 2008-2010.</td>
|
||
</tr>
|
||
<tr class="field">
|
||
<th class="docinfo-name">License:</th>
|
||
<td class="field-body">Distributed under the Boost Software License,
|
||
Version 1.0. (See accompanying file <tt class="literal">
|
||
<span class="pre">LICENSE_1_0.txt</span></tt> or copy at
|
||
<a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
|
||
http://www.boost.org/LICENSE_1_0.txt</a>)</td>
|
||
</tr>
|
||
</table>
|
||
|
||
</body>
|
||
|
||
</html>
|