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

**URL:** https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696
**Category:** Web
**Created:** [November 13, 2023, 5:12pm UTC](https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696 "2023-11-13T17:12:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gzt036](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gzt036/32/5960_2.png) [@gzt036](https://discourse.vtk.org/u/gzt036)
#### Post date: [November 13, 2023, 5:12pm UTC](https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696/1 "2023-11-13T17:12:17Z")

</div>

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.,

```auto
                const clipPlane = vtkPlane.newInstance();
                clipPlane.setOrigin(0, 0, 0);
                clipPlane.setNormal(1, 1, 1); 
                coneActor.getMapper().addClippingPlane(clipPlane);

```

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.

> **[vtk.js](https://kitware.github.io/vtk-js/examples/Cutter.html)**
>
> CutterLive example Sourceimport '@kitware/vtk.js/favicon';// Load the rendering pieces we want to use (for both WebGL and WebGPU)import '@kitware/vtk.js/Rendering/Profiles/Geometry

Thanks.

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [November 13, 2023, 5:51pm UTC](https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696/2 "2023-11-13T17:51:46Z")

</div>

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](https://kitware.github.io/vtk-js/examples/ClipClosedSurface.html) that has optional “closing”. (set `generateFaces` to `false`)

---

<div class="post-metadata">

### Author: ![gzt036](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gzt036/32/5960_2.png) [@gzt036](https://discourse.vtk.org/u/gzt036)
#### Post date: [November 15, 2023, 4:51am UTC](https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696/3 "2023-11-15T04:51:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [November 15, 2023, 7:53am UTC](https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696/4 "2023-11-15T07:53:15Z")

</div>

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

Yes, they can share the same input data.

---

<div class="post-metadata">

### Author: ![gzt036](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gzt036/32/5960_2.png) [@gzt036](https://discourse.vtk.org/u/gzt036)
#### Post date: [November 15, 2023, 8:41am UTC](https://discourse.vtk.org/t/what-is-the-proper-way-to-cut-an-actor-into-two-parts-in-vtk-js/12696/5 "2023-11-15T08:41:45Z")

</div>

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.
