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 =========================================================================*/
41 #ifndef vtkCellPicker_h
42 #define vtkCellPicker_h
43 
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkPicker.h"
46 
47 class vtkMapper;
48 class vtkTexture;
50 class vtkImageMapper3D;
51 class vtkPlaneCollection;
53 class vtkDataArray;
54 class vtkDoubleArray;
55 class vtkIdList;
56 class vtkCell;
57 class vtkGenericCell;
58 class vtkImageData;
60 class vtkCollection;
61 class vtkMatrix4x4;
62 
63 class VTKRENDERINGCORE_EXPORT vtkCellPicker : public vtkPicker
64 {
65 public:
66  static vtkCellPicker *New();
67  vtkTypeMacro(vtkCellPicker, vtkPicker);
68  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
69 
76  int Pick(double selectionX, double selectionY, double selectionZ,
77  vtkRenderer *renderer) VTK_OVERRIDE;
78 
88  void AddLocator(vtkAbstractCellLocator *locator);
89 
95  void RemoveLocator(vtkAbstractCellLocator *locator);
96 
100  void RemoveAllLocators();
101 
103 
111  vtkSetMacro(VolumeOpacityIsovalue, double);
112  vtkGetMacro(VolumeOpacityIsovalue, double);
114 
116 
122  vtkSetMacro(UseVolumeGradientOpacity, int);
123  vtkBooleanMacro(UseVolumeGradientOpacity, int);
124  vtkGetMacro(UseVolumeGradientOpacity, int);
126 
128 
140  vtkSetMacro(PickClippingPlanes, int);
141  vtkBooleanMacro(PickClippingPlanes, int);
142  vtkGetMacro(PickClippingPlanes, int);
144 
146 
154  vtkGetMacro(ClippingPlaneId, int);
156 
158 
163  vtkGetVectorMacro(PickNormal, double, 3);
165 
167 
171  vtkGetVector3Macro(MapperNormal, double);
173 
175 
179  vtkGetVector3Macro(PointIJK, int);
181 
183 
188  vtkGetVector3Macro(CellIJK, int);
190 
192 
196  vtkGetMacro(PointId, vtkIdType);
198 
200 
203  vtkGetMacro(CellId, vtkIdType);
205 
207 
211  vtkGetMacro(SubId, int);
213 
215 
220  vtkGetVector3Macro(PCoords, double);
222 
227  vtkTexture *GetTexture() { return this->Texture; };
228 
230 
240  vtkSetMacro(PickTextureData, int);
241  vtkBooleanMacro(PickTextureData, int);
242  vtkGetMacro(PickTextureData, int);
244 
245 protected:
246  vtkCellPicker();
247  ~vtkCellPicker() VTK_OVERRIDE;
248 
249  void Initialize() VTK_OVERRIDE;
250 
251  virtual void ResetPickInfo();
252 
253  double IntersectWithLine(double p1[3], double p2[3], double tol,
254  vtkAssemblyPath *path, vtkProp3D *p,
255  vtkAbstractMapper3D *m) VTK_OVERRIDE;
256 
257  virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
258  double t1, double t2, double tol,
259  vtkProp3D *prop, vtkMapper *mapper);
260 
261  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet,
262  const double p1[3], const double p2[3],
263  double t1, double t2, double tol,
264  vtkAbstractCellLocator* &locator,
265  vtkIdType& cellId, int& subId,
266  double &tMin, double &pDistMin,
267  double xyz[3], double minPCoords[3] );
268 
269  virtual double IntersectVolumeWithLine(const double p1[3],
270  const double p2[3],
271  double t1, double t2,
272  vtkProp3D *prop,
273  vtkAbstractVolumeMapper *mapper);
274 
275  virtual double IntersectImageWithLine(const double p1[3],
276  const double p2[3],
277  double t1, double t2,
278  vtkProp3D *prop,
279  vtkImageMapper3D *mapper);
280 
281  virtual double IntersectProp3DWithLine(const double p1[3],
282  const double p2[3],
283  double t1, double t2, double tol,
284  vtkProp3D *prop,
285  vtkAbstractMapper3D *mapper);
286 
287  static int ClipLineWithPlanes(vtkAbstractMapper3D *mapper,
288  vtkMatrix4x4 *propMatrix,
289  const double p1[3], const double p2[3],
290  double &t1, double &t2, int& planeId);
291 
292  static int ClipLineWithExtent(const int extent[6],
293  const double x1[3], const double x2[3],
294  double &t1, double &t2, int &planeId);
295 
296  static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
297  const double *weights, double normal[3]);
298 
299  static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
300  const double *weights, double tcoord[3]);
301 
302  static int HasSubCells(int cellType);
303 
304  static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
305 
306  static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
307  int cellType, vtkGenericCell *cell);
308 
309  static void SubCellFromCell(vtkGenericCell *cell, int subId);
310 
311  void SetImageDataPickInfo(const double x[3], const int extent[6]);
312 
313  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
314  vtkImageData *data, vtkDataArray *scalars,
315  vtkPiecewiseFunction *scalarOpacity,
316  vtkPiecewiseFunction *gradientOpacity);
317 
318  vtkCollection *Locators;
319 
320  double VolumeOpacityIsovalue;
321  int UseVolumeGradientOpacity;
322  int PickClippingPlanes;
323  int ClippingPlaneId;
324 
325  vtkIdType PointId;
326  vtkIdType CellId;
327  int SubId;
328  double PCoords[3];
329 
330  int PointIJK[3];
331  int CellIJK[3];
332 
333  double PickNormal[3];
334  double MapperNormal[3];
335 
336  vtkTexture *Texture;
337  int PickTextureData;
338 
339 private:
340  void ResetCellPickerInfo();
341 
342  vtkGenericCell *Cell; //used to accelerate picking
343  vtkIdList *PointIds; // used to accelerate picking
344  vtkDoubleArray *Gradients; //used in volume picking
345 
346 private:
347  vtkCellPicker(const vtkCellPicker&) VTK_DELETE_FUNCTION;
348  void operator=(const vtkCellPicker&) VTK_DELETE_FUNCTION;
349 };
350 
351 #endif
352 
353 
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
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:56
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:57
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:43
int vtkIdType
Definition: vtkType.h:345
provides thread-safe access to cells
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:55
vtkTexture * GetTexture()
Get the texture that was picked.
dynamic, self-adjusting array of double
abstract class to specify cell behavior
Definition: vtkCell.h:56
a list of nodes that form an assembly path
a simple class to control print indentation
Definition: vtkIndent.h:33
abstract class for mapping images to the screen
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
list of point or cell ids
Definition: vtkIdList.h:30
static vtkPicker * New()
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
handles properties associated with a texture map
Definition: vtkTexture.h:64
abstract class specifies interface to map 3D data
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:85
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
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.