Boost logo

Geometry :

Subject: [ggl] Re: [fixed] Box concept traits and registration
From: vd (zedxz2)
Date: 2011-09-01 21:40:32


Turns out the only problem is that I had Point traits registration with
GET/SET in mind when writing the Box registration.

If we look at the point registration:

        static inline CoordinateType get(Point const& p) \

        { return p. Get (); }

It does p. Get() while for the Min(Max)Corner of boxes there is no
parentheses,

    static inline ct get(Box const& b) \

    { return geometry::get<D>(b. MinCorner); } \

So one must pass min_corner(), not min_corner, to the box registration
macro.

Adding the () fixed the accessors!

-vd

On Wed, Aug 31, 2011 at 7:17 PM, vd <zedxz2_at_[hidden]> wrote:

> Hi,
>
> 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
> method.
>
> typedef MyPointType<double> Point2;
> BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(Point2, double,
> boost:geometry::cs::cartesian,
> Point2::x,
> Point2::y,
> Point2::set_x,
> Point2::set_y)
>
> 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
> {
> public:
> 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_; }
> private:
> P minCorner_;
> P maxCorner_;
> };
>
> // Registration:
> typedef MyBoxType<Point2 > Box2;
> BOOST_GEOMETRY_REGISTER_BOX(Box2, Point2, Box2::min_corner,
> Box2::max_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
> boost::geometry::core_dispatch::indexed_access<boost::geometry::box_tag,
> 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,
>
> Thanks!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20110901/424425fc/attachment.html


Geometry list run by mateusz at loskot.net