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
Boost.Polygon's rectangle_data

Boost.Polygon's rectangle type (boost::polygon::rectangle_data) is adapted to the Boost.Geometry Point Concept.

Description

Boost.Polygon's points (as well as polygons) can be used by Boost.Geometry. The two libraries can therefore be used together. Using a boost::polygon::rectangle_data<...>, algorithms from both Boost.Polygon and Boost.Geometry can be called.

Model of

Box Concept

Header

#include <boost/geometry/geometries/adapted/boost_polygon.hpp>

The standard header boost/geometry.hpp does not include this header.

Example

Shows how to use Boost.Polygon rectangle_data within Boost.Geometry

#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon.hpp>

int main()
{
    typedef boost::polygon::rectangle_data<int> rect;

    rect b = boost::polygon::construct<rect>(1, 2, 3, 4);

    std::cout << "Area (using Boost.Geometry): "
        << boost::geometry::area(b) << std::endl;
    std::cout << "Area (using Boost.Polygon): "
        << boost::polygon::area(b) << std::endl;

    return 0;
}

Output:

Area (using Boost.Geometry): 4
Area (using Boost.Polygon): 4

PrevUpHomeNext