Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is an old version of boost. Click here for the latest version's documentation home page.
PrevUpHomeNext
get (with index)

get coordinate value of a Box or Segment

Description

The free functions get and set are two of the most important functions of Boost.Geometry, both within the library, as also for the library user. With these two functions you normally get and set coordinate values from and for a point, box, segment or sphere.

Synopsis

template<std::size_t Index, std::size_t Dimension, typename Geometry>
coordinate_type<Geometry>::type get(Geometry const & geometry)

Parameters

Type

Concept

Name

Description

Index

Index, this template parameter is required. For a Box: either min_corner or max_corner. For a Segment: either 0 or 1 for first or last point.

-

Must be specified

Dimension

Dimension, this template parameter is required. Should contain [0 .. n-1] for an n-dimensional geometry

-

Must be specified

Geometry const &

Any type fulfilling a Box Concept or a Segment Concept

geometry

A model of the specified concept

Returns

coordinate value

Header

Either

#include <boost/geometry/geometry.hpp>

Or

#include <boost/geometry/core/access.hpp>

Behavior

Case

Behavior

Rectangle

Returns the coordinate of a box (use min_corner, max_corner to specify which of the points to get)

Segment

Returns the coordinate of a segment (use 0, 1 to specify which of the two points to get)

Complexity

Constant

Example

Get the coordinate of a box

#include <iostream>

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

namespace bg = boost::geometry;

int main()
{
    bg::model::box<bg::model::d2::point_xy<double> > box;

    bg::assign_values(box, 1, 3, 5, 6);

    std::cout << "Box:"
        << " " << bg::get<bg::min_corner, 0>(box)
        << " " << bg::get<bg::min_corner, 1>(box)
        << " " << bg::get<bg::max_corner, 0>(box)
        << " " << bg::get<bg::max_corner, 1>(box)
        << std::endl;

    return 0;
}

Output:

Box: 1 3 5 6

PrevUpHomeNext