# Using vtkCutter on vtkPolyhedron cells with large number of vertices ( \> 512)

**URL:** <https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785>\
**Category:** Development\
**Created:** [May 15, 2021, 3:38am UTC](https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785 "2021-05-15T03:38:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scbiradar](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scbiradar/32/346_2.png) [@scbiradar](https://discourse.vtk.org/u/scbiradar)\
**Post date:** [May 15, 2021, 3:38am UTC](https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785/1 "2021-05-15T03:38:58Z")

</div>

I have a CFD dataset consisting of hex and polyhedral cells. When I try to apply vtkCutter using a plane on the dataset, VTK crashes for some polyhedral cells.  
I then found that it was crashing when I tried to cut through a polyhedron which has more than 512 vertices.

I found a similar issue reported on Paraview : [https://www.paraview.org/pipermail/paraview/2017-January/038874.html](https://www.paraview.org/pipermail/paraview/2017-January/038874.html)

I have a simple script which generates a polyhedron as shown below

![polyhedron_10](https://discourse.vtk.org/uploads/default/original/2X/b/bcae8f8202a66da2611d1bd95e41f600b606b188.png)

In the script, I increase the number of the quadrilateral faces on the visible side in the image to increase the total number of vertices of the polyhedron.  
I apply a vtkCutter on the polyhedron and my python VTK script crashes only when I have more than 512 vertices.

I am attaching a polyhedron cell with 514 vertices .  
This polyhedron can be loaded in Paraview 5.4 and applying a slice filter on it crashes Paraview as well.

I am creating a simple polyhedron cell with all planar faces and bounds of the polyhedron are big enough (0,254,0,5,0,5)[polyhedron\_514verts.vtu](https://discourse.vtk.org/uploads/short-url/5K2eZI2QIUYlsIK3CB5zSVTrDDD.vtu) (19.6 KB)

Thanks,  
Santosh

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [May 15, 2021, 10:32am UTC](https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785/3 "2021-05-15T10:32:42Z")

</div>

I reproduce on master. Could you open an issue on our gitlab ?

---

<div class="post-metadata">

**Author:** ![scbiradar](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scbiradar/32/346_2.png) [@scbiradar](https://discourse.vtk.org/u/scbiradar)\
**Post date:** [May 17, 2021, 11:25am UTC](https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785/4 "2021-05-17T11:25:47Z")

</div>

Created an issue at [https://gitlab.kitware.com/vtk/vtk/-/issues/18214](https://gitlab.kitware.com/vtk/vtk/-/issues/18214)

---

<div class="post-metadata">

**Author:** ![Swarna\_Ravali](https://discourse.vtk.org/user_avatar/discourse.vtk.org/swarna_ravali/32/2573_2.png) [@Swarna\_Ravali](https://discourse.vtk.org/u/Swarna_Ravali)\
**Post date:** [September 27, 2021, 11:30am UTC](https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785/5 "2021-09-27T11:30:04Z")

</div>

Hi,  
This message is regarding vtkCutter on vtkPolyhedron with \>512 verts. I am facing a similar issue. In my model I have more than 1000 verts for a polyhedron. Is there any immediate fix?  
I am using Python.  
Any suggestion would be helpful.  
Thanks,  
Swarna.

---

<div class="post-metadata">

**Author:** ![scbiradar](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scbiradar/32/346_2.png) [@scbiradar](https://discourse.vtk.org/u/scbiradar)\
**Post date:** [September 27, 2021, 1:08pm UTC](https://discourse.vtk.org/t/using-vtkcutter-on-vtkpolyhedron-cells-with-large-number-of-vertices-512/5785/6 "2021-09-27T13:08:53Z")

</div>

Hi Swarna,  
You have fix the code in vtkCutter.cxx and then build the C++ binaries and the python bindings for them.

It is just a one line fix though  
In the UnstructuredGridCutter function, you need to replace the following line  
`cellScalars->Allocate(VTK_CELL_SIZE*cutScalars->GetNumberOfComponents());`  
with  
`cellScalars->Allocate(input->GetMaxCellSize()*cutScalars->GetNumberOfComponents());`

Thanks,  
Santosh
