]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/make_2d_point.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / make_2d_point.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// QuickBook Example
3
4// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
6// Use, modification and distribution is subject to the Boost Software License,
7// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10//[make_2d_point
11//` Shows the usage of make as a generic constructor for different point types
12
13#include <iostream>
14
15#include <boost/geometry.hpp>
16#include <boost/geometry/geometries/point_xy.hpp>
17#include <boost/geometry/geometries/register/point.hpp>
18#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
19#include <boost/geometry/geometries/adapted/boost_polygon/point.hpp>
20
21BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
22
23struct mypoint { float _x, _y; };
24
25BOOST_GEOMETRY_REGISTER_POINT_2D(mypoint, float, cs::cartesian, _x, _y)
26
27template <typename Point>
28void construct_and_display()
29{
30 using boost::geometry::make;
31 using boost::geometry::get;
32
33 Point p = make<Point>(1, 2);
34
35 std::cout << "x=" << get<0>(p) << " y=" << get<1>(p)
36 << " (" << typeid(Point).name() << ")"
37 << std::endl;
38}
39
40int main()
41{
42 construct_and_display<boost::geometry::model::d2::point_xy<double> >();
43 construct_and_display<boost::geometry::model::d2::point_xy<int> >();
44 construct_and_display<boost::tuple<double, double> >();
45 construct_and_display<boost::polygon::point_data<int> >();
46 construct_and_display<mypoint>();
47 return 0;
48}
49
50//]
51
52//[make_2d_point_output
53/*`
54Output (compiled using gcc):
55[pre
56x=1 y=2 (N5boost8geometry5model2d28point_xyIdNS0_2cs9cartesianEEE)
57x=1 y=2 (N5boost8geometry5model2d28point_xyIiNS0_2cs9cartesianEEE)
58x=1 y=2 (N5boost6tuples5tupleIddNS0_9null_typeES2_S2_S2_S2_S2_S2_S2_EE)
59x=1 y=2 (N5boost7polygon10point_dataIiEE)
60x=1 y=2 (7mypoint)
61]
62*/
63//]