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 to view this page for the latest version.
PrevUpHomeNext
expand

Expands a box using the bounding box (envelope) of another geometry (box, point)

Synopsis

template<typename Box, typename Geometry>
void expand(Box & box, Geometry const & geometry)

Parameters

Type

Concept

Name

Description

Box &

type of the box

box

box to be expanded using another geometry, mutable

Geometry const &

Any type fulfilling a Geometry Concept

geometry

A model of the specified concept geometry which envelope (bounding box) will be added to the box

Header

Either

#include <boost/geometry.hpp>

Or

#include <boost/geometry/algorithms/expand.hpp>

Conformance

The function expand is not defined by OGC.

Behavior

Case

Behavior

Box / Point

Box is expanded to include the specified Point

Box / Box

Box is expanded to include the specified Box

Box / Other geometries

Not yet supported in this version

[Note] Note

To use expand with another geometry type then specified, use expand(make_envelope<box_type>(geometry)

Complexity

Linear

Example

Shows the usage of expand

#include <iostream>
#include <list>

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

int main()
{
    typedef boost::geometry::model::d2::point_xy<short int> point_type;
    typedef boost::geometry::model::box<point_type> box_type;

    using boost::geometry::expand;

    box_type box = boost::geometry::make_inverse<box_type>(); 1

    expand(box, point_type(0, 0));
    expand(box, point_type(1, 2));
    expand(box, point_type(5, 4));
    expand(box, boost::geometry::make<box_type>(3, 3, 5, 5));

    std::cout << boost::geometry::dsv(box) << std::endl;

    return 0;
}

1

expand is usually preceded by a call to assign_inverse or make_inverse

Output:

((0, 0), (5, 5))

PrevUpHomeNext