-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathc09_custom_fusion_example.cpp
62 lines (44 loc) · 1.46 KB
/
c09_custom_fusion_example.cpp
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
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2011-2012 Akira Takahashi
// 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 point / Boost.Fusion Example
#include <iostream>
#include <boost/fusion/include/adapt_struct_named.hpp>
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/geometries/adapted/boost_fusion.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/dsv/write.hpp>
BOOST_GEOMETRY_REGISTER_BOOST_FUSION_CS(cs::cartesian);
// Sample point, having x/y
struct my_2d
{
float x,y;
};
BOOST_FUSION_ADAPT_STRUCT(my_2d,
(float, x)
(float, y))
int main()
{
my_2d p1 = {1, 5};
my_2d p2 = {3, 4};
std::cout << "Coordinate using direct access: "
<< p1.x
<< std::endl;
std::cout << "Coordinate using Boost.Fusion: "
<< boost::fusion::at_c<0>(p1)
<< std::endl;
std::cout << "Coordinate using Boost.Geometry: "
<< boost::geometry::get<0>(p1)
<< std::endl;
std::cout << "Two points are: "
<< boost::geometry::dsv(p1) << " "
<< boost::geometry::dsv(p2) << std::endl;
std::cout << "Distance: "
<< boost::geometry::distance(p1, p2)
<< std::endl;
return 0;
}