bug in vtkcutter. It does not return cells only points

(ester) #1

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();
(ester) #2

I attach a picute with the problem. ThanksScreenshot_1

(Bill Lorensen) #3

The VTK Examples Project has several examples that use vtkCutter. For example, see:

  1. ExtractPolyLinesFromPolyData
  2. 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, PythonVTKClassesUsed, JavaVTKClassesUsed or, CSharpVTKClassesUsed.

Enjoy VTK,

Bill

(ester) #4

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();