vtkStaticCellLocator throws error on IntersectWithLine

I am trying to intersect a polydata ( tri mesh) with a line, I am using vtkStaticCellLocator filter as follows

vtkSmartPointer< vtkStaticCellLocator> pCellLocator = vtkSmartPointer<vtkStaticCellLocator>::New();
pCellLocator->SetDataSet( polyData );
pCellLocator->BuildLocator();

vtkSmartPointer<vtkPoints> pPoints = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New();
pCellLocator->IntersectWithLine( fStartPoint, fEndPoint, pPoints, idlist );

Results the following error

ERROR: In C:\VTK-9.0.1\Common\DataModel\vtkAbstractCellLocator.cxx, line 96
vtkStaticCellLocator (000001E8223F8BB0): The locator class - vtkStaticCellLocator does not yet support this IntersectWithLine interface

Thanks!

It looks like someone implemented the specialized method IntersectWithLine( fStartPoint, fEndPoint, pPoints, idlist ) in one of the subclasses of vtkAbstractCellLocator, but did not also implement it in some of the other subclasses. Generally not a good idea, hopefully it wasn’t me :slight_smile:

Look in vtkCellLocator / vtkStaticCellLocator. There are other versions of IntersectWithLine that are implemented e.g,

vtkCellLocator::IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t,
double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell)

If you are ambitious, add the missing IntersectWithLine to vtkCellLocator and/or vtkStaticCellLocator.