Skip to content

Fix vtkCutter and add test for ContourLoopExtraction - #3637

Open
Jo-Byr wants to merge 3 commits into
Kitware:masterfrom
Jo-Byr:fix-cutter
Open

Fix vtkCutter and add test for ContourLoopExtraction#3637
Jo-Byr wants to merge 3 commits into
Kitware:masterfrom
Jo-Byr:fix-cutter

Conversation

@Jo-Byr

@Jo-Byr Jo-Byr commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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).

Screenshot 2026-09-07 154550

Results

By properly handling cases where the plane intersects a point, we can fix the issue and have only 2 loops (red and green):

image

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.

image

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

  • GitHub Actions CI passed: semantic-release commit messages, lint, and tests
  • Test coverage added
  • Documentation and TypeScript definitions are updated to match these changes

@Jo-Byr
Jo-Byr requested a review from finetjul September 7, 2026 13:58
@Jo-Byr Jo-Byr self-assigned this Sep 7, 2026
Comment thread Sources/Filters/Core/Cutter/index.js Outdated
Comment thread Sources/Filters/Core/Cutter/index.js Outdated
}
}

// Remove duplicate points

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you only remove duplicate cells, not duplicate points, do you ? (when you remove a cell, you are not removing its associated points)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intersectedEdgesList lists intersected edges of the current cell, with associated intersection point. So I'm removing a point of this list so that it's treated as a line and not as a poly with a duplicated point.

Comment thread Sources/Filters/Core/Cutter/index.js Outdated
@finetjul

finetjul commented Sep 7, 2026

Copy link
Copy Markdown
Member

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
@Jo-Byr

Jo-Byr commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Does it mean the VTK C++ implementation also has the problem ? If so, please report a bug in VTK

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.

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