# How to evenly cut the pipe model through the method in VTK

**URL:** https://discourse.vtk.org/t/how-to-evenly-cut-the-pipe-model-through-the-method-in-vtk/10156
**Category:** Support
**Tags:** python
**Created:** [December 11, 2022, 1:20pm UTC](https://discourse.vtk.org/t/how-to-evenly-cut-the-pipe-model-through-the-method-in-vtk/10156 "2022-12-11T13:20:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Dwight98](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dwight98/32/5373_2.png) [@Dwight98](https://discourse.vtk.org/u/Dwight98)
#### Post date: [December 11, 2022, 1:20pm UTC](https://discourse.vtk.org/t/how-to-evenly-cut-the-pipe-model-through-the-method-in-vtk/10156/1 "2022-12-11T13:20:21Z")

</div>

I have a long OBJ model of a mine pipeline, but its direction is not regular in any of the x, y, or z axial directions，I used to use the bounding box to determine the direction of Plane’s cutting for him, but the cut out is still diagonal, do you have any good methods?

supplement：The language I use is python, the method I use is vtkBooleanOperationPolyDataFilter(), and the polydata used for cutting is vtkplane。

---

<div class="post-metadata">

### Author: ![mau\_igna\_06](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mau_igna_06/32/8064_2.png) [@mau\_igna\_06](https://discourse.vtk.org/u/mau_igna_06)
#### Post date: [December 11, 2022, 5:56pm UTC](https://discourse.vtk.org/t/how-to-evenly-cut-the-pipe-model-through-the-method-in-vtk/10156/2 "2022-12-11T17:56:11Z")

</div>

I guess you can use SVD to get the cylinder (i.e. tube) axis… or this code to find the anatomical centerline of a long bone may help also:

> <https://github.com/SlicerIGT/SlicerBoneReconstructionPlanner/blob/8e2ead652c84fb8eb79fa4c270b94a738e400957/BoneReconstructionPlanner/BoneReconstructionPlanner.py#L3182-L3218>

For cutting I would use the Slicer’s Dynamic Modeler tool called Plane Cut. Please see the video [here](https://discourse.slicer.org/t/new-module-dynamic-modeler-parametric-surface-editing-for-biomedical-applications/11759).

If after testing it you find it’s just what you need you would only have to dig the vtk code out from the [Slicer](https://github.com/Slicer/Slicer) or [Dynamic Modeler](https://github.com/Slicer/SlicerSurfaceToolbox/tree/master/DynamicModeler) repositories

Hope it helps

---

<div class="post-metadata">

### Author: ![Dwight98](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dwight98/32/5373_2.png) [@Dwight98](https://discourse.vtk.org/u/Dwight98)
#### Post date: [December 12, 2022, 6:39am UTC](https://discourse.vtk.org/t/how-to-evenly-cut-the-pipe-model-through-the-method-in-vtk/10156/3 "2022-12-12T06:39:00Z")

</div>

> [@mau\_igna\_06](#):
>
> I guess you can use SVD to get the cylinder (i.e. tube) axis… or this code to find the anatomical centerline of a long bone may help also:

First of all, sincerely thank you for your reply, I will consider the help you provided, I will reply later, thank you again！
