[vtkusers] Determine which points are inside of a cell

David Gobbi david.gobbi at gmail.com
Mon Apr 12 17:01:41 EDT 2010


On Mon, Apr 12, 2010 at 2:42 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> Hi David G,
>
> Thanks for your very detailed response.
>
> I apologize if my terminology was clunky. What I am trying to do here
> is determine which points (from a polydata) are inside of a grid of
> cubes. Am I correct that these cubes are the cells of the ImageData,
> and the corners (or centers?) of the cubes are the points of the
> ImageData? If this is correct, then since I am interested in which
> cube, I think I am indeed looking to use the FindCell function.

Usually when I say "voxel", I mean a little cube with the data point
at the center.  Since the vtkVoxel has the data points at the corners,
it is usually not what I want if I want a voxel.


> It has quite a beast of a signature:
>
> virtual vtkIdType vtkDataSet::FindCell  (       double  x[3],
> vtkCell *       cell,
> vtkIdType       cellId,
> double  tol2,
> int &   subId,
> double  pcoords[3],
> double *        weights
> )
>
> Maybe you can check/fill in these parameter explanations:
>
> - double x[3] : the point in question (the point we want to know which
> cube it falls inside of)
>
> - vtkCell* cell : a point to the actual cell that is found
>
> - vtkIdType cellId: is this the same value that is returned by the
> function? If so, that seems very odd.

This should be set to an "initial guess" of the cellId.  So you can
just set it to zero.

> - double tol2: what is a reasonable value for this?

Somewhere between 1e-3 and 1e-6 is typical.

> - int & subId : I assume I'll never use this so I'll just pass it a
> variable to make it happy and then never use it

Yup.

> - pcoords : not used for this type of query
>
> - weights : also not used for this

Just pass an empty array for pcoords and (I think) a NULL for weights.

> Could we add a
>
> virtual vtkIdType vtkDataSet::FindCell  (double         x[3])

Yes, I think that this is a good idea and I can't say why it isn't
there.  But I have no power to make decisions over low-level
interfaces like that.  You'll have to try to catch the attention of
one of the Kitware leads.


> Also, could we add a function "FindPointsWithinVoxel" (or maybe voxel
> is again bad terminology) which calls FindPointsWithinRadius (with the
> radius = the diagonal length of the cube)and then loops through to
> remove points outside of the cube but inside of the sphere?

Let's see what people think.  It's probably too late, though, because
and adding a new methods like "PointsWithinBounds(double bounds[6]) or
PointsWithinBox(double p[3], double size[3]) would require changes to
each and every point locator subclass.  We're about talking a lot of
work.

   David



More information about the vtkusers mailing list