Boost logo

Geometry :

Subject: Re: [geometry] How to register a custom rectangle with additional angle information
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-10-31 18:05:03


Hi Holger,

Welcome to the list!

On 31-10-2012 11:38, Holger wrote:
> Hi community,
>
> I like to use boost::geometry with custom 2D geometry types. Registration of
> points, segments, polygons work so far well by use of the boost registration
> macros. Now I stuck by trying to register a custom rectangle with an
> additional angle information.
>
> My custom rectangle looks something like this:
>
> class rectangleCustom
> {
> private:
> int m_Left;
> int m_Top;
> int m_Width;
> int m_Height;
> double m_Phi; // This member forces me to use the bg::ring registration
> // and not the easy going rectangle registration :-(
> ...
> }
>
> >From my point of view I have to use the bg::ring registration and store the
> 4+1 point representing an rectangle and map all the points dependent of the
> custom angle information.
> OK, that's my theory so far but to implement this I do not have enough
> knowledge in meta programming etc.
> All the examples at
> http://www.boost.org/doc/libs/1_51_0/libs/geometry/example/
> <http://www.boost.org/doc/libs/1_51_0/libs/geometry/example/>
> did not give me the right hint or I just missed the point.

There is indeed no sample for this. Actually I've not done this or
anything like this myself. But it is probably possible. Indeed you need
a ring. A ring follows the Boost.Range concept, so you need to have it
like a range, exposing an iterator. So you need to create an iterator
yourself, outputting the coordinates in the correct order (so e.g.
lowerleft, upperleft, upperright, lowerright), all calculated on the fly
(ideally - might also be stored) from your input. Then you are there.

Regards, Barend


Geometry list run by mateusz at loskot.net