using vtkIntersectionPolyDataFilter

hello,
I’m having a polyline and I’m trying to convert it to polydata, and then use vtkIntersectionPolyDataFilter
to compute intersection and cutting another mesh.

But I see that polydata doesn’t have GetOutPort.

vtkSmartPointer<vtkPoints> vertices = vtkPoints::New();
	vtkSmartPointer<vtkCellArray> faces = vtkCellArray::New();

	int nVer = pnt.size();// ver.size();
	vertices->SetNumberOfPoints(nVer);

	int nFaces = fac.size();

	vtkIdType* cells_array = new vtkIdType[nFaces * 4];

		for (int i = 0; i < nVer; i+=3)
		{
			
			vertices->SetPoint(i, pnt[i], pnt[i+1], pnt[i+2]);
		}

		for (int i = 0; i < nFaces; i+=3)
		{
			 
			cells_array[i * 4 + 0] = 3;		// 3 is the number of points in this cell (face)
			cells_array[i * 4 + 1] = fac[i];
			cells_array[i * 4 + 2] = fac[i+1];
			cells_array[i * 4 + 3] = fac[i+2];
		}

	vtkSmartPointer<vtkPolyData> pPolyData = vtkSmartPointer<vtkPolyData>::New();

	// construct vtk id type array from raw cells array
	vtkSmartPointer<vtkIdTypeArray> facesArray = vtkSmartPointer<vtkIdTypeArray>::New();
	facesArray->SetArray(cells_array, nFaces * 4, 0, vtkAbstractArray::DeleteMethod::VTK_DATA_ARRAY_DELETE);

	// pass this id type array to the cell array object to initialize it with the manually created cells
	faces->SetCells(nFaces, facesArray);

	pPolyData = vtkSmartPointer<vtkPolyData>::New();
	pPolyData->SetPoints(vertices);
	pPolyData->SetPolys(faces);

	pPolyData->Squeeze();


	vtkNew<vtkIntersectionPolyDataFilter> intersectionPolyDataFilter;
	intersectionPolyDataFilter->SetInputConnection(
		0, pPolyData->GetOutPort()));
	intersectionPolyDataFilter->SetInputConnection(
		1, sphereSource2->GetOutputPort());
	intersectionPolyDataFilter->Update();

I also have another question, how can I use vtkImprintFilter to write to obj file.

You can try:

intersectionPolyDataFilter->SetInputData(0, pPolyData);