Boost logo

Geometry :

Subject: [ggl] Box concept traits and registration
From: vd (zedxz2)
Date: 2011-09-01 09:25:50


I think there is a problem with the box concept traits registration, or
there is obviously something I'm doing wrong.
I have a simple MyBoxType class that does a few things, and have a point
type template parameter.

I use this template parameter mainly for custom points. These have traits so
that they can be used with boost geometry.
The traits are created via the BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET

typedef MyPointType<double> Point2;

These custom points work fine. For example, I can create a
boost::geometry::model::polygon<Point2 > and a Point2 and call
boost::geometry::within and it works as expected.

However, when trying to use the same algorithm (or any other) with 2 of my
custom boxes, I get compilation errors that seems related to traits.
Here is a brief overview of my custom box class, is it very straightforward:

template <typename P>
class MyBoxType
  MyBoxType(const P& minc, const P& maxc)
  : minCorner_(minc)
  , maxCorner_(maxc)
  // ...
  const P& min_corner() const { return minCorner_; }
  const P& max_corner() const { return maxCorner_; }
  P& min_corner() { return minCorner_; }
        P& max_corner() { return maxCorner_; }
  P minCorner_;
  P maxCorner_;

// Registration:
typedef MyBoxType<Point2 > Box2;
BOOST_GEOMETRY_REGISTER_BOX(Box2, Point2, Box2::min_corner,

Then trying to call for example boost::geometry::within (or any other) on 2
Box2 objects, I get:
*MyBoxType.h: In static member function ?static double
boost::geometry::traits::indexed_access<MyBoxType<MyPointType<double> >,
1ul, D>::get(const Box2&) [with long unsigned int D = 0ul]?:*
*/opt/local/include/boost/geometry/core/access.hpp:138: instantiated from
?static CoordinateType
Box, CoordinateType, Index, Dimension>::get(const Box&) [with Box =
MyBoxType<MyPointType<double> >, CoordinateType = double, long unsigned int
Index = 1ul, long unsigned int Dimension = 0ul]?*
*/opt/local/include/boost/geometry/core/access.hpp:283: instantiated from
?typename boost::geometry::coordinate_type<Geometry>::type
boost::geometry::get(const Geometry&,
boost::geometry::detail::signature_getset_index_dimension*) [with long
unsigned int Index = 1ul, long unsigned int Dimension = 0ul, Geometry =
MyBoxType<MyPointType<double> >]?*
*/opt/local/include/boost/geometry/algorithms/within.hpp:117: instantiated
from ?static int boost::geometry::detail::within::box_in_box<Box1, Box2,
Strategy, Dimension, DimensionCount>::apply(const Box1&, const Box2&, const
Strategy&) [with Box1 = MyBoxType<MyPointType<double> >, Box2 =
MyBoxType<MyPointType<double> >, Strategy =
boost::geometry::strategy::within::unused_strategy, long unsigned int
Dimension = 0ul, long unsigned int DimensionCount = 2ul]?*
*/opt/local/include/boost/geometry/algorithms/within.hpp:411: instantiated
from ?bool boost::geometry::within(const Geometry1&, const Geometry2&) [with
Geometry1 = Box2, Geometry2 = Box2]?*
*Geometries.cpp:223: instantiated from here*
*MyBoxType.h:90: error: no matching function for call to ?get(<unresolved
overloaded function type>)?*

Does anyone see something I'm doing wrong (or not doing?)
Any help is appreciated,

-------------- next part --------------
An HTML attachment was scrubbed...

Geometry list run by mateusz at