Fix vtkCutter and add test for ContourLoopExtraction - #3637
Conversation
|
Does it mean the VTK C++ implementation also has the problem ? If so, please report a bug in VTK |
Fix bug in vtkCutter where the output would be invalid if the cutting plane intersecting a point of the input mesh
Change initial values and bounds of example's parameters to allow exploring the mesh properly
I didn't look into the C++ implementation but it does not produce this invalid result, I used a local python vtk as a truth test. |
sankhesh
left a comment
There was a problem hiding this comment.
LGTM with a couple of questions
| [0.0, 0.0, -0.7], | ||
| [0.0, 5.0, 0.0], | ||
| ]; | ||
| const expectedNbLoops = [2, 0, 3, 1]; |
There was a problem hiding this comment.
Why not test all 5 loops?
| for (let i = 1; i < it.cell.length; i++) { | ||
| const sideCurrentPoint = cellPointsScalars[i] > 0; | ||
| for (let i = 0; i < it.cell.length; i++) { | ||
| if (i === firstPointIdx) { |
There was a problem hiding this comment.
This new sign()-based crossing detection is definitely better than what we had before but I'm curious what would happen if all points of the cell are exactly on the cut plane? I'd assume firstPointIdx remains null. It might be a good test case too.
Isn't the vtkCutter JS implementation a port of the VTK C++ implementation ? Maybe it would be wise to check how it differs... |
Context
vtkCutter yields invalid results if the plane intersects a point of the cut mesh. This is visible on vtkContourLoopExtraction's example where the loop extraction returns 8 loops (visibly 3: pink, green, pink but each actually has multiple layers under).
Results
By properly handling cases where the plane intersects a point, we can fix the issue and have only 2 loops (red and green):
Changes
Properly differentiate the 3 cases: negative sign, null sign (on plane) and positive sign
Dedupe points, result of a same point being counted twice.
For the green triangle, intersected in one of its vertices by the red plane, 2 edges will be counted as intersected on the same position.
Added a non-regression test on ContourLoopExtraction
Modified ContourLoopExtraction example's parameters to fit with the model's bounds.
PR Checklist