# bug in vtkcutter. It does not return cells only points

**URL:** https://discourse.vtk.org/t/bug-in-vtkcutter-it-does-not-return-cells-only-points/1309
**Category:** Support
**Created:** [July 9, 2019, 7:56am UTC](https://discourse.vtk.org/t/bug-in-vtkcutter-it-does-not-return-cells-only-points/1309 "2019-07-09T07:56:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [July 9, 2019, 7:56am UTC](https://discourse.vtk.org/t/bug-in-vtkcutter-it-does-not-return-cells-only-points/1309/1 "2019-07-09T07:56:44Z")

</div>

Dear all,

I have detected a bug in vtkcutter, i want to get the intersection between a plane and an stl and instead of getting edges what i get is points. If i print the cells returns 0, so i can´t use vtkstripper as it returns the same output. And there are parts that even the plane is intersecting there the point is not considerered. The cut is correct but how it returns the data is wrong, I though because the stl is hollow and it is very thin but i extruded the stl and i get the same points with no cells.

Someone has had the same problem?. Any solution?

Thank you

```
//vtkCutter returns the intersection of the plane with a mesh (polydata)
vtkSmartPointer<vtkCutter> clipper =
	vtkSmartPointer<vtkCutter>::New();

     clipper->SetInputData(stl);

```

//The normal to what we cut  
double perpendicular[3] = { v[0],v[1],v[2] };  
perpendicular[2] = 0;  
double\* normalizedX = perpendicular;  
vtkMath::Normalize(normalizedX);

```
vtkSmartPointer<vtkPlane> plane =
	vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(pts1[0], pts1[1], pts1[2]);
plane->SetNormal(normalizedX[0], normalizedX[1], normalizedX[2]);

boolean->AddFunction(plane);
clipper->SetCutFunction(boolean);
clipper->Update();

vtkSmartPointer<vtkPolyData> ClippedpolyData = vtkSmartPointer<vtkPolyData>::New();
ClippedpolyData->DeepCopy(clipper->GetOutput());
ClippedpolyData->Modified();
```

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [July 9, 2019, 10:56am UTC](https://discourse.vtk.org/t/bug-in-vtkcutter-it-does-not-return-cells-only-points/1309/2 "2019-07-09T10:56:37Z")

</div>

I attach a picute with the problem. Thanks ![Screenshot_1](https://discourse.vtk.org/uploads/default/original/1X/788f1367e0a9bf2f3ee57d6e6c01d98be53e2720.png)

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [July 9, 2019, 7:17pm UTC](https://discourse.vtk.org/t/bug-in-vtkcutter-it-does-not-return-cells-only-points/1309/3 "2019-07-09T19:17:04Z")

</div>

The [VTK Examples Project](https://lorensen.github.io/VTKExamples/site/) has several examples that use vtkCutter. For example, see:

1. [ExtractPolyLinesFromPolyData](https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/ExtractPolyLinesFromPolyData/)
2. [FitSplineToCutterOutput](https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/FitSplineToCutterOutput/)

In each of these examples, cells are output.

In the future if you have a question about a class, see if it’s listed in:  
[CxxVTKClassesUsed](https://lorensen.github.io/VTKExamples/site/Coverage/CxxVTKClassesUsed/), [PythonVTKClassesUsed](https://lorensen.github.io/VTKExamples/site/Coverage/PythonVTKClassesUsed/), [JavaVTKClassesUsed](https://lorensen.github.io/VTKExamples/site/Coverage/JavaVTKClassesUsed/) or, [CSharpVTKClassesUsed](https://lorensen.github.io/VTKExamples/site/Coverage/CSharpVTKClassesUsed/).

Enjoy VTK,

Bill

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [July 10, 2019, 8:04am UTC](https://discourse.vtk.org/t/bug-in-vtkcutter-it-does-not-return-cells-only-points/1309/4 "2019-07-10T08:04:20Z")

</div>

Hi !!

Thank you for your quick respoponse and the links. My problem is not the usage of this filter. It is very simple to use. The problem is a bug of this filter

with certain surfaces I printed out the number of lines of the output of the cutter and it returns 0 lines (0 cells). The cut is ok but i would like to obtain lines no disconnected points. I read in other posts that some suraces have problems but they do not get any solution. Any idea?: Thanks

There are 0 lines in the polydata  
-----------Lines using vtkStripper  
There are 0 lines in the polydata

The cut is correct but it only returns disconnected points .

polyData-\>GetPoint(startcut\_position\_curve, pts1);  
polyData-\>GetPoint(startcut\_position\_curve + 1, pts2);  
v[0] = pts2[0] - pts1[0];  
v[1] = pts2[1] - pts1[1];  
v[2] = 0;  
vtkMath::Normalize(v);

```
//The normal to what we cut
double perpendicular[3] = { v[0],v[1],v[2] };
perpendicular[2] = 0;
double* normalizedX = perpendicular;
vtkMath::Normalize(normalizedX);

vtkSmartPointer<vtkPlane> plane =
	vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(pts1[0], pts1[1], pts1[2]);
plane->SetNormal(normalizedX[0], normalizedX[1], normalizedX[2]);

boolean->AddFunction(plane);
clipper->SetCutFunction(boolean);
clipper->Update();

```

auto stripper =  
vtkSmartPointer::New();  
stripper-\>SetInputConnection(clipper-\>GetOutputPort());  
stripper-\>JoinContiguousSegmentsOn();  
stripper-\>Update();

```
	// Extract the lines from the polydata
	vtkIdType numberOfLines = clipper->GetOutput()->GetNumberOfLines();
```
