<p dir="ltr">Den 7 sep. 2016 3:32 em skrev "Cory Quammen" <<a href="mailto:cory.quammen@kitware.com">cory.quammen@kitware.com</a>>:<br>
><br>
> Elvis,<br>
><br>
> Have a look at vtkImageData::FindPoint(double x, double y, double z).<br>
><br>
> It takes into account the image spacing and origin, but will not<br>
> correct for any modifications to the position of the vtkVolume you<br>
> seem to be using to represent it in the scene.</p>
<p dir="ltr">Thanks Cory, </p>
<p dir="ltr">I did initially find FindPoint, but I was unsure how I can translate the vtkIdType it returns (some sort of index?) into i,j,k voxel coordinate. Do you know?</p>
<p dir="ltr">Since then I've also found vtkImageData::ComputeStructuredCoordinates, which looks similar, but does seem to produce a ijk voxel coordinate. Perhaps that is the function I'm looking for? It's doubly interesting since it has a static variant where I can specify the origin, spacing etc manually, which I might have a need for actually, if I want to do the same computation but don't have access to an actual vtkImageData instance, only its parameters so to speak.</p>
<p dir="ltr">Elvis</p>
<p dir="ltr">><br>
> HTH,<br>
> Cory<br>
><br>
><br>
><br>
> On Wed, Sep 7, 2016 at 3:10 AM, Elvis Stansvik<br>
> <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>> wrote:<br>
> > Den 4 sep. 2016 2:25 em skrev "Elvis Stansvik"<br>
> > <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>>:<br>
> >><br>
> >> Hi all,<br>
> >><br>
> >> I have multiple volumes in a renderer, positioned above/below each other<br>
> >> (like a "string" of volumes) along the Z axis, none of them are<br>
> >> intersecting. As the user clicks+drags the mouse in the viewport, I need to<br>
> >> capture the mouse position at the start/end positions of the drag operation<br>
> >> and convert them to world coordinates. I think I have these parts figured<br>
> >> out.<br>
> >><br>
> >> Then, I need to search through the list of my volumes (sorted by their end<br>
> >> positions in world coordinates), and construct a series of vtkExtractVOI<br>
> >> that will extract the selected segments. For volumes that are completely<br>
> >> inside the selected area, the vtkExtractVOI will extract the full volumes,<br>
> >> but for the start/end volume (which may be the same volume), it will only<br>
> >> extract a portion of it.<br>
> >><br>
> >> I looked at the vtkDataSet::FindPoint, which I think will give me a linear<br>
> >> point ID (not familiar with that from before) for a point given in world<br>
> >> coordinates. But how can I convert that to a structured point position that<br>
> >> I can use when setting up the extent to use for my vtkExtractVOI?<br>
> >><br>
> >> Is the static vtkStructuredData::ComputePointStructuredCoords helper the<br>
> >> function I'm looking for? Or is there some other easier way to extract an<br>
> >> area of a volume when the area is expressed in world coordinates?<br>
> >> (specifically, as a start/end Z position in world coordinates).<br>
> >><br>
> >> Here's an ASCII drawing that perhaps explains better what I want to do,<br>
> >> the rectangular areas are my volumes:<br>
> >><br>
> >> ^ +-----+<br>
> >> | | |<br>
> >> | | P1 | <--- User clicks here (world coordinate X, Y, Z)..<br>
> >> | | |<br>
> >> Z +-----+<br>
> >> +-----+<br>
> >> | |<br>
> >> | |<br>
> >> +-----+<br>
> >> +-----+<br>
> >> | |<br>
> >> | |<br>
> >> | P2 | <--- ..and drags to here (world coordinate A, B, C).<br>
> >> | |<br>
> >> | |<br>
> >> | |<br>
> >> +-----+<br>
> >><br>
> >> From this I want to create three vtkExtractVOI, that when combined gives a<br>
> >> list of vtkImageData that represents the selected area along the Z axis (in<br>
> >> the X and Y direction, everything from the volumes should be included).<br>
> >><br>
> >> Thanks in advance,<br>
> >> Elvis<br>
> ><br>
> > I realized my mail above is a little long-winded and unclear. Sorry about<br>
> > that. In essence, what I'm asking is how to map an x,y,x (double) point in<br>
> > world coordinates to a i,j,k (int) grid position (voxel coordinate) of a<br>
> > given volume. I don't want the nearest point, but to return "null" or<br>
> > equivalent if the world point does not fall inside any voxel.<br>
> ><br>
> > I'd also be interested how to do the same but against a plain vtkImageData<br>
> > instead of a vtkVolume. For this I assume I'd have to provide some info<br>
> > about where in the world the vtkImageData belongs (where/how I intend to map<br>
> > it into the scene).<br>
> ><br>
> > Anyone know what the VTK API for this is?<br>
> ><br>
> > Thanks in advance,<br>
> > Elvis<br>
> ><br>
> >><br>
> >><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>
> ><br>
> > Visit other Kitware open-source projects at<br>
> > <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
> ><br>
> > Please keep messages on-topic and check the VTK FAQ at:<br>
> > <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> ><br>
> > Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a><br>
> ><br>
> > Follow this link to subscribe/unsubscribe:<br>
> > <a href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
> ><br>
><br>
><br>
><br>
> --<br>
> Cory Quammen<br>
> Staff R&D Engineer<br>
> Kitware, Inc.<br></p>