Question: So I have a point, and create a line in the z axis to see the point of intersection with a certain mesh (to project the point on the mesh on the z axis). 

So I create a vtkCellLocator, but what are each of the paramter of the function? It is not described at all in the documentation : 

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

```

I've tested a bit, and it seems that a0 and a1 are the endpoints of our line, and x is the found intersection point values and cellid the cellid of the intersection point.

What does the rest means? What happens if I have multiple points of intersection? How does it choose the "best" cell of intersection from all the points of intersection?

Answer: 
The parameters for the IntersectWithLine are derived from vtkCell class. It is a bit buried you can see the detailed description [here](https://vtk.org/doc/nightly/html/classvtkCell.html#a66dc048858c0f5e5e00de5175dfcc3e4) for the parameters. The implementation in vtkCellLocator uses this call to `vtkCell::IntersectWithLine` to define the parameters.

> 
> virtual int vtkCell::IntersectWithLine ( const double p1[3],
> const double p2[3], double tol, double & t, double
> x[3], double pcoords[3], int & subId )
> 
> 
> Intersect with a ray.
> 
> 
> Return parametric coordinates (both line and cell) and global
> intersection coordinates, given ray definition p1[3], p2[3] and
> tolerance tol. The method returns non-zero value if intersection
> occurs. A parametric distance t between 0 and 1 along the ray
> representing the intersection point, the point coordinates x[3] in
> data coordinates and also pcoords[3] in parametric coordinates. subId
> is the index within the cell if a composed cell like a triangle strip.
> 
> 
> 

The cellId that is returned is based on the parametric distance to the intersecting cell. So the returned cellId is the cell that minimizes the member function `vtkCell::GetParametricDistance`

> 
> virtual double vtkCell::GetParametricDistance ( const double pcoords[3] )
> 
> 
> 

> 
> Return the distance of the parametric coordinate provided to the
> cell.
> 
> 
> If inside the cell, a distance of zero is returned. This is used
> during picking to get the correct cell picked. (The tolerance will
> occasionally allow cells to be picked who are not really intersected
> "inside" the cell.)
> 
> 
> 

Therefore it should be the cell that intersects the line within the tolerance that is closest to `p1`
Sorry, I don't have a direct answer (well...the `&t` is probably the parameter of the line where the intersection happens, the `cellId` is the id of the found cell and the `cell` is a pointer to the found cell (but you can just use the `cellId` to get it)). But I do have an advice as someone who works with VTK often: use the fact that it is open source - just download the VTK sources and look directly into them to find your answers. Trust me that especially if you plan to work with VTK regularly, this will save you a lot of time in the end. The documentation is sadly sometimes a bit vague :(