Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLAccuratePicker Class Reference

A cell picker that stays fast when large surfaces are shown. More...

#include <Libs/MRML/DisplayableManager/vtkMRMLAccuratePicker.h>

Inheritance diagram for vtkMRMLAccuratePicker:
Collaboration diagram for vtkMRMLAccuratePicker:

Classes

struct  CachedLocator
 

Public Types

typedef vtkCellPicker Superclass
 

Public Member Functions

virtual const char * GetClassName ()
 
virtual vtkIdType GetMinimumCellCountToIndex ()
 
virtual int IsA (const char *type)
 
int Pick (double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
virtual void SetMinimumCellCountToIndex (vtkIdType)
 

Static Public Member Functions

static int IsTypeOf (const char *type)
 
static vtkMRMLAccuratePicker * New ()
 
static vtkMRMLAccuratePicker * SafeDownCast (vtkObject *o)
 

Protected Member Functions

double IntersectActorWithLine (const double p1[3], const double p2[3], double t1, double t2, double tol, vtkProp3D *prop, vtkMapper *mapper) override
 
bool IntersectDataSetWithLine (vtkDataSet *dataSet, const double p1[3], const double p2[3], double t1, double t2, double tol, vtkAbstractCellLocator *&locator, vtkIdType &cellId, int &subId, double &tMin, double &pDistMin, double xyz[3], double minPCoords[3]) override
 
double IntersectWithLine (const double p1[3], const double p2[3], double tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m) override
 
void UpdateLocators (vtkRenderer *renderer)
 
 vtkMRMLAccuratePicker ()
 
 ~vtkMRMLAccuratePicker () override
 

Protected Attributes

std::map< vtkPolyData *, CachedLocator > LocatorsBySurface
 
vtkIdType MinimumCellCountToIndex { 10000 }
 

Detailed Description

A cell picker that stays fast when large surfaces are shown.

vtkCellPicker tests every cell of every pickable surface unless a spatial locator is registered for that surface's data. Over a large mesh – for example a segmentation closed surface with millions of cells – an un-indexed pick costs O(number of cells), tens to hundreds of milliseconds, which makes per-mouse-move picking (markup dragging, hover read-out) janky.

vtkMRMLAccuratePicker registers and caches a vtkStaticCellLocator for each large, pickable surface in the renderer before every pick, rebuilding a locator only when its surface changes and dropping it when the surface is no longer shown. Picks then become indexed queries. Everything else behaves like vtkCellPicker (same tolerance, picked position, and normal), so it is a drop-in replacement. Picked positions are on the surface of the picked object, whether or not the surface is indexed, unless the ray misses the surface and it is picked within the pick tolerance, for example near its silhouette (see IntersectDataSetWithLine()).

A single instance is meant to be shared per view: vtkMRMLThreeDViewInteractorStyle owns one and exposes it through vtkMRMLInteractionEventData::GetAccuratePicker(), so every widget in the view – and anything else that needs quick localization in world coordinates – reuses one picker and one set of locators.

Definition at line 58 of file vtkMRMLAccuratePicker.h.

Member Typedef Documentation

◆ Superclass

typedef vtkCellPicker vtkMRMLAccuratePicker::Superclass

Definition at line 62 of file vtkMRMLAccuratePicker.h.

Constructor & Destructor Documentation

◆ vtkMRMLAccuratePicker()

vtkMRMLAccuratePicker::vtkMRMLAccuratePicker ( )
protected

◆ ~vtkMRMLAccuratePicker()

vtkMRMLAccuratePicker::~vtkMRMLAccuratePicker ( )
overrideprotected

Member Function Documentation

◆ GetClassName()

virtual const char * vtkMRMLAccuratePicker::GetClassName ( )
virtual

◆ GetMinimumCellCountToIndex()

virtual vtkIdType vtkMRMLAccuratePicker::GetMinimumCellCountToIndex ( )
virtual

◆ IntersectActorWithLine()

double vtkMRMLAccuratePicker::IntersectActorWithLine ( const double p1[3],
const double p2[3],
double t1,
double t2,
double tol,
vtkProp3D * prop,
vtkMapper * mapper )
overrideprotected

Intersect the pick ray with an actor. If the mapper is a vtkMRMLRayCastMapper (it renders a surface without geometry that could be intersected) then the mapper computes the intersection, otherwise the cells of the mapper are intersected as in vtkCellPicker.

◆ IntersectDataSetWithLine()

bool vtkMRMLAccuratePicker::IntersectDataSetWithLine ( vtkDataSet * dataSet,
const double p1[3],
const double p2[3],
double t1,
double t2,
double tol,
vtkAbstractCellLocator *& locator,
vtkIdType & cellId,
int & subId,
double & tMin,
double & pDistMin,
double xyz[3],
double minPCoords[3] )
overrideprotected

Pick the cell that the ray hits.

vtkCellPicker picks cells within the pick tolerance of the ray, at the point where the ray crosses the plane of the cell. Over a curved surface, that can be a cell that the ray misses, in front of the cell that it hits, so the picked position is in front of the surface. With a locator, vtkCellPicker picks the first such cell along the ray. Without a locator, it prefers the cell that the ray passes through, but depending on the order of the cells, it can keep a cell that the ray misses. Instead, search for a cell that the ray hits first, and use the pick tolerance only if the ray does not hit the surface (for example, when it passes just outside the silhouette of the surface), with or without a locator.

Vertices and lines can only be picked within the pick tolerance. If the data set has them along with surface or volumetric cells, then both searches are done, and a vertex or line is picked if it is in front of the cell that the ray hits.

◆ IntersectWithLine()

double vtkMRMLAccuratePicker::IntersectWithLine ( const double p1[3],
const double p2[3],
double tol,
vtkAssemblyPath * path,
vtkProp3D * p,
vtkAbstractMapper3D * m )
overrideprotected

Intersect the pick ray with a prop. The ray of a vtkMRMLRayCastMapper is not clipped with the clipping planes of the mapper first, as vtkCellPicker does, because the mapper applies them itself (see vtkMRMLRayCastMapper::IntersectWithRay): vtkCellPicker would limit the pick to where all plane functions are positive, which is not what the mapper keeps in all of its clipping modes. Other props are intersected as in vtkCellPicker.

◆ IsA()

virtual int vtkMRMLAccuratePicker::IsA ( const char * type)
virtual

◆ IsTypeOf()

static int vtkMRMLAccuratePicker::IsTypeOf ( const char * type)
static

◆ New()

static vtkMRMLAccuratePicker * vtkMRMLAccuratePicker::New ( )
static

◆ Pick()

int vtkMRMLAccuratePicker::Pick ( double selectionX,
double selectionY,
double selectionZ,
vtkRenderer * renderer )
override

Refresh the cell locators for the renderer's large surfaces, then pick as vtkCellPicker does.

◆ PrintSelf()

void vtkMRMLAccuratePicker::PrintSelf ( ostream & os,
vtkIndent indent )
override

◆ SafeDownCast()

static vtkMRMLAccuratePicker * vtkMRMLAccuratePicker::SafeDownCast ( vtkObject * o)
static

◆ SetMinimumCellCountToIndex()

virtual void vtkMRMLAccuratePicker::SetMinimumCellCountToIndex ( vtkIdType )
virtual

Minimum number of cells for a surface to be indexed with a locator. Smaller surfaces are already cheap to pick by brute force, and building a locator for them would cost more than it saves. Indexing changes how fast a surface is picked, not the picked position. Defaults to 10000.

◆ UpdateLocators()

void vtkMRMLAccuratePicker::UpdateLocators ( vtkRenderer * renderer)
protected

Register a cached locator with this picker for each large, pickable surface currently shown in the renderer (building or rebuilding it only when the surface changes) and drop locators for surfaces no longer shown.

Member Data Documentation

◆ LocatorsBySurface

std::map<vtkPolyData*, CachedLocator> vtkMRMLAccuratePicker::LocatorsBySurface
protected

Locator of each indexed surface. Not named Locators, which would hide vtkCellPicker::Locators (the locators that the picker uses).

Definition at line 137 of file vtkMRMLAccuratePicker.h.

◆ MinimumCellCountToIndex

vtkIdType vtkMRMLAccuratePicker::MinimumCellCountToIndex { 10000 }
protected

Definition at line 139 of file vtkMRMLAccuratePicker.h.


The documentation for this class was generated from the following file: