VTK 8.2.0 vtkIntersectionPolyDataFilter::TriangleTriangleIntersection stack smashing due to numerical error
Following on from issue #17012
This triangle pair does not intersect (they look almost coplanar):
V = [1.5181 3.23314 -14.2567; ...
1.52291 2.49478 -14.3478; ...
1.48537 3.14193 -13.5191; ...
1.56011 1.85889 -15.1692; ...
1.52772 1.75642 -14.4389; ...
1.52291 2.49478 -14.3478];
F = [1 2 3; 4 5 6];
but the code falls into the line-plane intersection tests starting at line 2123 of ./Filters/General/vtkIntersectionPolyDataFilter.cxx.
Using a tolerance of 1e-6, the values within the loop are:
val1: 1, t: 0.999997
val2: 1, t: 0.999967 <----
val1: 0, t: -5.96659e-11
val2: 1, t: 0.999999 <----
val1: 1, t: 0.999967
val2: 1, t: 6.01444e-11
The t values are close to 1 but don't exceed threshold, the ts2 index is never set and causes a segmentation fault later.
The only triangle pairs I have found that have this problem don't actually intersect. So an easy fix is to edit
line 2157 to be: if (index1 > 2 && ts1 < 50) line 2162 to be: if (index2 > 2 && ts2 < 50)
Then it will fall through and return 0 (non-intersecting).