VTK/New CellPicker: Difference between revisions
Line 41: | Line 41: | ||
* The picker will ignore any portions of the data that are outside of the ClippingPlanes of the mapper. | * 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 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. | * A locator can be specified with the AddLocator() method to speed up picking. Only vtkCellLocator has been tested so far. | ||
== ImageActor Specifics == | == ImageActor Specifics == |
Revision as of 23:34, 1 December 2009
The new class vtkVolumePicker 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. 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 vtkCellPicker but also returns the closest point within the picked cell. 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 was added to VTK cvs by David Gobbi of Atamai Inc. on November 25, 2009.
New Features
The vtkVolumePicker provides a superset of the functionality of 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
- 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.
Volume Picking Specifics
Volume picking is achieved by shooting a ray through the volume and identifying an isosurface.
- The current cvs code does a ray-cast with
nearest neighborlinear interpolation. - The VolumeOpacityIsovalue is compared against the scalar opacity
and gradient opacityin order to locate the surface. If the IgnoreGradientOpacity flag is set to Off, then the product of the gradient opacity and scalar opacity is used. - 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 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.
ImageActor Specifics
The image pick simply intersects the displayed image slice. The normal of the slice plane is returned.
Caveats
Like the vtkCellPicker, this picker does not work efficiently on long triangle strips. When you prepare data with vtkStripper, use a MaximumLength of around 10.
Incomplete
- For volumes, only the Subvolume cropping method is supported.
Future Possibilities
Volume ray-cast with trilinear interpolation for increased pick accuracy.Done.- Support for different volume cropping modes
Create a superclass that has no dependencies on the VolumeRendering kit. The CroppingPlanes feature is the only feature that needs the VolumeRendering kit, and it would be good to have all other functionality available within Rendering.Done. The superclass of vtkVolumePicker is vtkSurfacePicker.Allow Locators to be provided via an AddLocator method, so that picking of large polydata objects can be done efficiently.Done.