vtkIntersectionPolyDataFilter do not work

The code to reproduce my problem is:

	vtkSmartPointer<vtkLineSource> lineSource = vtkSmartPointer<vtkLineSource>::New();
	lineSource->SetPoint1(0, 0, 0);
	lineSource->SetPoint2(10, 0, 0);

	vtkSmartPointer<vtkTubeFilter> tubeFilter = vtkSmartPointer<vtkTubeFilter>::New();
	tubeFilter->SetInputConnection(lineSource->GetOutputPort());
	tubeFilter->SetRadius(4);
    /////////////////////////////////////////////////////////////////////////////
	tubeFilter->SetNumberOfSides(50); // key code
    /////////////////////////////////////////////////////////////////////////////
	tubeFilter->SetCapping(1);
	tubeFilter->Update();

	vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
	vtkSmartPointer<vtkPoints> vps = vtkSmartPointer<vtkPoints>::New();
	vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
	polygon->GetPointIds()->SetNumberOfIds(3);
	vps->InsertNextPoint(0, 0, 0);
	polygon->GetPointIds()->SetId(0, 0);
	vps->InsertNextPoint(10, 0, 0);
	polygon->GetPointIds()->SetId(1, 1);
	vps->InsertNextPoint(10, 10, 0);
	polygon->GetPointIds()->SetId(2, 2);

	vtkSmartPointer<vtkCellArray> polygons = vtkSmartPointer<vtkCellArray>::New();
	polygons->InsertNextCell(polygon);
	polydata->SetPoints(vps);
	polydata->SetPolys(polygons);

	vtkSmartPointer<vtkTriangleFilter> tri1 = vtkSmartPointer<vtkTriangleFilter>::New();
	tri1->SetInputData(tubeFilter->GetOutput());
	tri1->Update();

	vtkSmartPointer<vtkTriangleFilter> tri2 = vtkSmartPointer<vtkTriangleFilter>::New();
	tri2->SetInputData(polydata);
	tri2->Update();

	vtkSmartPointer<vtkIntersectionPolyDataFilter> intersection = vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();
	intersection->SetInputData(0, tri1->GetOutput());
	intersection->SetInputData(1, tri2->GetOutput());
	intersection->Update();

A bug is reported:

image

However, if I change tubeFilter->SetNumberOfSides(50); to tubeFilter->SetNumberOfSides(49);, everything is OK.

How can I fix this bug? Any suggestion is appreciated~~~

Hi,

Since you’re at it, can you share the stack trace?

regards,

Paulo

@Paulo_Carvalho Thank you for your kindly reply. The stack trace is:

The bug is happened in vtkIntersectionPolyDataFilter::Impl::SplitMesh, line 520.

The cellId is almost -inf.

What are the values of inputIndex and id variables in the second screencap?

They looks like a normal variable.

inputIndex = 0;
id = 3;

It seems like a bug to me. You can report it here: https://gitlab.kitware.com/vtk/vtk/-/issues. But before reporting it, make sure you’re using the latest VTK version.