]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/make_2d_point.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
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)
11 //` Shows the usage of make as a generic constructor for different point types
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>
21 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
23 struct mypoint
{ float _x
, _y
; };
25 BOOST_GEOMETRY_REGISTER_POINT_2D(mypoint
, float, cs::cartesian
, _x
, _y
)
27 template <typename Point
>
28 void construct_and_display()
30 using boost::geometry::make
;
31 using boost::geometry::get
;
33 Point p
= make
<Point
>(1, 2);
35 std::cout
<< "x=" << get
<0>(p
) << " y=" << get
<1>(p
)
36 << " (" << typeid(Point
).name() << ")"
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
>();
52 //[make_2d_point_output
54 Output (compiled using gcc):
56 x=1 y=2 (N5boost8geometry5model2d28point_xyIdNS0_2cs9cartesianEEE)
57 x=1 y=2 (N5boost8geometry5model2d28point_xyIiNS0_2cs9cartesianEEE)
58 x=1 y=2 (N5boost6tuples5tupleIddNS0_9null_typeES2_S2_S2_S2_S2_S2_S2_EE)
59 x=1 y=2 (N5boost7polygon10point_dataIiEE)