|
Boost : |
Subject: Re: [boost] [Review] GGL review starts today, November 5th
From: Pierre Morcello (pmorcell-cppfrance_at_[hidden])
Date: 2009-11-22 13:23:52
Hi Barend,
Thanks for your answer.
Concerning the result of an intersection and using or not a variant :
Barend wrote:
>>>>Another option, still using a variant, is having the output iterator
adding variants. In this way all output of the intersection, points,
lines and polygons, are just append to e.g. a vector of variants.
This is what I had in mind. But reading your points, I came to the conclusion that it was far from good, and that something simplier could even work : instead of a variant, a tuple of back_inserter could do the trick very nicely.
vector<point2D> myPoints;
vector<line2D> myLines;
vector<polygon2D> myPolygons;
typedef tuple<vector<point2D>, vector<line2D>, vector<polygon2D> > AFakeTupleType;
intersection_inserter<AFakeTupleType>(poly1, poly2, make_tuple(back_inserter(myPoints), back_inserter(myLines), back_inserter(myPolygons));
Please note there is no object of type AFakeTupleType constructed. This type is just used to drive the algorithm.
The output can be dispatched to different vectors, and the input is still 1 object. Then, the user can simply check the lenght of each result to check if there was an intersection.
You already use tuple, so maybe references wrapper in AFakeTupleType would be needed to make the distinction with your other tuple.
What do you think of that? Do you see any drawbacks?
Best regards,
Pierre
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk