[vtkusers] Uniformly subdividing a 3D space with points

David Doria daviddoria+vtk at gmail.com
Sun Jan 17 11:58:23 EST 2010


On Sun, Jan 17, 2010 at 10:08 AM, Bryn Lloyd <blloyd at vision.ee.ethz.ch> wrote:
> Hi David,
>
>
> You could try the following:
>
> 1. put your regular grid (e.g. vtkImageData) into a vtkCellLocator.
>
> 2. query for each of your points in the point cloud:
> vtkCellLocator::FindCell(...)
>
> 3. store this information in a way suitable for you, e.g. vtkDataArray for
> the point cloud.
>
>
> BTW. vtkDataSet (and all sub-classes) has its own "FindCell" method, so you
> could skip the vtkCellLocator.
>
>
> Cheers
> Bryn
>
>
>
>
>
> David Doria wrote:
>>
>> I have a point cloud. I would like to break it down into a uniform
>> grid of cubic voxels (axis aligned is fine). That is, I would like to
>> be able to ask "which points are in voxel (i,j,k)?". The only way I
>> know how to do this is to actually create a cube to represent each
>> voxel and then, for each cube, use a vtkSelectEnclosedPoints filter.
>> This seems very "manual" - I'd need to come up with a data structure
>> to store the cubes in this (i,j,k) type format, etc. It seems like
>> there should be a way to divide the space into a grid of cubes all in
>> one shot.
>>
>> Does anyone know of a filter that does this efficiently?
>>
>> Thanks,
>>
>> David
>> _______________________________________________

Ok, seems like we're headed in the right direction. I wanted to make
sure I was using vtkCellLocator correctly, so I tried to use the
GenerateRepresentation function to visualize it. However, GetLevel()
seems to return -1?

http://www.cmake.org/Wiki/VTK/Examples/CellLocator

Assuming it was working, I started building the code for my original question:
http://www.cmake.org/Wiki/VTK/Examples/GridPointCloud

It seems to kind of work... except it always says point 0 is in cell
-1. There shouldn't be negative cell indices, right? So you're
recommending asking which cell every point is in, then storing the
cellId as an array in the PointData? Then I would somehow (how?) query
this PointData array to get all of the point indices that are in a
particular cell?

Also, then I could traverse the cells in linear order, but is there a
way to access them in (i,j,k) notation without simply writing my own
(linear index)->(i,j,k) function?

Thanks for your help,

David



More information about the vtkusers mailing list