Polyline inside rect intersection = Empty? #460
Answered
by
AngusJohnson
DasUberbadger
asked this question in
Q&A
Replies: 3 comments 1 reply
-
|
There are some differences, maybe hold off this Q until I've merged in latest and checked if it's still happening. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
OK, updated to latest Clipper2 from the repo - same result though, empty polytree :( |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
DasUberbadger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I've been using Clipper2 to clip OpenStreetMap vector data to a tile bounds and am finding it regularly returns an empty solution for polylines which are completely enclosed by a tile's bounds.
Here's a real-world-data example, (all int64) with:
An open line added as subject with points (3172, 2361) to (3168, 2381)
A closed rect added as clip with points (0,0), (4096, 0), (4096, 4096), (0,4096)
Clip called via Execute with clip type Intersection and fill rule NonZero gives me a successful clip, but an empty polytree.
This isn't consistent, for the most part the returned polytrees are correct for both enclosed and overlapping polylines of various lengths, but every now and again, such as the above example, I get nothing.
Any ideas? Has anyone encountered anything like this? Or - and this is quite likely - am I doing something dumb/missing something in the setup?
Test code is as follows:
Clipper2Lib::Paths64 subjects;
Clipper2Lib::Paths64 clip;
Clipper2Lib::Paths64 solution;
Clipper2Lib::Path64 Path;
Path.push_back(Clipper2Lib::Point64(0,0));
Path.push_back(Clipper2Lib::Point64(4096, 0));
Path.push_back(Clipper2Lib::Point64(4096, 4096));
Path.push_back(Clipper2Lib::Point64(0, 4096));
clip.push_back(Path);
Clipper2Lib::Path64 part;
part.push_back(Clipper2Lib::Point64(3172, 2361));
part.push_back(Clipper2Lib::Point64(3168, 2381));
subjects.push_back(Part);
Clipper2Lib::Clipper64 Clipper;
Clipper.AddOpenSubject(subjects);
Clipper.AddClip(clip);
bool bSucceeded = false;
Clipper2Lib::PolyTree64 LineSolution;
bSucceeded = Clipper.Execute(Clipper2Lib::ClipType::Intersection, Clipper2Lib::FillRule::NonZero, LineSolution);
and LineSolution comes up as size 0.
Oh - of course it's pertinent that this that this is part of the Unreal 5 codebase so could be missing a more recent fix or something. Going to go and have a compare with latest Clipper2 in github.
Beta Was this translation helpful? Give feedback.
All reactions