Calling GetBounds method causes infinite loop
Polygon and line clipping and offsetting library (C++, C#, Delphi)
Brought to you by:
angusj
Running simple code snippet:
Clipper clipper;
Path rectangle;
rectangle << Point64(0, 0) << Point64(100, 0)
<< Point64(100, 100) << Point64(0, 100);
clipper.AddPath(rectangle, ptSubject);
Rect64 bounds = clipper.GetBounds();
causes infinite loop in here:
// clipper.cpp, GetBounds() ...
do {
if (v2.pt.x < result.left) result.left = v2.pt.x;
if (v2.pt.x > result.right) result.right = v2.pt.x;
if (v2.pt.y < result.top) result.top = v2.pt.y;
if (v2.pt.y > result.bottom) result.bottom = v2.pt.y;
} while (&v2 != &v);
I've tried running Execute() method before GetBounds(), but this hasn't fixed the problem either.
Anonymous
Thanks, and yes, it's missing an important step.
Here's what the function should look like (though admittedly I haven't tested it yet) ...
I've tested your changes now. This yields the same infinite loop. But if I change the condition:
to this:
seems to solve the problem and yields correct Rect64.
Oops, sent previous message as anonymous...
Last edit: Andrii Doroshenko 2017-11-23
OK, sorry about that.
This time I've had a proper look and tested too ...
Last edit: Angus Johnson 2017-11-23
Yeah, works like a charm, thanks!