|
Geometry : |
Subject: [ggl] Understanding get_turns for linestring/polygon overlay
From: John Swensen (jpswensen)
Date: 2011-02-03 12:28:15
On Feb 3, 2011, at 12:06 PM, barend wrote:
> Hi John,
>
> -----Original Message-----
> I can confirm that it does compile if I remove the call to resize. I don't quite understand what you were saying about .replace and erase. Are you saying that instead of using resize, I could use erase to remove objects at the end if the new size is smaller than the existing size and simply append to the end if the new size is larger than the existing size?
>
> John
>
> Yes, I mean exactly that. I've currently no time, but will look at this this weekend. In this case, it is probably always smaller.
>
> If you still use it only to get the intersection points, you can just leave it commented for a few days, it will not go into the traverse function. Even in traverse, it will in most cases not reach that point. You might set a temporary assertion there to be sure. I mean if the rest compiles fine, you can at least continue with your testing and I can solve this issue later on. Nice that you use it for the iPhone.
>
> Regards, Barend
>
I was going to replace the .resize with the following code, but because I don't ever hit this and can't be sure I have all the indices right, I am just going to put the assert in there as suggested.
std::size_t ringsSize = rings.size();
if (ringsSize > size_at_start) {
rings.erase(rings.end() - (ringsSize-size_at_start),rings.end());
}
else if (ringsSize < size_at_start) {
for (int i = 0; i < (size_at_start-ringsSize); i++) {
typename boost::range_value<Rings>::type current_output;
rings.push_back(current_output);
}
}
I appreciate the quick replies and once I have this polygon cutter code completed, I will give it to you for inclusion in the library (probably after Boostifying it as I am sure my code looks nothing like the Boost standard).
John
Geometry list run by mateusz at loskot.net