VTK  9.2.6
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 "vtkPicker.h"
51 #include "vtkRenderingCoreModule.h" // For export macro
52 
53 class vtkMapper;
54 class vtkTexture;
57 class vtkImageMapper3D;
58 class vtkPlaneCollection;
60 class vtkDataArray;
61 class vtkDoubleArray;
62 class vtkIdList;
63 class vtkCell;
64 class vtkGenericCell;
65 class vtkImageData;
67 class vtkCollection;
68 class vtkMatrix4x4;
69 class vtkBitArray;
71 
72 class VTKRENDERINGCORE_EXPORT vtkCellPicker : public vtkPicker
73 {
74 public:
75  static vtkCellPicker* New();
76  vtkTypeMacro(vtkCellPicker, vtkPicker);
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
85  int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
86 
92  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
93 
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, vtkAbstractMapper3D* m) override;
268 
269  virtual double IntersectActorWithLine(const double p1[3], const double p2[3], double t1,
270  double t2, double tol, vtkProp3D* prop, vtkMapper* mapper);
271 
272  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet, const double p1[3], const double p2[3],
273  double t1, double t2, double tol, vtkAbstractCellLocator*& locator, vtkIdType& cellId,
274  int& subId, double& tMin, double& pDistMin, double xyz[3], double minPCoords[3]);
275 
277 
280  virtual double IntersectHyperTreeGridWithLine(
281  const double[3], const double[3], double, double, vtkAbstractHyperTreeGridMapper*);
282  virtual bool RecursivelyProcessTree(vtkHyperTreeGridNonOrientedGeometryCursor*, int);
284 
285  virtual double IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1,
286  double t2, vtkProp3D* prop, vtkAbstractVolumeMapper* mapper);
287 
288  virtual double IntersectImageWithLine(const double p1[3], const double p2[3], double t1,
289  double t2, vtkProp3D* prop, vtkImageMapper3D* mapper);
290 
291  virtual double IntersectProp3DWithLine(const double p1[3], const double p2[3], double t1,
292  double t2, double tol, vtkProp3D* prop, vtkAbstractMapper3D* mapper);
293 
294  static int ClipLineWithPlanes(vtkAbstractMapper3D* mapper, vtkMatrix4x4* propMatrix,
295  const double p1[3], const double p2[3], double& t1, double& t2, int& planeId);
296 
297  static int ClipLineWithExtent(const int extent[6], const double x1[3], const double x2[3],
298  double& t1, double& t2, int& planeId);
299 
300  static int ComputeSurfaceNormal(
301  vtkDataSet* data, vtkCell* cell, const double* weights, double normal[3]);
302 
303  static int ComputeSurfaceTCoord(
304  vtkDataSet* data, vtkCell* cell, const double* weights, double tcoord[3]);
305 
306  static int HasSubCells(int cellType);
307 
308  static int GetNumberOfSubCells(vtkIdList* pointIds, int cellType);
309 
310  static void GetSubCell(
311  vtkDataSet* data, vtkIdList* pointIds, int subId, int cellType, vtkGenericCell* cell);
312 
313  static void SubCellFromCell(vtkGenericCell* cell, int subId);
314 
315  void SetImageDataPickInfo(const double x[3], const int extent[6]);
316 
317  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3], vtkImageData* data,
318  vtkDataArray* scalars, vtkPiecewiseFunction* scalarOpacity,
319  vtkPiecewiseFunction* gradientOpacity);
320 
322 
327 
330  int SubId;
331  double PCoords[3];
332 
333  int PointIJK[3];
334  int CellIJK[3];
335 
336  double PickNormal[3];
337  double MapperNormal[3];
338 
341 
343  double WordlPoint[3];
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&) = delete;
354  void operator=(const vtkCellPicker&) = delete;
355 };
356 
357 #endif
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:72
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:49
int vtkIdType
Definition: vtkType.h:332
vtkTypeBool UseVolumeGradientOpacity
provides thread-safe access to cells
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:61
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:60
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:53
list of point or cell ids
Definition: vtkIdList.h:33
vtkTypeBool PickClippingPlanes
static vtkPicker * New()
vtkBitArray * InMask
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
handles properties associated with a texture map
Definition: vtkTexture.h:68
abstract class specifies interface to map 3D data
vtkCollection * Locators
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:87
void Initialize() override
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
create and manipulate ordered lists of objects
Definition: vtkCollection.h:55
vtkTypeBool PickTextureData
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
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.
Abstract class for a HyperTreeGrid mapper.