[vtkusers] FindAndGetCell does not behave as expected. Tolerance not respected

Bryn Lloyd lloyd at itis.ethz.ch
Thu May 5 14:57:09 EDT 2011


Hi

 

I was trying to interpolate values at points by locating the containing cell
and using the parametric coordinates. The cells are 2d triangles (z==0).

 

It seems to me that the function vtkDataSet::FindAndGetCell does not work as
expected!

Sometimes points, which are on the edge of a cell are not classified as
inside. I am aware that due to numerical precision reasons this is not
completely robust, but I would expect that if I increase the Tolerance in
the call to FindAndGelCell then I should get a nearby cell. This does not
always happen!

 

After digging in the code I see that this function returns a vtkCell if
following condition in vtkDataSet::FindCellWalk is fulfilled:

 

    if (   (cell->EvaluatePosition(x, closestPoint, subId,

                                   pcoords, dist2, weights) == 1)

        && (dist2 <= tol2) )

      {

      return cellId;

      }

 

 

 

It often happens that cell->EvaluatePosition returns 0 but, the tolerance
condition is true. Therefore, the tolerance does not have any effect. I
think this should be changed to either:

 

    if (   (cell->EvaluatePosition(x, closestPoint, subId,

                                   pcoords, dist2, weights) == 1)

        || (dist2 <= tol2) )

      {

      return cellId;

      }

 

Or, alternatively the tolerance should be passed on to the cell and used to
evaluate if the point is inside or not. This could for instance be done as
follows:

 

if((pcoords[0] > -tol2) 

&& (pcoords[1] > -tol2)

&& (pcoords[2] > -tol2))

  return 1; // i.e. point inside cell

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110505/14de10b8/attachment.htm>


More information about the vtkusers mailing list