Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random small polygons appearing during polygon offset #418

Closed
Eswcvlad opened this issue Feb 22, 2023 · 1 comment
Closed

Random small polygons appearing during polygon offset #418

Eswcvlad opened this issue Feb 22, 2023 · 1 comment

Comments

@Eswcvlad
Copy link

Hello,

I've managed to find another strange issue during my testing. See the image below. Black line is the original polygon. Green is the polygon with a positive offset and red is the polygon with a negative offset.

offset

You can see that there are some random, like 3 or 4 point, polygons from the offsets. Some of them are really bizarre, like one from the negative offset lies outside the original polygon:

image

Here is the C++ code I've used for testing: test.txt

I've also tested on an older d3fbd4a commit and it doesn't seem to have this issue there, so this seems to be related to a relatively recent change.

@AngusJohnson
Copy link
Owner

Hi Vlad.

Here's the fix ...

In ClipperOffset::OffsetPoint() in clipper.offset.cpp (~line 319):

	if (AlmostZero(cos_a - 1, 0.01)) // almost straight
	{
		group.path.push_back(GetPerpendic(path[j], norms[k], group_delta_));
		group.path.push_back(GetPerpendic(path[j], norms[j], group_delta_)); //ADD THIS 
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants