Repository navigation
fix(Intersections): robustness and performance of the intersections inspection - #201
Conversation
When two Section triangles share two vertices, the second shared point was read in mesh1 with its mesh2 index, giving a wrong point and false intersections between adjacent surfaces numbered differently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mesh vertices not linked to a unique vertex all compared equal (NO_ID), so unrelated triangles were seen as sharing vertices. Ignore NO_ID and fall back to mesh vertex indices within the same surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…spection When any surface had no polygon (or any line no edge), the whole model intersection inspection returned without checking anything. Components are now iterated through the AABB trees, which skip empty meshes, and the mesh_tree_ids_ lookups are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With zero or one common vertex, 2D triangles were only tested for crossing edges, so a triangle lying inside another one (or nested in its corner at the common vertex) was not reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A line segment lying in a triangle plane and crossing it is reported as 'parallel' by the segment/triangle detection, which was ignored. It is now an intersection unless the contact is reduced to triangle vertices. The edge0/1/2 tests on the segment position, which can never happen, are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collinear edges are reported as 'parallel' by the segment/segment detection and were ignored, so overlapping or duplicated lines (and lines folding back on themselves) were never reported. model_A1 has 1254 such pairs of duplicated line edges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A vertex shared by two surfaces (same unique vertex) can have slightly different coordinates in each mesh. The exact predicates then saw a tiny crossing at the common corner and reported a false intersection. The second triangle now uses the first mesh points for its common vertices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding the common vertices of each candidate triangle pair made up to 12 model.unique_vertex() calls (uuid hash map lookup + attribute read). The mesh vertex to unique vertex mapping of each surface is now computed once. corbi_tet_mesh 0.61s -> 0.21s, cva/brep_from_topo 1.76s -> 1.33s, fimiston 11.7s -> 8.2s (identical results). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before the segment/triangle tests (up to 12 exact orientations), check if the non-common vertices of a triangle are strictly on one side of the other triangle plane: the triangles can then only touch at their common vertex. cva/brep_from_topo 1.33s -> 1.05s, fimiston 8.2s -> 6.5s (identical results). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inspect_surfaces_self_intersections still traversed the AABB trees of every pair of overlapping surfaces, only to reject every polygon pair in the action. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each surface was tested serially against every embedded line, without checking their bounding boxes first, and nb_embedding_blocks was recomputed for each surface. Overlapping (surface, line) pairs now come from the components AABB trees and are processed in parallel, in the same order as before. No change on the test models (few embedded lines); the cost was quadratic in the number of surfaces and lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e test The two point_triangle_position calls before the segment/triangle detection are covered by it (inside second position, or parallel then end point check). Brute-force check on 2M random integer segment/triangle pairs, including degenerate ones: identical results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
polygon_fan_triangles stored a single triangle inline, so every quad (two fan triangles) allocated for each candidate polygon pair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cpp-Linter Report
|
| check_section_nested_triangles(); | ||
| check_brep_vertices_without_unique_vertex(); | ||
| check_brep_with_empty_meshes(); | ||
| check_brep_common_vertex_with_different_coordinates(); |
There was a problem hiding this comment.
this is a global comment on the commit, do you have an inspector criterion searching if vertices with the same unique vertex are at the same location. If not this should be added
There was a problem hiding this comment.
Yes, it already exists: UniqueVerticesColocation reports unique_vertices_linked_to_different_points, the unique vertices whose component mesh vertices are not at the same location. It is part of the BRep and Section meshes inspectors. This test covers the case where the coordinates differ by less than that criterion's tolerance, so the vertices are valid for it, but the exact predicates still saw a tiny crossing.
…ed check Review follow-up: a straight line made of several collinear edges reports no self intersection, and a comment explains why a single non common vertex is tested for 2D nested triangles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nspector into fix/intersections-review
|
🎉 This PR is included in version 6.12.4-rc.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Robustness and performance fixes for the model and mesh intersection inspections, from a review of OpenGeode-Inspector. There is one commit per fix, and each fix comes with a test in
tests/inspection/test-model-intersections.cpp.Robustness (wrong results)
NO_ID), so unrelated triangles were treated as sharing vertices.mesh_tree_ids_.at()lookups.parallel) was ignored.model_A1has 1254 such pairs of duplicated line edges, so its expected count goes from 13494 to 14748 intest-brepandtest-py-brep.py.Performance (identical results on all benchmark models)
unique_vertex()hash lookups per candidate pair.ModelMeshesIntersections<BRep>timings,inspect_intersections()plusinspect_surfaces_self_intersections(), best of 3:Not done
model_has_intersecting_surfacesand similar are not used by validity.Related
SurfaceMeshIntersections, the 3D segment/segment projection, empty meshes in the model AABB helpers) are fixed in fix(Mesh): robustness fixes found while reviewing OpenGeode-Inspector OpenGeode#1354.🤖 Generated with Claude Code