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

Holes and T-junctions? #105

Closed
samsonsite1 opened this issue Sep 8, 2018 · 6 comments
Closed

Holes and T-junctions? #105

samsonsite1 opened this issue Sep 8, 2018 · 6 comments

Comments

@samsonsite1
Copy link

Can mapbox earcut completely eliminate T-junctions?
I have an issue where triangulating a polygon with holes is creating T-junctions.

For data:
#104

One of the main reasons why I was looking for a poly tesselator, is to create a triangulation without T-junctions. This is when the vertex lies against an edge, but doesn't connect.

Thanks.

t_junctions

@mrgreywater
Copy link
Collaborator

mrgreywater commented Sep 8, 2018

You could potentially detect those T junction edges in the function earcutLinked, and avoid cutting ears on them in the first pass. You would also need to try to avoid creating these junctions in findHoleBridge.

edit: Looking at the marked edges, I think I misunderstood the issue and this is a duplicate of #74

@samsonsite1
Copy link
Author

Thanks for looking at it. I will have to give the issue more thought.

@samsonsite1
Copy link
Author

samsonsite1 commented Sep 9, 2018

I think you're correct. I should explain my application also goes beyond just rendering. T-junctions are cracks in the model, it prevents certain edge traversing algorithms from functioning properly (e.g. can't walk across an edge).

I haven't encountered a case yet where earcut creates T-junctions without holes, but it seems it's more likely to create them when holes are included.

@mourner
Copy link
Member

mourner commented Sep 9, 2018

Let's close as a duplicate of #74

@mourner mourner closed this as completed Sep 9, 2018
@mrgreywater
Copy link
Collaborator

mrgreywater commented Sep 9, 2018

As a workaround, In case you are sure your polygons are simple, and you're fine with loosing some robustness, you can comment out the area(p.prev, p, p.next) === 0 check in filterPoints so those colinear points are not removed.

@samsonsite1
Copy link
Author

samsonsite1 commented Sep 9, 2018

Thanks, does earcut behave more like GLUtessellator when degenerate triangles are kept?

I used GLUtessellator before, and technically, I would say it doesn't create T-junctions. But, if you run the triangulated polygon through a mesh cleaner that removes degen trigs, T-junctions are created. This is because degen trigs were inserted into the edges during triangulation, which somewhat fixed the issue, but not in the best way.

Perhaps an earcutter needs another level of awareness, not just knowing how points are connected, but how edges are connected too.

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

3 participants