I have a vtkUnstructuredGrid
that can contain 0D, 1D, 2D or 3D cells, and we need to return the cell containing a 3D point given as input. This works fine for 3D cells, but for 0D/1D/2D we need a tolerance because otherwise the point will almost never lie exactly on the element.
We wanted to use one of the available vtkCellLocator
classes to accelerate this query but none of them uses the tolerance parameter according to the documentation (the parameter is present on the API, but marked as vtkNotUsed
).
So I tried another method, using the FindClosestPointWithinRadius()
API, which should support the tolerance parameter properly and also return the cell corresponding to the closest point found. This seems to work in simple cases (e.g. a dataset entirely made of quads that lie on the same plane) but does not return valid results when the dataset has a more complex structure. Even calling FindClosestPoint()
with no radius (which should consider the entire dataset) does not return valid results in most cases, which doesn’t make any sense to me.
I found that there’s a FindCell()
method on the vtkDataSet
class itself (not sure if this one uses an acceleration structure for the location of the cell, but at this point I just wanted it to work) which takes a tolerance and uses it, so I tried that one as well but with very similar results. Points that lie along the edges of the cell seem to be working, but on the rest of the surface it pretty much always fails. The flat dataset always works though.
I want to understand if this a limitation of the VTK library, or if I’m doing something wrong which is causing this to fail.
I have verified that the datasets I create are correct. In the following image you can see both datasets (step 1 and step 15 of the same animation) exported in ParaView. The location of cells works for the “flat” one and not for the other.
I would upload the dataset files, but “new users can not upload attachments”.
Thanks in advance,
PaoloG