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

Boost.Polygon's rectangle_data

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


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


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

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


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;


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