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 the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext
set (with index)

set coordinate value of a Box / 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>
void set(Geometry & geometry, typename coordinate_type< Geometry >::type const & value)

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 &

Any type fulfilling a Box Concept or a Segment Concept

geometry

A model of the specified concept

typename coordinate_type< Geometry >::type const &

value

The coordinate value to set

Header

Either

#include <boost/geometry/geometry.hpp>

Or

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

Behavior

Case

Behavior

Rectangle

Sets the coordinate of a box (use min_corner, max_corner to specify which of the points to set)

Segment

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

Complexity

Constant

Example

Set 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::set<bg::min_corner, 0>(box, 0);
    bg::set<bg::min_corner, 1>(box, 2);
    bg::set<bg::max_corner, 0>(box, 4);
    bg::set<bg::max_corner, 1>(box, 5);

    std::cout << "Extent: " << bg::dsv(box) << std::endl;

    return 0;
}

Output:

Extent: ((0, 2), (4, 5))

PrevUpHomeNext