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_GEOMETRY_REGISTER_BOX_TEMPLATED

Macro to register a box.

Description

The macro BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED registers a box such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type. The type must have one template parameter, which should be a point type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated box are registered, regardless of their point type.

Synopsis

#define BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(Box, MinCorner, MaxCorner)

Parameters

Name

Description

Box

Box type to be registered

MinCorner

minimum corner (should be public member or method)

MaxCorner

maximum corner (should be public member or method)

Header

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

Example

Show the use of the macro BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED

#include <iostream>

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

template <typename P>
struct my_box
{
    P ll, ur;
};

// Register the box type
BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(my_box, ll, ur)

int main()
{
    typedef my_box<boost::geometry::model::d2::point_xy<double> > box;
    box b = boost::geometry::make<box>(0, 0, 2, 2);
    std::cout << "Area: "  << boost::geometry::area(b) << std::endl;
    return 0;
}

Output:

Area: 4

PrevUpHomeNext