BioMedIA / MIRTK

The Medical Image Registration ToolKit (MIRTK), the successor of the IRTK, contains common CMake build configuration files, core libraries, and basic command-line tools. Extension packages are hosted by the MIRTK GitHub group at
https://github.com/MIRTK
Apache License 2.0
186 stars 71 forks source link

Fix and extend SurfaceCollisions filter #754

Closed schuhschuh closed 3 years ago

schuhschuh commented 3 years ago

This change fixes mistakes in the SurfaceCollisions filter. A related issue is #753, and both should be merged together.

The projection of triangles with a shared edge to 2D in order to check if both other vertices are on the same side of this edge was implemented incorrectly. Both triangles were projected to a different 2D plane. After initially fixing this, I eventually figured to simply compute the inner product between the vectors from the edge midpoint to each of the two other triangle vertices. An angle of less than 90 degrees means that triangles are folding onto each other.

Similarly, I've added a near-miss collision check for adjacent triangles, which either share an edge or a single vertex. Previously, the SurfaceCollisions filter would only detect intersections in these cases, but not report any collisions.

The current collision detection is somewhat an heuristic still. An algorithm which projects one triangle onto the other and computes the clipped convex overlap polygon would presumably be better. Will look into this later this week or in Dec.

Attention: This change results in slightly different surfaces on the dHCP data than previously. Option adjacent_collision_test exists to disable the added test of near-miss collisions between adjacent triangles, but the changes (bugfix) with respect to the adjacent intersection test remain.

schuhschuh commented 3 years ago

CC @amakropoulos @jcupitt