FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
geometry/example/c02_custom_box_example.cpp at develop · boostorg/geometry · GitHub
boostorg
geometry
Repository navigation
Code
Issues
146
(146)
Pull requests
15
(15)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
geometry
/
example
/
c02_custom_box_example.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (64 loc) · 2.42 KB
Breadcrumbs
geometry
/
example
/
c02_custom_box_example.cpp
Copy path
File metadata and controls
78 lines (64 loc) · 2.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
Boost.Geometry (aka GGL, Generic Geometry Library)
//
Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
//
Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
//
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
//
Use, modification and distribution is subject to the Boost Software License,
//
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//
http://www.boost.org/LICENSE_1_0.txt)
//
//
Custom Box Example
#
include
<
iostream
>
#
include
<
boost/geometry/algorithms/make.hpp
>
#
include
<
boost/geometry/algorithms/within.hpp
>
#
include
<
boost/geometry/geometries/register/point.hpp
>
#
include
<
boost/geometry/geometries/register/box.hpp
>
#
include
<
boost/geometry/strategies/strategies.hpp
>
#
include
<
boost/geometry/io/dsv/write.hpp
>
struct
my_point
{
double
x, y;
};
struct
my_int_point
{
int
x, y;
};
struct
my_box
{
my_point ll, ur;
};
struct
my_box_ltrb
{
int
left, top, right, bottom;
};
struct
my_box_4
{
double
coors[
4
];
};
template
<
typename
P>
struct
my_box_t
{
P ll, ur;
};
BOOST_GEOMETRY_REGISTER_POINT_2D
(my_point,
double
, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_POINT_2D
(my_int_point,
int
, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_BOX
(my_box, my_point, ll, ur)
BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED
(
my_box_t
, ll, ur)
BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES
(my_box_ltrb, my_int_point, left, top, right, bottom)
BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES
(my_box_4, my_point, coors[
0
], coors[
1
], coors[
2
], coors[
3
])
int
main
()
{
my_point p = boost::geometry::make<my_point>(
3.5
,
3.5
);
my_box b = boost::geometry::make<my_box>(
0
,
0
,
2
,
2
);
my_box_ltrb b1 = boost::geometry::make<my_box_ltrb>(
0
,
0
,
3
,
3
);
my_box_4 b4 = boost::geometry::make<my_box_4>(
0
,
0
,
4
,
4
);
my_box_t
<my_point> bt = boost::geometry::make<
my_box_t
<my_point> >(
0
,
0
,
5
,
5
);
std::cout <<
boost::geometry::dsv
(p) <<
"
IN
"
<<
boost::geometry::dsv
(b)
<<
"
:
"
<<
int
(
boost::geometry::within
(p, b)) << std::endl;
std::cout <<
boost::geometry::dsv
(p) <<
"
IN
"
<<
boost::geometry::dsv
(b1)
<<
"
:
"
<<
int
(
boost::geometry::within
(p, b1)) << std::endl;
std::cout <<
boost::geometry::dsv
(p) <<
"
IN
"
<<
boost::geometry::dsv
(b4)
<<
"
:
"
<<
int
(
boost::geometry::within
(p, b4)) << std::endl;
std::cout <<
boost::geometry::dsv
(p) <<
"
IN
"
<<
boost::geometry::dsv
(bt)
<<
"
:
"
<<
int
(
boost::geometry::within
(p, bt)) << std::endl;
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL