VTK/New CellPicker: Difference between revisions

From KitwarePublic
< VTK
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 52: Line 52:
* A surface normal is computed: If the data has normals, they are interpolated to get the normal.  Otherwise, the polygon normal is computed.
* A surface normal is computed: If the data has normals, they are interpolated to get the normal.  Otherwise, the polygon normal is computed.
* A locator can be specified with the AddLocator() method to speed up picking.  Only vtkCellLocator has been tested so far.
* A locator can be specified with the AddLocator() method to speed up picking.  Only vtkCellLocator has been tested so far.
* If the picker has a texture, then you can retrieve the cell information for the image data that was used for the texture.
* If the actor has a texture, then you can retrieve the cell information for the image data that was used for the texture.


== ImageActor Specifics ==
== ImageActor Specifics ==
Line 67: Line 67:
== Future Possibilities ==
== Future Possibilities ==


* Prefer lower-dimensionality objects when doing a pick, e.g. if a data set has polys, lines, and verts and if the mouse is within tolerance of all three types, then the lower-dimensionality type should have priority.
* Prefer lower-dimensionality cells when doing a pick, e.g. if a data set has polys, lines, and verts and if the mouse is within tolerance of all three types, then the lower-dimensionality cell should have priority.
* Support for picking unstructured grid volumes.  With a CellLocator, this could be done efficiently.
* Support for picking unstructured grid volumes.  With a CellLocator, this could be done efficiently.
* Support for picking MIP volumes.  This is straightforward, just find the brightest voxel that is over the opacity threshold.
* Support for picking MIP volumes.  This is straightforward, just find the brightest voxel that is over the opacity threshold.

Latest revision as of 16:20, 22 August 2012

The vtkCellPicker will shoot a ray into a renderer containing Actors, ImageActors, and Volumes, and will return information about the intersection of the ray with the objects. On Jan 25, 2009 the original Cell Picker, which had existed more-or-less unmodified for over a decade, was replaced by a new Cell Picker that offers enhanced functionality. For vtkVolume objects, it shoots a ray into the volume and returns the point where the ray intersects an isosurface of a chosen opacity. For vtkImageActor objects, it intersects the ray with the displayed slice. For vtkActor objects, it works like the original vtkCellPicker but also returns the closest point within the picked cell and enables the use of vtkCellLocators to speed up the pick. If the object's mapper has ClippingPlanes, then it takes the clipping into account, and will return the Id of the clipping plane that was intersected.

This new class is based on the vtkVolumePicker that was added to VTK cvs by David Gobbi of Atamai Inc. on November 25, 2009. It is part of VTK 5.6 and later releases.

VolumePicker regression test image.

New Features

The new vtkCellPicker provides a superset of the functionality of the old vtkCellPicker and vtkPointPicker. The information it returns is as follows:

  • The Cell Id, Sub Id, and PCoords.
  • The Point Id of the point in the cell that is parametrically closest to the pick position.
  • The IJK indices of the cell if the picked data is vtkImageData.
  • The IJK indices of the point if the picked data is vtkImageData.

Since the pick is a ray-cast that is looking for surfaces in the data, another piece of information returned is:

  • The Normal of the surface that was intersected at the pick position.

The ray-cast will intersect any clipping planes that are used in the mappers, and will return:

  • The ClippingPlaneId to identify the index of the clipping plane that was intersected by the ray

For volumes, you should use the volume-enhanced vtkVolumePicker. It can also return:

  • The CroppingPlaneId to identify which of the vtkVolumeMapper cropping planes was intersected

There is also a flag, PickClippingPlanesOn(), that will cause the pick ray to stop at the clipping planes and return the position and normal of the clipping plane that was intersected. A similar flag, PickCroppingPlanesOn(), only impacts volume picking and causes the pick ray to stop at the last cropping plane, clipping plane, or bounding plane before entering the volume.

Examples

  • VTK/Examples/VolumeRendering/Python/VolumePicker.py
  • VTK/Rendering/Testing/Tcl/PickerWithLocator.tcl
  • VTK/VolumeRendering/Testing/Tcl/VolumePickerCrop.tcl
  • VTK/VolumeRendering/Testing/Tcl/VolumePicker.tcl

Volume Picking Specifics

Volume picking is achieved by shooting a ray through the volume and identifying an isosurface.

  • The pick is achieved by doing a ray-cast with linear interpolation for the pixel at the pick position.
  • The VolumeOpacityIsovalue is compared against the scalar opacity in order to locate the surface. If the UseGradientOpacity flag is set to On, then the product of the gradient opacity and scalar opacity is used, but this is usually detrimental because it makes the isosurface harder to find.
  • If the volume has multiple independent components, then a ray is cast into each and information about the frontmost intersection is returned (untested)
  • The normal of the surface is computed from the gradient of the volume.
  • If the pick cannot penetrate the volume (i.e the outermost point is already above the selected opacity value), then the normal of the cropping plane or clipping plane at that boundary is used.

Actor Picking Specifics

The actor picking works identical to the old vtkCellPicker with three exceptions:

  • The picker will ignore any portions of the data that are outside of the ClippingPlanes of the mapper.
  • A surface normal is computed: If the data has normals, they are interpolated to get the normal. Otherwise, the polygon normal is computed.
  • A locator can be specified with the AddLocator() method to speed up picking. Only vtkCellLocator has been tested so far.
  • If the actor has a texture, then you can retrieve the cell information for the image data that was used for the texture.

ImageActor Specifics

The image pick simply intersects the displayed image slice. The normal of the slice plane is returned, in addition to the the point and cell information at the pick position.

Caveats

  • This picker does not work efficiently on long triangle strips. When you prepare data with vtkStripper, use a MaximumLength of around 10.
  • When picking a vtkLODProp3D, the pick will be done on the mapper corresponding to the PickLODId.
  • Volumes that are rendered from data other than vtkImageData will not be picked properly.
  • Volume picking for RGBA volumes and other multi-component volumes has not yet been tested.

Future Possibilities

  • Prefer lower-dimensionality cells when doing a pick, e.g. if a data set has polys, lines, and verts and if the mouse is within tolerance of all three types, then the lower-dimensionality cell should have priority.
  • Support for picking unstructured grid volumes. With a CellLocator, this could be done efficiently.
  • Support for picking MIP volumes. This is straightforward, just find the brightest voxel that is over the opacity threshold.
  • Volume ray-cast with trilinear interpolation for increased pick accuracy. Done.
  • Support for different volume cropping modes. Done.
  • Allow Locators to be provided via an AddLocator method, so that picking of large polydata objects can be done efficiently. Done.