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

Z callback not called for new vertex #932

Open
LarsSkiba opened this issue Jan 15, 2025 · 0 comments
Open

Z callback not called for new vertex #932

LarsSkiba opened this issue Jan 15, 2025 · 0 comments

Comments

@LarsSkiba
Copy link
Contributor

LarsSkiba commented Jan 15, 2025

Hello Angus,

during my endeavor to implement offseting of "open path sections" of a closed paths i discovered an unexpected behavior.
It is not explicitly communicated in the documentation, but you can kind of read it like "every vertex which does not map to an input vertex will trigger the z callback". Of course that's just my interpretation.

This leads to an interesting, unexpected side effect with usage of Z coordinates.

Consider this polygon, i attach the point indices as z coordinates:
image

The intermediate solution passed to the simplify looks like this:image

The offset leads to exactly collinear, even identical, edges in the narrow section.
The vertex of interest is at the end of these edges.

The XY coordinates are identical and thus they could be considered the same, the Z coordinates are not.

I think it would be consistent to trigger the z callback during the clean up of this horizontal spike if Z coordinates are used.

Here you can see the data attached to the output of the simplify from my point tracing.

image

I expected to see 2 2 | 5 5 here, because the vertex is the result of the touching end points of the two edges, which i'd call "edges from a point source" (JoinType::Square in this case).

Currently, the Z-coordinate / one of the two input points are chosen arbitrarily.

Here the code reproducing the issue (a z callback needs to be added).

	Clipper2Lib::ClipperOffset offset;
	{
		Clipper2Lib::Paths64 closedPaths = {
			{{0, 0, 0},
			 {268435456, 0, 1},
			 {268435456, 107374182, 2},
			 {536870912, 107374182, 3},
			 {536870912, 161061274, 4},
			 {268435456, 161061274, 5},
			 {268435456, 268435456, 6},
			 {0, 268435456, 7}}};
		offset.AddPaths(closedPaths, Clipper2Lib::JoinType::Square, Clipper2Lib::EndType::Polygon);
	}

	Clipper2Lib::Paths64 solution;
	offset.Execute(-0.100000000000000006 * 268435456, solution);

Regards, Lars

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

1 participant