VTK  9.3.1
vtkCellPicker.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
35 #ifndef vtkCellPicker_h
36 #define vtkCellPicker_h
37 
38 #include "vtkPicker.h"
39 #include "vtkRenderingCoreModule.h" // For export macro
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkMapper;
43 class vtkTexture;
46 class vtkImageMapper3D;
47 class vtkPlaneCollection;
49 class vtkDataArray;
50 class vtkDoubleArray;
51 class vtkIdList;
52 class vtkCell;
53 class vtkGenericCell;
54 class vtkImageData;
56 class vtkCollection;
57 class vtkMatrix4x4;
58 class vtkBitArray;
60 
61 class VTKRENDERINGCORE_EXPORT vtkCellPicker : public vtkPicker
62 {
63 public:
64  static vtkCellPicker* New();
65  vtkTypeMacro(vtkCellPicker, vtkPicker);
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
74  int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
75 
81  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
82 
90  void AddLocator(vtkAbstractCellLocator* locator);
91 
97  void RemoveLocator(vtkAbstractCellLocator* locator);
98 
102  void RemoveAllLocators();
103 
105 
113  vtkSetMacro(VolumeOpacityIsovalue, double);
114  vtkGetMacro(VolumeOpacityIsovalue, double);
116 
118 
124  vtkSetMacro(UseVolumeGradientOpacity, vtkTypeBool);
125  vtkBooleanMacro(UseVolumeGradientOpacity, vtkTypeBool);
126  vtkGetMacro(UseVolumeGradientOpacity, vtkTypeBool);
128 
130 
142  vtkSetMacro(PickClippingPlanes, vtkTypeBool);
143  vtkBooleanMacro(PickClippingPlanes, vtkTypeBool);
144  vtkGetMacro(PickClippingPlanes, vtkTypeBool);
146 
148 
156  vtkGetMacro(ClippingPlaneId, int);
158 
160 
165  vtkGetVectorMacro(PickNormal, double, 3);
167 
169 
173  vtkGetVector3Macro(MapperNormal, double);
175 
177 
181  vtkGetVector3Macro(PointIJK, int);
183 
185 
190  vtkGetVector3Macro(CellIJK, int);
192 
194 
198  vtkGetMacro(PointId, vtkIdType);
200 
202 
205  vtkGetMacro(CellId, vtkIdType);
207 
209 
213  vtkGetMacro(SubId, int);
215 
217 
222  vtkGetVector3Macro(PCoords, double);
224 
229  vtkTexture* GetTexture() { return this->Texture; }
230 
232 
242  vtkSetMacro(PickTextureData, vtkTypeBool);
243  vtkBooleanMacro(PickTextureData, vtkTypeBool);
244  vtkGetMacro(PickTextureData, vtkTypeBool);
246 
247 protected:
248  vtkCellPicker();
249  ~vtkCellPicker() override;
250 
251  void Initialize() override;
252 
253  virtual void ResetPickInfo();
254 
255  double IntersectWithLine(const double p1[3], const double p2[3], double tol,
256  vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m) override;
257 
258  virtual double IntersectActorWithLine(const double p1[3], const double p2[3], double t1,
259  double t2, double tol, vtkProp3D* prop, vtkMapper* mapper);
260 
261  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet, const double p1[3], const double p2[3],
262  double t1, double t2, double tol, vtkAbstractCellLocator*& locator, vtkIdType& cellId,
263  int& subId, double& tMin, double& pDistMin, double xyz[3], double minPCoords[3]);
264 
266 
269  virtual double IntersectHyperTreeGridWithLine(
270  const double[3], const double[3], double, double, vtkAbstractHyperTreeGridMapper*);
271  virtual bool RecursivelyProcessTree(vtkHyperTreeGridNonOrientedGeometryCursor*, int);
273 
274  virtual double IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1,
275  double t2, vtkProp3D* prop, vtkAbstractVolumeMapper* mapper);
276 
277  virtual double IntersectImageWithLine(const double p1[3], const double p2[3], double t1,
278  double t2, vtkProp3D* prop, vtkImageMapper3D* mapper);
279 
280  virtual double IntersectProp3DWithLine(const double p1[3], const double p2[3], double t1,
281  double t2, double tol, vtkProp3D* prop, vtkAbstractMapper3D* mapper);
282 
283  static int ClipLineWithPlanes(vtkAbstractMapper3D* mapper, vtkMatrix4x4* propMatrix,
284  const double p1[3], const double p2[3], double& t1, double& t2, int& planeId);
285 
286  static int ClipLineWithExtent(const int extent[6], const double x1[3], const double x2[3],
287  double& t1, double& t2, int& planeId);
288 
289  static int ComputeSurfaceNormal(
290  vtkDataSet* data, vtkCell* cell, const double* weights, double normal[3]);
291 
292  static int ComputeSurfaceTCoord(
293  vtkDataSet* data, vtkCell* cell, const double* weights, double tcoord[3]);
294 
295  static vtkTypeBool HasSubCells(int cellType);
296 
297  static int GetNumberOfSubCells(vtkIdList* pointIds, int cellType);
298 
299  static void GetSubCell(
300  vtkDataSet* data, vtkIdList* pointIds, int subId, int cellType, vtkGenericCell* cell);
301 
302  static void SubCellFromCell(vtkGenericCell* cell, int subId);
303 
304  void SetImageDataPickInfo(const double x[3], const int extent[6]);
305 
306  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3], vtkImageData* data,
307  vtkDataArray* scalars, vtkPiecewiseFunction* scalarOpacity,
308  vtkPiecewiseFunction* gradientOpacity);
309 
311 
316 
319  int SubId;
320  double PCoords[3];
321 
322  int PointIJK[3];
323  int CellIJK[3];
324 
325  double PickNormal[3];
326  double MapperNormal[3];
327 
330 
332  double WordlPoint[3];
333 
334 private:
335  void ResetCellPickerInfo();
336 
337  vtkGenericCell* Cell; // used to accelerate picking
338  vtkIdList* PointIds; // used to accelerate picking
339  vtkDoubleArray* Gradients; // used in volume picking
340 
341  vtkCellPicker(const vtkCellPicker&) = delete;
342  void operator=(const vtkCellPicker&) = delete;
343 };
344 
345 VTK_ABI_NAMESPACE_END
346 #endif
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
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:52
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:61
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:38
int vtkIdType
Definition: vtkType.h:315
vtkTypeBool UseVolumeGradientOpacity
provides thread-safe access to cells
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:50
vtkTexture * GetTexture()
Get the texture that was picked.
dynamic, self-adjusting array of double
vtkIdType CellId
int vtkTypeBool
Definition: vtkABI.h:64
abstract class to specify cell behavior
Definition: vtkCell.h:49
vtkTexture * Texture
a list of nodes that form an assembly path
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract class for mapping images to the screen
vtkIdType PointId
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
list of point or cell ids
Definition: vtkIdList.h:22
vtkTypeBool PickClippingPlanes
static vtkPicker * New()
vtkBitArray * InMask
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
handles properties associated with a texture map
Definition: vtkTexture.h:57
abstract class specifies interface to map 3D data
vtkCollection * Locators
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:76
void Initialize() override
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:28
create and manipulate ordered lists of objects
Definition: vtkCollection.h:44
vtkTypeBool PickTextureData
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
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.