Boost logo

Geometry :

Subject: [ggl] Keeping information for points when running algorithms
From: Barend Gehrels (barend)
Date: 2011-11-03 07:50:34


On 2-11-2011 4:57, V D wrote:
> Hi,
> Let's say I have a custom point type (it's a point, but it has flags,
> see code below).
> My problem is that I have some flags on some of those points, and when
> I'm running bg::intersection I am losing those flags, even if the
> point is part of the output, ie: it is not chopped.
> I would have thought that non-chopped points in the intersection would
> have been copy constructed, therefore preserving my flags.
> I'm assuming bg creates new points and just assign the coordinates via
> the setters ?

Yes, I agree with your findings and I also agree with Mateusz answer.

To add something: basically you would expect all points not touched by
the intersection algorithm to be taken over "literally", so here
including the flag. I think it could be implemented like that
(intersection points are of course newly created, but all other points).
However, Boost.Geometry (basically) supports also that your output point
type is different then your input point type. Therefore it does not
copies the point, but calls "append" and append is point-type
independant, so copies them coordinate-wise, as Mateusz answered.

This is actually a pity, because the use case you describe is one we
love to support. One of the intentions of Boost.Geometry is to use own
point types. If their specifics get lost, this "selling point" is
spoiled, partly. It can probably be solved by specialization again, at
the right point; I will look at that. A similar use case is a 3D point
in a 2D intersection, the invidiual height of each point should be
preserved during the intersection (excepted for the intersection points).

Thanks, Barend

Geometry list run by mateusz at