VTK
vtkCellPicker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellPicker.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
47 #ifndef vtkCellPicker_h
48 #define vtkCellPicker_h
49 
50 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkPicker.h"
52 
53 class vtkMapper;
54 class vtkTexture;
56 class vtkImageMapper3D;
57 class vtkPlaneCollection;
59 class vtkDataArray;
60 class vtkDoubleArray;
61 class vtkIdList;
62 class vtkCell;
63 class vtkGenericCell;
64 class vtkImageData;
66 class vtkCollection;
67 class vtkMatrix4x4;
68 
69 class VTKRENDERINGCORE_EXPORT vtkCellPicker : public vtkPicker
70 {
71 public:
72  static vtkCellPicker *New();
73  vtkTypeMacro(vtkCellPicker, vtkPicker);
74  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
75 
82  int Pick(double selectionX, double selectionY, double selectionZ,
83  vtkRenderer *renderer) VTK_OVERRIDE;
84 
94  void AddLocator(vtkAbstractCellLocator *locator);
95 
101  void RemoveLocator(vtkAbstractCellLocator *locator);
102 
106  void RemoveAllLocators();
107 
109 
117  vtkSetMacro(VolumeOpacityIsovalue, double);
118  vtkGetMacro(VolumeOpacityIsovalue, double);
120 
122 
128  vtkSetMacro(UseVolumeGradientOpacity, int);
129  vtkBooleanMacro(UseVolumeGradientOpacity, int);
130  vtkGetMacro(UseVolumeGradientOpacity, int);
132 
134 
146  vtkSetMacro(PickClippingPlanes, int);
147  vtkBooleanMacro(PickClippingPlanes, int);
148  vtkGetMacro(PickClippingPlanes, int);
150 
152 
160  vtkGetMacro(ClippingPlaneId, int);
162 
164 
169  vtkGetVectorMacro(PickNormal, double, 3);
171 
173 
177  vtkGetVector3Macro(MapperNormal, double);
179 
181 
185  vtkGetVector3Macro(PointIJK, int);
187 
189 
194  vtkGetVector3Macro(CellIJK, int);
196 
198 
202  vtkGetMacro(PointId, vtkIdType);
204 
206 
209  vtkGetMacro(CellId, vtkIdType);
211 
213 
217  vtkGetMacro(SubId, int);
219 
221 
226  vtkGetVector3Macro(PCoords, double);
228 
233  vtkTexture *GetTexture() { return this->Texture; };
234 
236 
246  vtkSetMacro(PickTextureData, int);
247  vtkBooleanMacro(PickTextureData, int);
248  vtkGetMacro(PickTextureData, int);
250 
251 protected:
252  vtkCellPicker();
253  ~vtkCellPicker() VTK_OVERRIDE;
254 
255  void Initialize() VTK_OVERRIDE;
256 
257  virtual void ResetPickInfo();
258 
259  double IntersectWithLine(double p1[3], double p2[3], double tol,
260  vtkAssemblyPath *path, vtkProp3D *p,
261  vtkAbstractMapper3D *m) VTK_OVERRIDE;
262 
263  virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
264  double t1, double t2, double tol,
265  vtkProp3D *prop, vtkMapper *mapper);
266 
267  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet,
268  const double p1[3], const double p2[3],
269  double t1, double t2, double tol,
270  vtkAbstractCellLocator* &locator,
271  vtkIdType& cellId, int& subId,
272  double &tMin, double &pDistMin,
273  double xyz[3], double minPCoords[3] );
274 
275  virtual double IntersectVolumeWithLine(const double p1[3],
276  const double p2[3],
277  double t1, double t2,
278  vtkProp3D *prop,
279  vtkAbstractVolumeMapper *mapper);
280 
281  virtual double IntersectImageWithLine(const double p1[3],
282  const double p2[3],
283  double t1, double t2,
284  vtkProp3D *prop,
285  vtkImageMapper3D *mapper);
286 
287  virtual double IntersectProp3DWithLine(const double p1[3],
288  const double p2[3],
289  double t1, double t2, double tol,
290  vtkProp3D *prop,
291  vtkAbstractMapper3D *mapper);
292 
293  static int ClipLineWithPlanes(vtkAbstractMapper3D *mapper,
294  vtkMatrix4x4 *propMatrix,
295  const double p1[3], const double p2[3],
296  double &t1, double &t2, int& planeId);
297 
298  static int ClipLineWithExtent(const int extent[6],
299  const double x1[3], const double x2[3],
300  double &t1, double &t2, int &planeId);
301 
302  static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
303  const double *weights, double normal[3]);
304 
305  static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
306  const double *weights, double tcoord[3]);
307 
308  static int HasSubCells(int cellType);
309 
310  static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
311 
312  static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
313  int cellType, vtkGenericCell *cell);
314 
315  static void SubCellFromCell(vtkGenericCell *cell, int subId);
316 
317  void SetImageDataPickInfo(const double x[3], const int extent[6]);
318 
319  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
320  vtkImageData *data, vtkDataArray *scalars,
321  vtkPiecewiseFunction *scalarOpacity,
322  vtkPiecewiseFunction *gradientOpacity);
323 
325 
330 
333  int SubId;
334  double PCoords[3];
335 
336  int PointIJK[3];
337  int CellIJK[3];
338 
339  double PickNormal[3];
340  double MapperNormal[3];
341 
344 
345 private:
346  void ResetCellPickerInfo();
347 
348  vtkGenericCell *Cell; //used to accelerate picking
349  vtkIdList *PointIds; // used to accelerate picking
350  vtkDoubleArray *Gradients; //used in volume picking
351 
352 private:
353  vtkCellPicker(const vtkCellPicker&) VTK_DELETE_FUNCTION;
354  void operator=(const vtkCellPicker&) VTK_DELETE_FUNCTION;
355 };
356 
357 #endif
358 
359 
int UseVolumeGradientOpacity
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Defines a 1D piecewise function.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
maintain a list of planes
an abstract base class for locators which find cells
Abstract class for a volume mapper.
abstract specification for renderers
Definition: vtkRenderer.h:63
double VolumeOpacityIsovalue
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
int vtkIdType
Definition: vtkType.h:345
provides thread-safe access to cells
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:58
vtkTexture * GetTexture()
Get the texture that was picked.
dynamic, self-adjusting array of double
vtkIdType CellId
abstract class to specify cell behavior
Definition: vtkCell.h:59
vtkTexture * Texture
a list of nodes that form an assembly path
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract class for mapping images to the screen
vtkIdType PointId
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
list of point or cell ids
Definition: vtkIdList.h:36
static vtkPicker * New()
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
handles properties associated with a texture map
Definition: vtkTexture.h:70
abstract class specifies interface to map 3D data
virtual double IntersectWithLine(double p1[3], double p2[3], double tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m)
vtkCollection * Locators
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:91
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void Initialize() override
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform pick operation with selection point provided.