[vtkusers] vtkDataSet::FindPoint, vtkExtractVOI and world coordinates?

Cory Quammen cory.quammen at kitware.com
Wed Sep 7 09:32:03 EDT 2016


Elvis,

Have a look at vtkImageData::FindPoint(double x, double y, double z).

It takes into account the image spacing and origin, but will not
correct for any modifications to the position of the vtkVolume you
seem to be using to represent it in the scene.

HTH,
Cory



On Wed, Sep 7, 2016 at 3:10 AM, Elvis Stansvik
<elvis.stansvik at orexplore.com> wrote:
> Den 4 sep. 2016 2:25 em skrev "Elvis Stansvik"
> <elvis.stansvik at orexplore.com>:
>>
>> Hi all,
>>
>> I have multiple volumes in a renderer, positioned above/below each other
>> (like a "string" of volumes) along the Z axis, none of them are
>> intersecting. As the user clicks+drags the mouse in the viewport, I need to
>> capture the mouse position at the start/end positions of the drag operation
>> and convert them to world coordinates. I think I have these parts figured
>> out.
>>
>> Then, I need to search through the list of my volumes (sorted by their end
>> positions in world coordinates), and construct a series of vtkExtractVOI
>> that will extract the selected segments. For volumes that are completely
>> inside the selected area, the vtkExtractVOI will extract the full volumes,
>> but for the start/end volume (which may be the same volume), it will only
>> extract a portion of it.
>>
>> I looked at the vtkDataSet::FindPoint, which I think will give me a linear
>> point ID (not familiar with that from before) for a point given in world
>> coordinates. But how can I convert that to a structured point position that
>> I can use when setting up the extent to use for my vtkExtractVOI?
>>
>> Is the static vtkStructuredData::ComputePointStructuredCoords helper the
>> function I'm looking for? Or is there some other easier way to extract an
>> area of a volume when the area is expressed in world coordinates?
>> (specifically, as a start/end Z position in world coordinates).
>>
>> Here's an ASCII drawing that perhaps explains better what I want to do,
>> the rectangular areas are my volumes:
>>
>> ^  +-----+
>> |  |     |
>> |  | P1  |  <--- User clicks here (world coordinate X, Y, Z)..
>> |  |     |
>> Z  +-----+
>>    +-----+
>>    |     |
>>    |     |
>>    +-----+
>>    +-----+
>>    |     |
>>    |     |
>>    |  P2 |  <--- ..and drags to here (world coordinate A, B, C).
>>    |     |
>>    |     |
>>    |     |
>>    +-----+
>>
>> From this I want to create three vtkExtractVOI, that when combined gives a
>> list of vtkImageData that represents the selected area along the Z axis (in
>> the X and Y direction, everything from the volumes should be included).
>>
>> Thanks in advance,
>> Elvis
>
> I realized my mail above is a little long-winded and unclear. Sorry about
> that. In essence, what I'm asking is how to map an x,y,x (double) point in
> world coordinates to a i,j,k (int) grid position (voxel coordinate) of a
> given volume. I don't want the nearest point, but to return "null" or
> equivalent if the world point does not fall inside any voxel.
>
> I'd also be interested how to do the same but against a plain vtkImageData
> instead of a vtkVolume. For this I assume I'd have to provide some info
> about where in the world the vtkImageData belongs (where/how I intend to map
> it into the scene).
>
> Anyone know what the VTK API for this is?
>
> Thanks in advance,
> Elvis
>
>>
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
Staff R&D Engineer
Kitware, Inc.


More information about the vtkusers mailing list