Limbo
3.5.4
Toggle main menu visibility
Loading...
Searching...
No Matches
test
geometry
test_boostpolygonapi.cpp
Go to the documentation of this file.
1
6
7
#include <iostream>
8
#include <string>
9
#include <vector>
10
#include <list>
11
#include <set>
12
#include <boost/polygon/polygon.hpp>
13
#include <
limbo/geometry/Polygon2Rectangle.h
>
14
#include <
limbo/geometry/api/BoostPolygonApi.h
>
15
#include <
limbo/geometry/api/GeoBoostPolygonApi.h
>
16
using
std::cout;
17
using
std::endl;
18
using
std::string;
19
using
std::vector;
20
using
std::list;
21
using
std::set;
22
23
namespace
gtl = boost::polygon;
24
namespace
lg
=
limbo::geometry
;
25
31
36
void
test1
(
string
const
& filename)
37
{
38
std::vector<gtl::rectangle_data<int> > vRect;
39
lg::Polygon2Rectangle<vector<gtl::point_data<int>
>, vector<gtl::rectangle_data<int> > > p2r (vRect,
lg::HOR_VER_SLICING
);
40
assert(p2r.
read
(filename));
41
assert(p2r());
42
p2r.
print
(
"p2r1.gp"
);
43
}
44
49
void
test2
(
string
const
& filename)
50
{
51
std::vector<gtl::rectangle_data<int> > vRect;
52
lg::Polygon2Rectangle<list<gtl::point_data<int>
>, vector<gtl::rectangle_data<int> > > p2r (vRect,
lg::HOR_VER_SLICING
);
53
assert(p2r.
read
(filename));
54
assert(p2r());
55
p2r.
print
(
"p2r2.gp"
);
56
}
57
62
void
test3
(
string
const
& filename)
63
{
64
std::vector<gtl::rectangle_data<int> > vRect;
65
lg::Polygon2Rectangle<set<gtl::point_data<int>
,
lg::point_compare_type
>, vector<gtl::rectangle_data<int> > > p2r (vRect,
lg::HOR_VER_SLICING
);
66
assert(p2r.
read
(filename));
67
assert(p2r());
68
p2r.
print
(
"p2r3.gp"
);
69
}
70
74
void
test4
()
75
{
76
vector<gtl::point_data<int> > vPoint (8);
77
vPoint[0] = gtl::construct<gtl::point_data<int> >(0, 0);
78
vPoint[1] = gtl::construct<gtl::point_data<int> >(0, 10);
79
vPoint[2] = gtl::construct<gtl::point_data<int> >(10, 10);
80
vPoint[3] = gtl::construct<gtl::point_data<int> >(10, 20);
81
vPoint[4] = gtl::construct<gtl::point_data<int> >(20, 20);
82
vPoint[5] = gtl::construct<gtl::point_data<int> >(20, 10);
83
vPoint[6] = gtl::construct<gtl::point_data<int> >(30, 10);
84
vPoint[7] = gtl::construct<gtl::point_data<int> >(30, 0);
85
//vPoint.push_back(gtl::construct<gtl::point_data<int> >(0, 0));
86
vector<gtl::rectangle_data<int> > vRectangle;
87
assert(
lg::polygon2RectangleBoost
(vPoint, vRectangle));
88
for
(std::size_t i = 0; i != vRectangle.size(); ++i)
89
{
90
gtl::rectangle_data<int>
const
& rect = vRectangle[i];
91
cout <<
"("
<< gtl::xl(rect) <<
", "
<< gtl::yl(rect) <<
", "
<< gtl::xh(rect) <<
", "
<< gtl::yh(rect) <<
")\n"
;
92
}
93
cout <<
"test 4 passed\n"
;
94
}
95
102
int
main
(
int
argc,
char
** argv)
103
{
104
test4
();
105
if
(argc > 1)
106
{
107
test1
(argv[1]);
108
test2
(argv[1]);
109
test3
(argv[1]);
110
}
111
else
cout <<
"at least 1 argument is required"
<< endl;
112
113
return
0;
114
}
BoostPolygonApi.h
Geometry traits for Boost.Polygon, include this file when you use Boost.Polygon geometric types.
GeoBoostPolygonApi.h
this file extracts polygon-to-rectangle conversion for Boost.Polygon API.
Polygon2Rectangle.h
a generic implementation of polygon-to-rectangle conversion
limbo::geometry::Polygon2Rectangle
a class implement conversion from manhattan polygon to rectangle
Definition
Polygon2Rectangle.h:91
limbo::geometry::Polygon2Rectangle::read
bool read(string const &filename)
read polygon from file try to be compatible to gnuplot format
Definition
Polygon2Rectangle.h:380
limbo::geometry::Polygon2Rectangle::print
void print(string const &filename) const
print polygon to file in gnuplot format
Definition
Polygon2Rectangle.h:441
limbo::geometry
namespace for Limbo.Geometry
Definition
Geometry.h:21
limbo::geometry::polygon2RectangleBoost
bool polygon2RectangleBoost(std::vector< gtl::point_data< int > > const &vPoint, std::vector< gtl::rectangle_data< int > > &vRectangle)
this function takes a set of points describing a rectilinear polygon and decomposes it into rectangle...
limbo::geometry::HOR_VER_SLICING
@ HOR_VER_SLICING
horizontal/vertical slicing and choose rectangle with larger area every time
Definition
Geometry.h:43
limbo::geometry::point_compare_type
sort helper if orient == HORIZONTAL, sort by left lower if orient == VERTICAL, sort by lower left
Definition
Polygon2Rectangle.h:51
main
int main()
Definition
test_ChromaticNumber.cpp:78
test4
void test4()
test polygon-to-rectangle for array of points
Definition
test_boostpolygonapi.cpp:74
test2
void test2(string const &filename)
test polygon-to-rectangle for std::list
Definition
test_boostpolygonapi.cpp:49
test3
void test3(string const &filename)
test polygon-to-rectangle for std::set
Definition
test_boostpolygonapi.cpp:62
test1
void test1()
test function API
Definition
test_solvers.cpp:11
Generated on
for Limbo by
1.17.0