[vtk-developers] Line picking

pat marion pat.marion at kitware.com
Sun Jan 24 12:22:56 EST 2010


I think I've figured out why vtkPropPicker doesn't work...   The steps to a
hardware pick are:

-call gluPickMatrix to constrain the rendering area to a small area around
the mouse click.  I think this works by setting the projection matrix to
greatly scale up the scene so only a small area is visible in the viewport.

- set render mode to GL_SELECT and do a hit test

In the opengl spec it says the hit test works by returning a list of
primitives that would have been drawn, but no rasterization steps are
actually performed (no pixel fragments are produced).  Well, rendering lines
with fixed width (10 pixels for example) is an operation that comes during
the rasterization.  It seems there is a limitation to the opengl spec that
you can't pick fixed width lines except by picking the center of the line as
if the line width was 1px (and presumably the same is true for points).

Using vtkCellPicker is an option, but it is not pixel precise, you have to
give it some tolerance.  If you give it a very strict tolerance it will miss
the line in the same way vtkPropPicker does.

It's possible to make the vtkPropPicker work if you set the width of the
pick area to be at least the width of the line (in vtk the pick area is
hardcoded to 1x1), but then vtkPropPicker is acting more like vtkCellPicker,
it has some tolerance.

Another solution is to stop using fixed width lines and represent lines as
cylinders.

Pat

* p.s. I'm no opengl expert, if what I've said is not accurate someone
correct me!


On Sun, Jan 24, 2010 at 11:28 AM, David Gobbi <david.gobbi at gmail.com> wrote:

> Hi Will, Pat,
>
> I've just checked in the new vtkCellPicker as of this morning.  It
> should show up in the nightly doxygen pages tomorrow.  For picking
> lines with vtkCellPicker the trick is setting the tolerance correctly.
>
> What Will says about the data being inconsistent between render & pick
> is something that can also occur with vtkPicker and its subclasses in
> some circumstances.  The vtkPicker expects that all the data was
> updated in the previous rendering pass, so it doesn't call Update on
> the data right before the pick.  If the data has changed between the
> last render and the pick, then it is necessary to either (a) re-render
> just before the pick or (b) go through all the props whose data might
> have changed and update their mappers' inputs.
>
>   David
>
>
> On Sun, Jan 24, 2010 at 5:27 AM, Will Schroeder
> <will.schroeder at kitware.com> wrote:
> > Pat-
> >
> > For now use vtkCellPicker (I'll attached the modified C++ file) it works
> > much better. I believe what's going on is the rendering pass made during
> the
> > picking process is not consistent with the display rendering pass, hence
> the
> > picking is working badly. I'm going to have to dive deeper into this
> which
> > my brain is resisting this being early Sunday morning (and I am in Bar
> > Harbor watching the sunrise :-))
> >
> > Note that David Gobbi is reworking vtkCellPicker and if he hasn't checked
> it
> > in yet, will do so shortly. By using a locator with the new vtkCellPicker
> > you will get great performance. plus more information than vtkPropPicker
> can
> > give you.
> >
> > Let me know if you need more help and I'll give you a call, in the mean
> time
> > I'll back burner the vtkPropPicker for lines.
> >
> > Will
> >
> > On Sat, Jan 23, 2010 at 1:22 PM, pat marion <pat.marion at kitware.com>
> wrote:
> >>
> >> I hacked one of the vtk examples to demonstrate the bug.  Attached and
> >> copied below.  With the bug, it will only print "Pick success" when the
> x
> >> coordinate of the mouse press is 150.
> >
> > ...stuff removed....
> >
> >>
> >> On Fri, Jan 22, 2010 at 1:18 PM, pat marion <pat.marion at kitware.com>
> >> wrote:
> >>>
> >>> Using vtkPropPicker::PickProp it is difficult to pick lines (using a
> >>> vtkLineSource with a vtkPolyDataMapper for example).  Even if I set the
> line
> >>> width to 10 pixels, the pick is only successful if I click exactly in
> the
> >>> center of the 10 pixel band, as if the hardware picker was not
> respecting
> >>> the 10 pixel width.  Can someone that is familiar with this part of vtk
> >>> verify the bug, or point me in the right direction?
> >>>
> >>> Pat
> >>
> >
> >
> >
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtk-developers
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100124/8c91f5f7/attachment.html>


More information about the vtk-developers mailing list