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) override;
75 
82  int Pick(double selectionX, double selectionY, double selectionZ,
83  vtkRenderer *renderer) override;
84 
90  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override;
91 
101  void AddLocator(vtkAbstractCellLocator *locator);
102 
108  void RemoveLocator(vtkAbstractCellLocator *locator);
109 
113  void RemoveAllLocators();
114 
116 
124  vtkSetMacro(VolumeOpacityIsovalue, double);
125  vtkGetMacro(VolumeOpacityIsovalue, double);
127 
129 
135  vtkSetMacro(UseVolumeGradientOpacity, vtkTypeBool);
136  vtkBooleanMacro(UseVolumeGradientOpacity, vtkTypeBool);
137  vtkGetMacro(UseVolumeGradientOpacity, vtkTypeBool);
139 
141 
153  vtkSetMacro(PickClippingPlanes, vtkTypeBool);
154  vtkBooleanMacro(PickClippingPlanes, vtkTypeBool);
155  vtkGetMacro(PickClippingPlanes, vtkTypeBool);
157 
159 
167  vtkGetMacro(ClippingPlaneId, int);
169 
171 
176  vtkGetVectorMacro(PickNormal, double, 3);
178 
180 
184  vtkGetVector3Macro(MapperNormal, double);
186 
188 
192  vtkGetVector3Macro(PointIJK, int);
194 
196 
201  vtkGetVector3Macro(CellIJK, int);
203 
205 
209  vtkGetMacro(PointId, vtkIdType);
211 
213 
216  vtkGetMacro(CellId, vtkIdType);
218 
220 
224  vtkGetMacro(SubId, int);
226 
228 
233  vtkGetVector3Macro(PCoords, double);
235 
240  vtkTexture *GetTexture() { return this->Texture; };
241 
243 
253  vtkSetMacro(PickTextureData, vtkTypeBool);
254  vtkBooleanMacro(PickTextureData, vtkTypeBool);
255  vtkGetMacro(PickTextureData, vtkTypeBool);
257 
258 protected:
259  vtkCellPicker();
260  ~vtkCellPicker() override;
261 
262  void Initialize() override;
263 
264  virtual void ResetPickInfo();
265 
266  double IntersectWithLine(const double p1[3], const double p2[3], double tol,
267  vtkAssemblyPath *path, vtkProp3D *p,
268  vtkAbstractMapper3D *m) override;
269 
270  virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
271  double t1, double t2, double tol,
272  vtkProp3D *prop, vtkMapper *mapper);
273 
274  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet,
275  const double p1[3], const double p2[3],
276  double t1, double t2, double tol,
277  vtkAbstractCellLocator* &locator,
278  vtkIdType& cellId, int& subId,
279  double &tMin, double &pDistMin,
280  double xyz[3], double minPCoords[3] );
281 
282  virtual double IntersectVolumeWithLine(const double p1[3],
283  const double p2[3],
284  double t1, double t2,
285  vtkProp3D *prop,
286  vtkAbstractVolumeMapper *mapper);
287 
288  virtual double IntersectImageWithLine(const double p1[3],
289  const double p2[3],
290  double t1, double t2,
291  vtkProp3D *prop,
292  vtkImageMapper3D *mapper);
293 
294  virtual double IntersectProp3DWithLine(const double p1[3],
295  const double p2[3],
296  double t1, double t2, double tol,
297  vtkProp3D *prop,
298  vtkAbstractMapper3D *mapper);
299 
300  static int ClipLineWithPlanes(vtkAbstractMapper3D *mapper,
301  vtkMatrix4x4 *propMatrix,
302  const double p1[3], const double p2[3],
303  double &t1, double &t2, int& planeId);
304 
305  static int ClipLineWithExtent(const int extent[6],
306  const double x1[3], const double x2[3],
307  double &t1, double &t2, int &planeId);
308 
309  static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
310  const double *weights, double normal[3]);
311 
312  static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
313  const double *weights, double tcoord[3]);
314 
315  static int HasSubCells(int cellType);
316 
317  static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
318 
319  static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
320  int cellType, vtkGenericCell *cell);
321 
322  static void SubCellFromCell(vtkGenericCell *cell, int subId);
323 
324  void SetImageDataPickInfo(const double x[3], const int extent[6]);
325 
326  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
327  vtkImageData *data, vtkDataArray *scalars,
328  vtkPiecewiseFunction *scalarOpacity,
329  vtkPiecewiseFunction *gradientOpacity);
330 
332 
337 
340  int SubId;
341  double PCoords[3];
342 
343  int PointIJK[3];
344  int CellIJK[3];
345 
346  double PickNormal[3];
347  double MapperNormal[3];
348 
351 
352 private:
353  void ResetCellPickerInfo();
354 
355  vtkGenericCell *Cell; //used to accelerate picking
356  vtkIdList *PointIds; // used to accelerate picking
357  vtkDoubleArray *Gradients; //used in volume picking
358 
359 private:
360  vtkCellPicker(const vtkCellPicker&) = delete;
361  void operator=(const vtkCellPicker&) = delete;
362 };
363 
364 #endif
365 
366 
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
virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m)
double VolumeOpacityIsovalue
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
int vtkIdType
Definition: vtkType.h:347
vtkTypeBool UseVolumeGradientOpacity
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
int vtkTypeBool
Definition: vtkABI.h:69
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
vtkTypeBool PickClippingPlanes
static vtkPicker * New()
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
handles properties associated with a texture map
Definition: vtkTexture.h:71
abstract class specifies interface to map 3D data
vtkCollection * Locators
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:86
void Initialize() override
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
vtkTypeBool PickTextureData
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform pick operation with selection point provided.
int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override
Perform pick operation with selection point and orientation provided.