Cut one actor by another actor

Hi,
I use vtk.js where I show how one object will be in the stone with inclusions.
I have two ply actors. One actor will be in second 100%. I want to cut all what not inside second actor?
Is it possible?
Mb, possible convert polygons to planes?

I can’t find it in the documentation.

You can probably use the ClipClosedSurface filter to do that.

@Sebastien_Jourdain
Thanks for answer.
Can you help me how to create a clippingPlanes for vtkClipClosedSurface?

I have a situation where I can’t get input connection - it is null

stoneInfo.mesh.forEach((meshItem) => {
        const filter = vtkClipClosedSurface.newInstance({
          clippingPlanes:[] // where to get it from another actor?
        });
        const mapper = meshItem.getMapper()

        filter.setInputConnection(mapper?.getInputConnection() as vtkPipelineConnection);

        filter.setScalarModeToNone();
        filter.update();
        const filterData = filter.getOutputData();

        mapper?.setInputData(filterData);
      });

Small update: I fix all problems with filter, but now I have problem with planes:
I create a vtkPlane by points of object:

const points = item.actor.getMapper()?.getInputData()?.getPoints()?.getData();
      const planes:any[] = []
      for (let i=0;i<points.length-3 || 0; i++){
        const point1 = points[i];
        const point2 = points[i+1];
        const point3 = points[i+2];
        planes.push(
          vtkPlane.newInstance({
            origin: [point1,point2,point3],
            normal: [1.0, 0.0, 0.0],
          })
        )
      }

But something went wrong and it is not works

I don’t understand why you create as many plane as you have points then also I don’t know what does not work. You did not share the error or anything else. At that point we can only guess…

Also the way you create your points are as follow
o0 = x0, y0, z0
o1 = y0, z0, x1
o2 = z0, x1, y1
o3 = x1, y1, z1

So, easiest:
I have a stone and inclusion: Screenshot-2023-03-29-at-17-26-30 hosted at ImgBB — ImgBB
It is 2 Actors
I want to cut inclusions, what not in the stone.
I try to use vtkClipClosedSurface, but it need planes. I try to use points for create a planes for vtkClipClosedSurface (As I understand, I made mistake in the normals calculation)
Now I got like this Screenshot-2023-03-29-at-17-31-31 hosted at ImgBB — ImgBB

It seems to be a strait forward problem to solve and I still don’t understand your remaining problem.

Last question:
meshItem.getMapper().getInputData().getPolys().getNumberOfCells() provide me 252056 elements
if I request meshItem.getMapper().getInputData().getPolys().getCell(0) - I got [0, 1, 2] array
If I request meshItem.getMapper().getInputData().getPolys().getCell(2) - I got [2] array
Am I right understand number in the array - it is a number of point?
Is it possible to have 1 point in the poly?

What’s happen here:
meshItem.getMapper().getInputData().getPolys().getCell(252057) // return me a big array.

How normally get poly and his dots.

Thanks, Sergei