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?
The parameters for the IntersectWithLine are derived from vtkCell class. It is a bit buried you can see the detailed description here 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With