# vtkCellLocator::IntersectWithLine() doesn't return the first intersection along the line

This is the mesh in question.

https://gitlab.kitware.com/vtk/vtk/uploads/c9b6ed49d6aac16ed994eec97f28eca3/mesh_small.7z

We're using VTK 9.2.6.

Here's how we create the vtkCellLocator:

```
vtkSmartPointer<vtkPolyData> vtkMesh = IndexedTriangleMeshUtilities::getVtkPoly(*mesh);
auto cellLocator = vtkSmartPointer<vtkCellLocator>::New();
cellLocator->SetMaxLevel(20);
cellLocator->SetDataSet(vtkMesh);
cellLocator->CacheCellBoundsOn();
cellLocator->SetTolerance(0.0);
cellLocator->BuildLocator();
```

We're calling

```
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
double pcoords[3], int& subId, vtkIdType& cellId) override;
```

with

```
p1 = -1.8748457268799541 332.01308322613477 299.32309093391029
p2 = 347.65019753186459 309.85283477012814 265.88698881876672
tol = 0
```

The result found by VTK is this one:

```
Intersection: 20.031 330.624 297.228
Triangle 26563: (18.1446 331.035 296.508) (33.0768 329.622 312.231) (19.2185 329.632 290.548)
Implicit triangle coords: 0.707822 0.113482 0.178696
Intersection as A * x: 20.031 330.624 297.228
Implicit line coord d: 0.0626732
Intersection as p1*d + p2*(1-d): 20.031 330.624 297.228
```

The "Implicit triangle coords" are computed by our own code, not by VTK. But they should be identical to the pcoords.

The correct solution would be the following, which is the first intersection along the line:

```
Intersection: 13.7033 331.025 297.833
Triangle 26562: (2.56194 330.907 290.218) (12.714 331.117 309.127) (18.1446 331.035 296.508)
Implicit triangle coords: 0.211664 0.210474 0.577862
Intersection as A * x: 13.7033 331.025 297.833
Implicit line coord d: 0.0445694
Intersection as p0*d + p1*(1-d): 13.7033 331.025 297.833
```

VTK returns the second intersection along the line.

Now, I'm not 100% sure if you would classify this as a bug, because the documentation of IntersectWithLine doesn't actually specify what that function does in case there's more than one intersection.

But when I look at the source, my understanding is that the algorithm is supposed to return the first intersection along the line.