|
Boost Users : |
Subject: Re: [Boost-users] [geometry] problems with the ring concept
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2013-08-25 08:37:45
Just an observation:
On Sat, Aug 24, 2013 at 11:07 AM, Lepere Renaud <lepere.renaud_at_[hidden]> wrote:
>
> I have an existing geometric structure, and i try to make it usable with
> boost geometry. I read the documentation for a similar problem but i did
> not success
> http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/examples/example__adapting_a_legacy_geometry_object_model.html
>
> My Ring structure is very simple :
> typedef std::vector< Point > Points;
> struct Ring
> {
> Points points;
> };
I'm not sure you're making it more complex than it needs to be. It
seems like a Ring *IS* a Vector of Points. And/or the *application* of
that type. So why not run with the type you've already defined?
typedef std::vector<Point> points_vector;
//...
points_vector my_ring;
Or:
typedefin std::vector<Point> ring_type;
Then you don't have to implement anything else, no other iterators:
vector is already done for you.
Good luck!
> void f()
> {
> boost::geometry::concept::check< Geom::Ring >();
> }
> show failure since apparently my range does not support a clear() method
> correctly.
>
> however i think i implemented correctly the range adaption
>
> namespace boost/geometry/traints
> template<> struct tag< Geom::Ring > { typedef ring_tag type; };
>
> namespace Geom
> inline Geom::Points::iterator
> range_begin(Ring & ring) { return ring.points.begin(); }
>
> inline Geom::Points::iterator
> range_end(Ring & ring) { return ring.points.end(); }
>
> inline Geom::Points::const_iterator
> range_begin(const Ring & ring) { return ring.points.begin(); }
>
> inline Geom::Points::const_iterator
> range_end(const Ring & ring) { return ring.points.end(); }
>
> and in namespace boost
> template <>
> struct range_mutable_iterator< Geom::Ring >
> { typedef Geom::Points::iterator type; };
> // i tried also with range_iterator
>
> template<>
> struct range_const_iterator< Geom::Ring >
> { typedef Geom::Points::const_iterator type; };
>
> I am a bit lost. Did i missed something obvious ?
> Thanks,
>
> Renaud
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net