Sophie

Sophie

distrib > Mageia > 6 > i586 > by-pkgid > 8bc6759a6f32712e5bc0cdfb80b23784 > files > 1000

boost-examples-1.60.0-6.mga6.noarch.rpm

// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example

// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.

// 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)

//[assign_point_from_index
//` Shows how to retrieve one point from a box (either lower-left or upper-right) or segment

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/segment.hpp>

using namespace boost::geometry;

int main()
{
    typedef model::d2::point_xy<double> point;
    typedef model::segment<point> segment;

    segment s;
    assign_values(s, 1, 1, 2, 2);

    point first, second;
    assign_point_from_index<0>(s, first);
    assign_point_from_index<1>(s, second);
    std::cout
        << "segment: " << dsv(s) << std::endl
        << "first: " << dsv(first) << std::endl
        << "second: " << dsv(second) << std::endl;

    return 0;
}

//]


//[assign_point_from_index_output
/*`
Output:
[pre
segment: ((1, 1), (2, 2))
first: (1, 1)
second: (2, 2)
]
*/
//]