VtkCutter : unexplained behaviour

Hi everyone,
I noticed a behavior of the vtkCutter filter that I can’t explain.
Let’s say I have a very basic planar polydata mesh of 5x5 quads (100m x 100m each) with a hole in the middle. See attachment
mesh.vtk (1.1 KB)

I want to compute the intersection of a cylinder with the mesh with the following code

    x, y = 0., 0.
    radius = 70.
    mesh = # Load mesh

    # Cylindre
    cylfunc = vtk.vtkCylinder()

    # Transformation
    t = vtk.vtkTransform()
    t.RotateX(90) # pour mettre le cylindre vertical
    t.Translate(-x, -y, 0)

    # Filtre
    filtre = vtk.vtkCutter()
    circle = filtre.GetOutput()
    n_cells = circle.GetNumberOfCells()
    print('n_cells', n_cells) # 0 ?!

The computed intersection is empty despite the fact that the cylinder used visually intersects the mesh.
I get the same result in Paraview. I don’t understand why. It looks like a bug to me.

I first used that code on real meshes (ground meshes with holes at the buildings locations, >1e5 cells) and it always worked as expected. So I suspect that strange behavior to come from the limited size of the basic mesh (I noticed that when I started to write unit tests…)

Could you please help me understand what’s happening, and even better help me find a fix to always compute that intersection successfully ?

Thank you in advance


Sorry the mesh uploaded was not the right size (quads are here 1m x 1m instead of 100m x 100m). But the behavior is the same : with a radius of 0.7m (instead of 70m) we should get an intersection, but we don’t. Why ?

Thanks !

Consider implicit modeling an approximation to geometric modelling - it requires reasonable resolution to produce decent results. It is typically used for rapid visualization operations like slicing a dataset with a plane etc.

Implicit modeling is based on “in/out” comparisons of scalar values (in other words, a scalar field based on the implicit function in your case a cylinder) is used. This scalar field is then isocontoured to produce the final result.

Your cylinder is small in comparison to the cells in mesh.vtk. In fact, no points in mesh.vtk are actually inside the cylinder. Thus all points of mesh.vtk are evaluated as “outside” the cylinder. As expected, the result is empty.

If you want precise geometric intersection results, implicit modeling is not the way to go.

1 Like

Thank you Will for taking the time to answer me (and for theses famous handbooks ! ;-)).
Now I get it.

My first idea was to look for a setting to change the level of discretization of the implicit cylinder. But there is none. So I guess it does not work that way.

I guess an idea would be to first subdivide the cells on my mesh in order to add intermediate points on each segment ? But then is there a way to subdivide quads into quads (my mesh is made mostly of quads) or do I have to triangulate my mesh first ? But even that way I know that I can always miss some intersections.

What I really need is not precise intersections but the list of all the cells that a circle is passing through. In a efficient way of course. Would you suggest a better approach ?


This sounds like a selection operation to me. I.e., use rendering to select cells (which also is quite fast). ParaView does this really well. I haven’t played around with the selection mechanism in quite some time so the best I can do is point you in this direction. I’d track down some VTK examples etc, and maybe a community member who is more up to speed can help.

Ok then thank you. Before I close this issue could you please point me to a VTK example showing what you mean by using rendering to select cells.

And what if I wanted a precise computation of the intersection of the circle with each cell ? It seems that several filter do 2D boolean operations but rely on not co-planar meshes ? And I assume boolean operations are more costly

Run, and then study: ~/Develop/LOD/VTK/Rendering/Core/Testing/Cxx/TestAreaSelections.cxx

This shows how to pick cells from an area (rubber band zoom). It could be extended for other graphical selections.

If you want to do more accurate intersections, hunt down Andras Lasso’s vtkbool related posts.

1 Like