what is the proper way to cut an actor into two parts in vtk.js

I need to cut a vtkActor, e.g., STL actor, or image Actor or plain polydata actors into 2 actor objects, which can be moved indepandently. However, I’m not sure how this can be done.

using clipPlane can easily ‘cut’ part of the actor, e.g.,

                const clipPlane = vtkPlane.newInstance();
                clipPlane.setOrigin(0, 0, 0);
                clipPlane.setNormal(1, 1, 1); 

but there are two problems:

  1. I don’t get two separate parts as actors
  2. if I move the ‘cutted’ coneActor around with translation or rotation, the cutting plane stays the same, and that ‘cut’ will not work anymore…

I also checked vtkCutter example, it doesn’t give you two cut parts either.


You can have 2 actors with 2 clipping planes (with opposite normal). You would then need to update the planes each time you move the actors.

Alternatively, you can look at vtkClipClosedSurface that has optional “closing”. (set generateFaces to false)

Thanks Julien, that’s very good suggestion.

It also raises a very interesting question, what’s the proper method to clone a vtk.js actor, can they could share the same source data or not.

You have to clone actors manually (create 2 instances).

Yes, they can share the same input data.

Thanks. but there are issues with existing actor properties, e.g., setting the position and especially orientation of the original actor, position can be set with setPosition(), orientation is different, I couldn’t find a good way. getOrientation() may return (0,0,0) although the actor may already been rotated. there are getMatrix() but no setMatrix(), only setUserMatrix(), I suppose these are different and may have unintended side effects somewhere. Color and other things could also be issues. there are shallowCopy() method for actor, seems to be a little buggy for my purpose as I tried.