|
Geometry : |
Subject: Re: [geometry] Using Boost.Geometry with a legacy class hierarchy
From: Mats Taraldsvik (mats.taraldsvik_at_[hidden])
Date: 2012-02-21 06:43:39
Hi Barend,
On 02/20/2012 07:21 PM, Barend Gehrels wrote:
> Hi Mats,
>
>
> On 20-2-2012 9:03, Mats Taraldsvik wrote:
>> The object hierarcy is a bit more complex than my current example
>> (also contains 2d, 3d points, curves etc.), and objects are stored in
>> pointer to base/super-containers. Therefore, I can't remove the
>> pointer requirement, I'm afraid. I guess creating separate pointer
>> and non-pointer specializations (e.g. point_type and point_type_ptr)
>> since they are so different, means either a lot of duplicated code,
>> or a very difficult problem...
>>
>> I was also hoping to overcome the pointer-to-base container issue
>> also, but thought it was best to take one step at a time. :)
>
>
> OK, so the first solution I mailed is still based on pointers. Does
> that work for you?
>
After re-reading your email, I realise that I misinterpreted it -- the
version you suggested, using references instead of pointers, should
work, since it does not modify my hierarchy.
-- However, since I the structure is a bit more complex, and I need to worry about casting from base pointers etc. later, I want to use the pointer version, as long as it works and behaves correctly. I managed to fix the issue in QRing, without modifying Boost.Geometry. :) Basically, I needed to change the ConstRingIterator : from: typedef RingIteratorImpl<std::vector<QLineString*>::const_iterator, const QPoint*> ConstRingIterator; to: typedef RingIteratorImpl<std::vector<QLineString*>::const_iterator, QPoint* const> ConstRingIterator; and then it woked perfectly. However, I'm not sure if the semantics are right -- shouldn't the QPoint be const as well as the pointer (i.e. const QPoint* const)? When ConstRingIterator is changed to (const QPoint* const), it does not compile (perhaps it is because of lacking specializations (I have defined QPoint* and const QPoint*). I updated my gist with the latest version [1] (a diff userscript is available for convenience, if you're not using git [2]) -- [1] https://gist.github.com/1852693/52eb48965b2d2b2729c51c1da9885722f028dc5b [2] http://www.google.no/search?sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=github+gist+diff <http://www.google.no/search?sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=github+gist+diff> Regards, Mats Taraldsvik > Regards, Barend > > > _______________________________________________ > Geometry mailing list > Geometry_at_[hidden] > http://lists.boost.org/mailman/listinfo.cgi/geometry
Geometry list run by mateusz at loskot.net