4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=windows-1252">
5 <title>Connectivity Extraction Usage
</title>
10 <p><font face=
"Courier New">#include
<boost/polygon/polygon.hpp
><br>
11 #include
<cassert
><br>
12 namespace gtl = boost::polygon;
<br>
14 //This function works with both the
90 and
45 versions
<br>
15 //of connectivity extraction algroithm
<br>
16 template
<typename ce_type
><br>
18 //first we create an object to do the connectivity extraction
<br>
19 ce_type ce;
<br>
21 //create some test data
<br>
22 std::vector
<gtl::rectangle_data
<int
> > test_data;
<br>
23 test_data.push_back(gtl::rectangle_data
<int
>(
10,
10,
90,
90));
<br>
24 test_data.push_back(gtl::rectangle_data
<int
>(
0,
0,
20,
20));
<br>
25 test_data.push_back(gtl::rectangle_data
<int
>(
80,
0,
100,
20));
<br>
26 test_data.push_back(gtl::rectangle_data
<int
>(
0,
80,
20,
100));
<br>
27 test_data.push_back(gtl::rectangle_data
<int
>(
80,
80,
100,
100));
<br>
28 //There is one big square and four little squares covering each
<br>
29 //of its corners.
<br>
31 for(unsigned int i =
0; i
< test_data.size(); ++i) {
<br>
32 //insert returns an id starting at zero and incrementing
<br>
33 //with each call
<br>
34 assert(ce.insert(test_data[i]) == i);
<br>
36 //notice that ids returned by ce.insert happen to match
<br>
37 //index into vector of inputs in this case
<br>
39 //make sure the vector graph has elements for our nodes
<br>
40 std::vector
<std::set
<int
> > graph(test_data.size());
<br>
42 //populate the graph with edge data
<br>
43 ce.extract(graph);
<br>
45 //make a map type graph to compare results
<br>
46 std::map
<int, std::set
<int
> > map_graph;
<br>
47 ce.extract(map_graph);
<br>
49 assert(map_graph.size()
&& map_graph.size() == graph.size());
<br>
50 for(unsigned int i =
0; i
< graph.size(); ++i) {
<br>
51 assert(graph[i] == map_graph[i]);
<br>
52 if(i ==
0)
<br>
53 assert(graph[i].size() ==
4); //four little
55 else
<br>
56 assert(graph[i].size() ==
1); //each little
57 toches the big square
<br>
62 test_ce
<gtl::connectivity_extraction_90
<int
> >();
<br>
63 test_ce
<gtl::connectivity_extraction_45
<int
> >();
<br>
67 //Now you know how to use the connectivity extraction algorithm
<br>
68 //to extract the connectivity graph for overlapping geometry
<br>
72 <table class=
"docinfo" rules=
"none" frame=
"void" id=
"table1">
74 <col class=
"docinfo-name"><col class=
"docinfo-content">
78 <th class=
"docinfo-name">Copyright:
</th>
79 <td>Copyright © Intel Corporation
2008-
2010.
</td>
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>