Boost.Geometry    Boost C++ Libraries
boost::geometry::concepts::Point< Geometry > Class Template Reference

Point concept. More...

Detailed Description

template<typename Geometry>
class boost::geometry::concepts::Point< Geometry >

Point concept.

Formal definition:
The point concept is defined as following:
Example:

A legacy point, defining the necessary specializations to fulfil to the concept.

Suppose that the following point is defined:

struct legacy_point1
{
double x, y;
};

It can then be adapted to the concept as following:

// adapt legacy_point1
namespace boost { namespace geometry { namespace traits
{
template <> struct tag<legacy_point1> { typedef point_tag type; };
template <> struct coordinate_type<legacy_point1> { typedef double type; };
template <> struct coordinate_system<legacy_point1> { typedef cs::cartesian type; };
template <> struct dimension<legacy_point1>: boost::mpl::int_<2> {};
template <> struct access<legacy_point1, 0>
{
static double get(legacy_point1 const& p) { return p.x; }
static void set(legacy_point1& p, double const& value) { p.x = value; }
};
template <> struct access<legacy_point1, 1>
{
static double get(legacy_point1 const& p) { return p.y; }
static void set(legacy_point1& p, double const& value) { p.y = value; }
};
}}} // namespace boost::geometry::traits

Note that it is done like above to show the system. Users will normally use the registration macro.

Example:

A read-only legacy point, using a macro to fulfil to the ConstPoint concept. It cannot be modified by the library but can be used in all algorithms where points are not modified.

The point looks like the following:

class legacy_point2
{
public :
double x() const;
double y() const;
};

It uses the macro as following:

// adapt legacy_point2
// end adaptation


April 2, 2011

Copyright © 2007-2011 Barend Gehrels, Amsterdam, the Netherlands
Copyright © 2008-2011 Bruno Lalande, Paris, France
Copyright © 2009-2010 Mateusz Loskot, London, UK
Documentation is generated by Doxygen