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) override;
69 
76  int Pick(double selectionX, double selectionY, double selectionZ,
77  vtkRenderer *renderer) override;
78 
84  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override;
85 
95  void AddLocator(vtkAbstractCellLocator *locator);
96 
102  void RemoveLocator(vtkAbstractCellLocator *locator);
103 
107  void RemoveAllLocators();
108 
110 
118  vtkSetMacro(VolumeOpacityIsovalue, double);
119  vtkGetMacro(VolumeOpacityIsovalue, double);
121 
123 
129  vtkSetMacro(UseVolumeGradientOpacity, vtkTypeBool);
130  vtkBooleanMacro(UseVolumeGradientOpacity, vtkTypeBool);
131  vtkGetMacro(UseVolumeGradientOpacity, vtkTypeBool);
133 
135 
147  vtkSetMacro(PickClippingPlanes, vtkTypeBool);
148  vtkBooleanMacro(PickClippingPlanes, vtkTypeBool);
149  vtkGetMacro(PickClippingPlanes, vtkTypeBool);
151 
153 
161  vtkGetMacro(ClippingPlaneId, int);
163 
165 
170  vtkGetVectorMacro(PickNormal, double, 3);
172 
174 
178  vtkGetVector3Macro(MapperNormal, double);
180 
182 
186  vtkGetVector3Macro(PointIJK, int);
188 
190 
195  vtkGetVector3Macro(CellIJK, int);
197 
199 
203  vtkGetMacro(PointId, vtkIdType);
205 
207 
210  vtkGetMacro(CellId, vtkIdType);
212 
214 
218  vtkGetMacro(SubId, int);
220 
222 
227  vtkGetVector3Macro(PCoords, double);
229 
234  vtkTexture *GetTexture() { return this->Texture; };
235 
237 
247  vtkSetMacro(PickTextureData, vtkTypeBool);
248  vtkBooleanMacro(PickTextureData, vtkTypeBool);
249  vtkGetMacro(PickTextureData, vtkTypeBool);
251 
252 protected:
253  vtkCellPicker();
254  ~vtkCellPicker() override;
255 
256  void Initialize() override;
257 
258  virtual void ResetPickInfo();
259 
260  double IntersectWithLine(const double p1[3], const double p2[3], double tol,
261  vtkAssemblyPath *path, vtkProp3D *p,
262  vtkAbstractMapper3D *m) override;
263 
264  virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
265  double t1, double t2, double tol,
266  vtkProp3D *prop, vtkMapper *mapper);
267 
268  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet,
269  const double p1[3], const double p2[3],
270  double t1, double t2, double tol,
271  vtkAbstractCellLocator* &locator,
272  vtkIdType& cellId, int& subId,
273  double &tMin, double &pDistMin,
274  double xyz[3], double minPCoords[3] );
275 
276  virtual double IntersectVolumeWithLine(const double p1[3],
277  const double p2[3],
278  double t1, double t2,
279  vtkProp3D *prop,
280  vtkAbstractVolumeMapper *mapper);
281 
282  virtual double IntersectImageWithLine(const double p1[3],
283  const double p2[3],
284  double t1, double t2,
285  vtkProp3D *prop,
286  vtkImageMapper3D *mapper);
287 
288  virtual double IntersectProp3DWithLine(const double p1[3],
289  const double p2[3],
290  double t1, double t2, double tol,
291  vtkProp3D *prop,
292  vtkAbstractMapper3D *mapper);
293 
294  static int ClipLineWithPlanes(vtkAbstractMapper3D *mapper,
295  vtkMatrix4x4 *propMatrix,
296  const double p1[3], const double p2[3],
297  double &t1, double &t2, int& planeId);
298 
299  static int ClipLineWithExtent(const int extent[6],
300  const double x1[3], const double x2[3],
301  double &t1, double &t2, int &planeId);
302 
303  static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
304  const double *weights, double normal[3]);
305 
306  static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
307  const double *weights, double tcoord[3]);
308 
309  static int HasSubCells(int cellType);
310 
311  static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
312 
313  static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
314  int cellType, vtkGenericCell *cell);
315 
316  static void SubCellFromCell(vtkGenericCell *cell, int subId);
317 
318  void SetImageDataPickInfo(const double x[3], const int extent[6]);
319 
320  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
321  vtkImageData *data, vtkDataArray *scalars,
322  vtkPiecewiseFunction *scalarOpacity,
323  vtkPiecewiseFunction *gradientOpacity);
324 
326 
331 
334  int SubId;
335  double PCoords[3];
336 
337  int PointIJK[3];
338  int CellIJK[3];
339 
340  double PickNormal[3];
341  double MapperNormal[3];
342 
345 
346 private:
347  void ResetCellPickerInfo();
348 
349  vtkGenericCell *Cell; //used to accelerate picking
350  vtkIdList *PointIds; // used to accelerate picking
351  vtkDoubleArray *Gradients; //used in volume picking
352 
353 private:
354  vtkCellPicker(const vtkCellPicker&) = delete;
355  void operator=(const vtkCellPicker&) = delete;
356 };
357 
358 #endif
359 
360 
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
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:43
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:55
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:56
vtkTexture * Texture
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
vtkIdType PointId
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
list of point or cell ids
Definition: vtkIdList.h:30
vtkTypeBool PickClippingPlanes
static vtkPicker * New()
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
handles properties associated with a texture map
Definition: vtkTexture.h:65
abstract class specifies interface to map 3D data
vtkCollection * Locators
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:80
void Initialize() override
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
vtkTypeBool PickTextureData
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
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.