[vtkusers] vtkPlotPoints GetNearestPoint data index?

Keith Fieldhouse keith.fieldhouse at kitware.com
Fri Jun 4 10:48:16 EDT 2010


Marcus is traveling today, I'll try to help out.

Roughly, yes, you do need to sort the points.  The problem with simply
searching through unsorted possibilities is that there's unlikely to be an
exact match and you need the best possible candidate for a match.  You
wouldn't be sure if there's a better candidate "down the line".

You will need to devise someway to keep your points and the index together
during the process.  In vtkPlotStacked.cxx (in the current VTK tree) I had
to do something similar with the upper and lower extent of the "stack".  I
cheated a little by using a vtkVector3f and treating the lower/upper bounds
as two "dimensions" but the idea is roughly the same.


On Fri, Jun 4, 2010 at 9:46 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:

> Hey Marcus,
> I'm trying to figure out how to alter your scatter plot code to get a hover
> tooltip which has more data-specific info, not just the point position. (In
> this case I want try displaying an image associated with the point, and I
> need the pedigree ID of the point to know which image to retrieve.) I'm
> curious if you can think of an easy way to get back the row index (or
> pedigree id, or something) for the hovered-over data point, and not just its
> position?
> In the current implementation you call vtkPlotPoints::GetNearestPoint()
> from vtkChartXY::LocatePointInPlots(), and it uses vtkstd::lower_bound() on
> a sort()-ed vector of positions. Is this method a lot faster than just
> stupidly traversing all the points until you find a hit? (As you can tell,
> I'm not a C++ expert.)
> To use the stl sort() and lower_bounds(), it seems like I would have to
> move to storing the row index along with the position vectors and sort them
> together to get back the index of the closest point. Otherwise, I guess I
> could make a new routine that just traverses in the original row index
> order.
> Off the top of your head, do you have a feeling for which would be best to
> try, or perhaps another idea of how to get back the original index?
> Thanks a lot,
> -Eric
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
> _______________________________________________
> 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
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100604/d9ed3379/attachment.htm>

More information about the vtkusers mailing list