Set the boundary of the clipping planes when using vtkClipClosedSurface

When using vtkClipClosedSurface, the clipping planes seem to have no boundaries so they will clip something that I don’t want to be clipped. Is there any easy way to solve this.

Unfortunately it is not supported. @dgobbi

I don’t know if you are referring to this, but you can add another 3 planes to form an obb to set limit on the other directions, this is an example that added one plane through the x axis.


code:

const p1 = [0.25, 0.25, 0.25];
const plane4 = vtkPlane.newInstance({
  origin: p1,
  normal: [-1.0, 0.0, 0.0],
});
planes.push(plane4);

In the vtkClipClosedSurface example.

Thank you for your reply. But this is not exactly my case. For example, my model is two spheres on the XOY plane and the clipping plane is the XOY plane. I want the plane clip one of the spheres and not clip the other.

The clipping planes are always infinite planes.

If you want to clip one object, but not the other, then you can separate them with vtkPolyDataConnectivityFilter, then clip just one object, and put them back together with vtkAppendPolyData.

Thank you for your reply. Is there method in vtkPolyDataConnectivityFilter to separate one object into two parts by a plane? For example, I have a “U” shape object and a horizontal clipping plane, I want to clip the left arm but not to clip the right arm. So maybe I need to firstly use a vertical plane to separate the “U” shape object into a right part and a left part?

Yes, separating the arms with a clipping plane should work. The filter vtkClipPolyData can be used for this. Use these vtkClipPolyData methods:

  • GenerateClippedOutputOn() — generate outputs for both sides of the clip plane
  • GetOutput() — to get first result
  • GetClippedOutput() — to get the result from other side of the plane

Another simple question. Are vtkClipPolyData and vtkPolyDataConnectivityFilter accessible in vtk.js? Because I cannot find them on the vtk.js/api page. Thanks a lot!

Hmm, maybe they’re missing from vtk.js. The vtkClipPolyData filter is one of the core filters in VTK C++.

What a pity. Thanks a lot for your reply! :grinning: