Box clip with vtkTableBasedClipDataSet and sharp edges?

The vtkBoxClipDataSet is great, however, it produces a triangulated mesh outside of the clipping box much like the vtkClipDataSet filter as discussed in the thread: Is it possible to turn off triangles on vtkClipDataSet filter?

I’m wondering how I might perform a box clip with the vtkTableBasedClipDataSet filter to avoid mesh triangulation. For example, a typical BoxClip of ImageData looks like this:

import vtk
...
alg = vtk.vtkBoxClipDataSet()
alg.SetBoxClip(xmin, xmax, ymin, ymax, zmin, zmax)
alg.SetInputDataObject(dataset) # pass image data in this example
alg.GenerateClippedOutputOn()
alg.Update()
result = alg.GetOutputDataObject(1)
...
# Plot result

Then you could try to do the same thing with vtkTableBasedClipDataSet, but the result is a bit curvey:

...
# Make implicit function
box = vtk.vtkBox()
box.SetBounds(xmin, xmax, ymin, ymax, zmin, zmax)

# Perfrom box clip
alg = vtk.vtkTableBasedClipDataSet()
alg.SetInputDataObject(dataset)
alg.SetClipFunction(box)
alg.SetInsideOut(False)
alg.Update()
result = alg.GetOutput()
...
# Plot result

This is super close to what I want - no triangulation - but the box clipped from the dataset is curved along the edges which is not prefered. How would I get sharp edges from vtkTableBasedClipDataSet?

And just in case someone wants to reproduce this:

xmin, xmax, ymin, ymax, zmin, zmax = 5.818, 9.0315 5.818, 9.0315, 5.818, 9.0315

And the ImageData used in this example: uniform.vtk (13.8 KB)

I believe you are seeing the effects of clipping by an implicit box function. The volume is clipped by a scalar field which is defined as the distance from the box. This distance field is only box-like when the cut value is set to 0. To see what the distance field looks like outside the box, see the images in this StackOverflow post.

The box function is effectively evaluated at points in the input data set. The problem is that in general, edges of your box function will not coincide with points in the input grid. In such cases vtkTableBasedClipDatatSet will perform linear interpolation between the points. The linear interpolation fails in the case of the non-linear distance function from the box, and is responsible for the rounded edges you see.

Is there any way to use the vtkTableBasedClipDatatSet filter and have sharp edges exactly like a vtkBoxClipDataSet? My goal is to not triangulate the output mesh where I don’t need to - which is why I’m interested in using the vtkTableBasedClipDatatSet.

Not to my knowledge.

What about “crinkling”? ParaView seems to have this implemented… how might this be done in VTK?:

Crinkling isn’t exactly what I am hoping to do, but its pretty close

ParaView uses vtkExtractGeometry to perform the “crinkle” clip using the following settings:

vtkExtractGeometry::SetExtractInside(1);
vtkExtractGeometry::SetExtractOnlyBoundaryCells(0);
vtkExtractGeometry::SetExtractBoundaryCells(1);
1 Like