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

Improve robustness of mesh/mesh intersection #286

Merged
merged 7 commits into from
Nov 13, 2024
Merged

Conversation

sebcrozet
Copy link
Member

@sebcrozet sebcrozet commented Nov 12, 2024

This PR further improves the robustness the mesh/mesh intersection for a better handling of pars of meshes with coplanar triangles. This was motivated by the need to fix a case where the same mesh would be cut multiple times by the exact same second mesh. All cuts except for the first one result in degenerate cases where many triangles are coplanar.

This applies the following changes:

  • Fix an issue where the orientation of a triangle output by the convex-polygons intersection algorithm, when given one triangle fully inside the other, is incorrect.
  • Fix an issue where coplanar triangles could be output twice by the mesh/mesh intersection code.
  • Improve robustness of convex-polygons intersection by avoiding the incorrect in-out state to be set when traversing an ambiguous configuration (when a point of one polygon lies exactly on an edge of the other polygon).
  • Fix an issue where the vertices of both polygons might be output by the convex-polygons intersection algorithm if one triangle is fully inside the other but has its vertices exactly on the edges of the other polygon.

Tolerances can now be specified for the mesh/mesh intersection (the method has been made public), and for the convex-polygons intersection.

The variable names in convex-polygons intersection have be changed for better readability.
Note that this introduces a O(n²) complexity for the case where a polygon is fully inside the other one. This can be addressed in a future PR.

@sebcrozet sebcrozet merged commit 4654845 into master Nov 13, 2024
7 checks passed
@sebcrozet sebcrozet deleted the more_mesh_mesh_fixes branch November 13, 2024 11:03
sebcrozet added a commit that referenced this pull request Nov 19, 2024
* fix: don’t insert duplicate triangles in mesh/mesh intersection

* feat: make intersect_meshes_with_tolerances and MeshIntersectionTolerances public

* fix some edge-cases of convex polygons intersections + rename its variables for better readability

* chore: add docs to the MeshIntersectionError variants

* chore: update changelog

* feat: switch to a deterministic hashmap in the mesh intersection algorithm

* chore: cargo fmt
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

Successfully merging this pull request may close these issues.

2 participants