VTK  9.0.20201201
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 "vtkPicker.h"
45 #include "vtkRenderingCoreModule.h" // For export macro
46 
47 class vtkMapper;
48 class vtkTexture;
51 class vtkImageMapper3D;
52 class vtkPlaneCollection;
54 class vtkDataArray;
55 class vtkDoubleArray;
56 class vtkIdList;
57 class vtkCell;
58 class vtkGenericCell;
59 class vtkImageData;
61 class vtkCollection;
62 class vtkMatrix4x4;
63 class vtkBitArray;
65 
66 class VTKRENDERINGCORE_EXPORT vtkCellPicker : public vtkPicker
67 {
68 public:
69  static vtkCellPicker* New();
70  vtkTypeMacro(vtkCellPicker, vtkPicker);
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
79  int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
80 
86  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
87 
97  void AddLocator(vtkAbstractCellLocator* locator);
98 
104  void RemoveLocator(vtkAbstractCellLocator* locator);
105 
109  void RemoveAllLocators();
110 
112 
120  vtkSetMacro(VolumeOpacityIsovalue, double);
121  vtkGetMacro(VolumeOpacityIsovalue, double);
123 
125 
131  vtkSetMacro(UseVolumeGradientOpacity, vtkTypeBool);
132  vtkBooleanMacro(UseVolumeGradientOpacity, vtkTypeBool);
133  vtkGetMacro(UseVolumeGradientOpacity, vtkTypeBool);
135 
137 
149  vtkSetMacro(PickClippingPlanes, vtkTypeBool);
150  vtkBooleanMacro(PickClippingPlanes, vtkTypeBool);
151  vtkGetMacro(PickClippingPlanes, vtkTypeBool);
153 
155 
163  vtkGetMacro(ClippingPlaneId, int);
165 
167 
172  vtkGetVectorMacro(PickNormal, double, 3);
174 
176 
180  vtkGetVector3Macro(MapperNormal, double);
182 
184 
188  vtkGetVector3Macro(PointIJK, int);
190 
192 
197  vtkGetVector3Macro(CellIJK, int);
199 
201 
205  vtkGetMacro(PointId, vtkIdType);
207 
209 
212  vtkGetMacro(CellId, vtkIdType);
214 
216 
220  vtkGetMacro(SubId, int);
222 
224 
229  vtkGetVector3Macro(PCoords, double);
231 
236  vtkTexture* GetTexture() { return this->Texture; }
237 
239 
249  vtkSetMacro(PickTextureData, vtkTypeBool);
250  vtkBooleanMacro(PickTextureData, vtkTypeBool);
251  vtkGetMacro(PickTextureData, vtkTypeBool);
253 
254 protected:
255  vtkCellPicker();
256  ~vtkCellPicker() override;
257 
258  void Initialize() override;
259 
260  virtual void ResetPickInfo();
261 
262  double IntersectWithLine(const double p1[3], const double p2[3], double tol,
263  vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m) override;
264 
265  virtual double IntersectActorWithLine(const double p1[3], const double p2[3], double t1,
266  double t2, double tol, vtkProp3D* prop, vtkMapper* mapper);
267 
268  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet, const double p1[3], const double p2[3],
269  double t1, double t2, double tol, vtkAbstractCellLocator*& locator, vtkIdType& cellId,
270  int& subId, double& tMin, double& pDistMin, double xyz[3], double minPCoords[3]);
271 
273 
276  virtual double IntersectHyperTreeGridWithLine(
277  const double[3], const double[3], double, double, vtkAbstractHyperTreeGridMapper*);
278  virtual bool RecursivelyProcessTree(vtkHyperTreeGridNonOrientedGeometryCursor*, int);
280 
281  virtual double IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1,
282  double t2, vtkProp3D* prop, vtkAbstractVolumeMapper* mapper);
283 
284  virtual double IntersectImageWithLine(const double p1[3], const double p2[3], double t1,
285  double t2, vtkProp3D* prop, vtkImageMapper3D* mapper);
286 
287  virtual double IntersectProp3DWithLine(const double p1[3], const double p2[3], double t1,
288  double t2, double tol, vtkProp3D* prop, vtkAbstractMapper3D* mapper);
289 
290  static int ClipLineWithPlanes(vtkAbstractMapper3D* mapper, vtkMatrix4x4* propMatrix,
291  const double p1[3], const double p2[3], double& t1, double& t2, int& planeId);
292 
293  static int ClipLineWithExtent(const int extent[6], const double x1[3], const double x2[3],
294  double& t1, double& t2, int& planeId);
295 
296  static int ComputeSurfaceNormal(
297  vtkDataSet* data, vtkCell* cell, const double* weights, double normal[3]);
298 
299  static int ComputeSurfaceTCoord(
300  vtkDataSet* data, vtkCell* cell, 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(
307  vtkDataSet* data, vtkIdList* pointIds, int subId, 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], vtkImageData* data,
314  vtkDataArray* scalars, vtkPiecewiseFunction* scalarOpacity,
315  vtkPiecewiseFunction* gradientOpacity);
316 
318 
323 
326  int SubId;
327  double PCoords[3];
328 
329  int PointIJK[3];
330  int CellIJK[3];
331 
332  double PickNormal[3];
333  double MapperNormal[3];
334 
337 
339  double WordlPoint[3];
340 
341 private:
342  void ResetCellPickerInfo();
343 
344  vtkGenericCell* Cell; // used to accelerate picking
345  vtkIdList* PointIds; // used to accelerate picking
346  vtkDoubleArray* Gradients; // used in volume picking
347 
348 private:
349  vtkCellPicker(const vtkCellPicker&) = delete;
350  void operator=(const vtkCellPicker&) = delete;
351 };
352 
353 #endif
vtkHyperTreeGridNonOrientedGeometryCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedGeometryCursor.h:56
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkProp3D
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:43
vtkX3D::data
Definition: vtkX3D.h:321
vtkPicker::Pick
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform pick operation with selection point provided.
vtkPicker::Pick3DRay
int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override
Perform pick operation with selection point and orientation provided.
vtkCellPicker::GetTexture
vtkTexture * GetTexture()
Get the texture that was picked.
Definition: vtkCellPicker.h:236
vtkPicker::New
static vtkPicker * New()
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkPicker
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:61
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:41
vtkCellPicker::VolumeOpacityIsovalue
double VolumeOpacityIsovalue
Definition: vtkCellPicker.h:319
vtkCellPicker::PointId
vtkIdType PointId
Definition: vtkCellPicker.h:324
vtkCellPicker::InMask
vtkBitArray * InMask
Definition: vtkCellPicker.h:338
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:65
vtkCollection
create and manipulate ordered lists of objects
Definition: vtkCollection.h:52
vtkCellPicker::PickClippingPlanes
vtkTypeBool PickClippingPlanes
Definition: vtkCellPicker.h:321
vtkMapper
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:81
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:57
vtkPicker::IntersectWithLine
virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m)
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkCellPicker::Texture
vtkTexture * Texture
Definition: vtkCellPicker.h:335
vtkAbstractHyperTreeGridMapper
Abstract class for a HyperTreeGrid mapper.
Definition: vtkAbstractHyperTreeGridMapper.h:46
vtkCellPicker::UseVolumeGradientOpacity
vtkTypeBool UseVolumeGradientOpacity
Definition: vtkCellPicker.h:320
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:48
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:45
vtkPicker::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkCellPicker::PickTextureData
vtkTypeBool PickTextureData
Definition: vtkCellPicker.h:336
vtkCellPicker::CellId
vtkIdType CellId
Definition: vtkCellPicker.h:325
vtkPicker.h
vtkCellPicker::Locators
vtkCollection * Locators
Definition: vtkCellPicker.h:317
vtkImageMapper3D
abstract class for mapping images to the screen
Definition: vtkImageMapper3D.h:48
vtkAbstractMapper3D
abstract class specifies interface to map 3D data
Definition: vtkAbstractMapper3D.h:42
vtkAbstractVolumeMapper
Abstract class for a volume mapper.
Definition: vtkAbstractVolumeMapper.h:38
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
vtkBitArray
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:33
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkCellPicker::SubId
int SubId
Definition: vtkCellPicker.h:326
vtkX3D::extent
Definition: vtkX3D.h:351
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:33
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkCellPicker::ClippingPlaneId
int ClippingPlaneId
Definition: vtkCellPicker.h:322
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPicker::Initialize
void Initialize() override