[geometry] problems with the ring concept
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 successhttp://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/example... My Ring structure is very simple : typedef std::vector< Point > Points; struct Ring { Points points; }; 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
Hi, On 24-8-2013 18:07, Lepere Renaud 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/example...
My Ring structure is very simple :
typedef std::vector< Point > Points; struct Ring { Points points; };
void f() { boost::geometry::concept::check< Geom::Ring >(); } show failure since apparently my range does not support a clear() method correctly.
The concepts you defined are for readonly rings. If you check
Just an observation:
On Sat, Aug 24, 2013 at 11:07 AM, Lepere Renaud
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/example...
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
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.
Yes, but the problem was that i would have prefer not to change the existing structure (not as simple as the one in the example). After implementing clear, resize and push_back as suggested by Barend (an example is here http://www.boost.org/doc/libs/1_54_0/libs/geometry/example/c08_custom_non_st...), it works ! Thanks for your help Renaud
On Sun, Aug 25, 2013 at 8:19 AM, Lepere Renaud
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.
Yes, but the problem was that i would have prefer not to change the existing structure (not as simple as the one in the example). After implementing clear, resize and push_back as suggested by Barend (an example is here http://www.boost.org/doc/libs/1_54_0/libs/geometry/example/c08_custom_non_st...), it works !
So more of an adapter pattern. Fair enough.
Thanks for your help
Renaud _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Barend Gehrels
-
Lepere Renaud
-
Michael Powell