[vtkusers] vtkPlotPoints GetNearestPoint data index?

Keith Fieldhouse keith.fieldhouse at kitware.com
Fri Jun 4 11:45:56 EDT 2010


Well, you're going to run into some ugliness shoving an index (a vtkIdType
or int) into, say the Z dimension (a float).  It could work out as a way to
prove that you're on the right track but in the end you'll  probably need to
create the vector of structures you described...


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

> Hey Keith,
> Thanks for the reply and the tip. That's a good idea, cheating with a
> vtkVector3f -- it seemed like it was going to get quite messy trying to
> change it to a vector of structures or some other new class (with my level
> of experience), but taking a quick look at your implementation I think I
> will be able to follow your example in my code.
> Thanks again, that's a big help. You might hear back from me if I get
> stuck. :)
> -Eric
> On Jun 4, 2010, at 10:48 AM, Keith Fieldhouse wrote:
> Eric,
> 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.
> Keith
> 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/7480d3e6/attachment.htm>

More information about the vtkusers mailing list