[vtkusers] Creating an ImageData from the bounds of a PolyData
David Doria
daviddoria+vtk at gmail.com
Tue Dec 8 17:17:01 EST 2009
On Tue, Dec 8, 2009 at 4:53 PM, Jérôme <jerome.velut at gmail.com> wrote:
>>
>> Jerome,
>>
>> Have you put this anywhere? It seems like a reasonable thing to add to
>> VTK, no?
>>
>
> Mmmmm yes... Attached, with my previous mail ;)
> I think I will put it in my soon-very-soon-ready-for-diffusion Chiron module
> (http://github.com/jeromevelut/Chiron). I will advertise this medical
> imaging ParaView plugin... soon.
>
>>
>> Another thing - how do you get the coordinates of the center of a cell
>> in an ImageData? The
>> vtkCell* GetCell(vtkIdType cellId)
>>
>>
>> seems to be linearly indexed, why does
>>
>> vtkCell* GetCell(int i, int j, int k)
>>
>> not exist?
>>
>
> I don't use the vtkCell object. I use the scalar pointer for data traversal.
> The point Idx is linear, but you can easily compute the image coordinate
> from the id (and vice-versa) if you know the number of scalar components and
> the extent. In the same way, David G -too much David here... I will name you
> all Jerome in the futur- gave you the function that computes image_id[i,j,k]
> from world_coord[x,y,z]. It is also reversible.
>
> I think that some helper functions exist in vtkImageData for these
> translations, but I cannot remember which.
>
>>
>> Thanks,
>
> You are welcome, Jerome
>>
>> David
>
>
> Jerome
Yes, I saw the files in the email, haha.
Based on what David G explained, I believe I have setup the ImageData
correctly. Of course it is reversible, but then you still have to deal
with all the nonsense every time you write code to do something like
this. I am suggesting that it should be included with the vtkImageData
class. When you ask for the cell/voxel center, there is even more of a
mess that shows up in the form of spacing/2 in all dimensions to get
from the corner of the cell to the center of the cell. This mess
should be dealt with/though about only once and then wrapped into
nice, intuitive accessors for users.
You mentioned the image iterator - I tried to make an example:
http://www.vtk.org/Wiki/VTK_Examples_vtkImageIterator
But it is giving me linking errors - is there a different library I
need to link to? Or have I just used it incorrectly? Jerome, would you
mind tweaking this example or explaining how you use it so I can fix
it? It seems to be very different than most VTK objects as the tests
show it being instantiated with "new vtkImageIterator" rather than the
typical ::New() that VTK provides - why is that?
Thanks,
David
More information about the vtkusers
mailing list