VTK/New CellPicker: Difference between revisions
m (VTK/Volume Picking moved to VTK/New vtkCellPicker: Most of the features on this page are part of the new vtkCellPicker) |
No edit summary |
||
Line 1: | Line 1: | ||
The | 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 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. 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. | This new class is based on the vtkVolumePicker that was added to VTK cvs by David Gobbi of Atamai Inc. on November 25, 2009. | ||
[[Image:VolumePicker-crop.png|right|200px|VolumePicker regression test image.]] | [[Image:VolumePicker-crop.png|right|200px|VolumePicker regression test image.]] | ||
Line 7: | Line 7: | ||
== New Features == | == New Features == | ||
The | 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 Cell Id, Sub Id, and PCoords. | ||
Line 21: | Line 21: | ||
* The ClippingPlaneId to identify the index of the clipping plane that was intersected by the ray | * 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 | * The CroppingPlaneId to identify which of the vtkVolumeMapper cropping planes was intersected | ||
Line 30: | Line 33: | ||
* The current cvs code does a ray-cast with <del>nearest neighbor</del> linear interpolation. | * The current cvs code does a ray-cast with <del>nearest neighbor</del> linear interpolation. | ||
* The VolumeOpacityIsovalue is compared against the scalar opacity | * 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) | * 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. | * The normal of the surface is computed from the gradient of the volume. | ||
Line 37: | Line 40: | ||
== Actor Picking Specifics == | == Actor Picking Specifics == | ||
The actor picking works identical to vtkCellPicker with three exceptions: | 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. | * 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. 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. | |||
== ImageActor Specifics == | == ImageActor Specifics == | ||
The image pick simply intersects the displayed image slice. The normal of the slice plane is returned. | 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 == | == 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 == | == Future Possibilities == | ||
Line 55: | Line 62: | ||
* <del>Volume ray-cast with trilinear interpolation for increased pick accuracy.</del> Done. | * <del>Volume ray-cast with trilinear interpolation for increased pick accuracy.</del> Done. | ||
* <del>Support for different volume cropping modes.</del> Done. | * <del>Support for different volume cropping modes.</del> Done. | ||
* <del>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.</del> Done. The superclass of vtkVolumePicker is | * <del>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.</del> Done. The superclass of vtkVolumePicker is the new vtkCellPicker. | ||
* <del>Allow Locators to be provided via an AddLocator method, so that picking of large polydata objects can be done efficiently.</del> Done. | * <del>Allow Locators to be provided via an AddLocator method, so that picking of large polydata objects can be done efficiently.</del> Done. |
Revision as of 17:57, 25 January 2010
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 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. 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.
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.
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 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 picker 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
Volume ray-cast with trilinear interpolation for increased pick accuracy.Done.Support for different volume cropping modes.Done.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 the new vtkCellPicker.Allow Locators to be provided via an AddLocator method, so that picking of large polydata objects can be done efficiently.Done.