VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
41 
42 VTK_ABI_NAMESPACE_BEGIN
43 class vtkMapper;
44 class vtkTexture;
47 class vtkImageMapper3D;
48 class vtkPlaneCollection;
50 class vtkDataArray;
51 class vtkDoubleArray;
52 class vtkIdList;
53 class vtkCell;
54 class vtkGenericCell;
55 class vtkImageData;
57 class vtkCollection;
58 class vtkMatrix4x4;
59 class vtkBitArray;
61 
62 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkCellPicker : public vtkPicker
63 {
64 public:
65  static vtkCellPicker* New();
66  vtkTypeMacro(vtkCellPicker, vtkPicker);
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
75  int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
76 
82  int Pick3DRay(VTK_FUTURE_CONST double selectionPt[3], VTK_FUTURE_CONST double orient[4],
83  vtkRenderer* ren) override;
84 
93  void AddLocator(vtkAbstractCellLocator* locator);
94 
101  void RemoveLocator(vtkAbstractCellLocator* locator);
102 
106  void RemoveAllLocators();
107 
109 
117  vtkSetMacro(VolumeOpacityIsovalue, double);
118  vtkGetMacro(VolumeOpacityIsovalue, double);
120 
122 
128  vtkSetMacro(UseVolumeGradientOpacity, vtkTypeBool);
129  vtkBooleanMacro(UseVolumeGradientOpacity, vtkTypeBool);
130  vtkGetMacro(UseVolumeGradientOpacity, vtkTypeBool);
132 
134 
146  vtkSetMacro(PickClippingPlanes, vtkTypeBool);
147  vtkBooleanMacro(PickClippingPlanes, vtkTypeBool);
148  vtkGetMacro(PickClippingPlanes, vtkTypeBool);
150 
152 
160  vtkGetMacro(ClippingPlaneId, int);
162 
164 
169  vtkGetVectorMacro(PickNormal, double, 3);
171 
173 
177  vtkGetVector3Macro(MapperNormal, double);
179 
181 
185  vtkGetVector3Macro(PointIJK, int);
187 
189 
194  vtkGetVector3Macro(CellIJK, int);
196 
198 
202  vtkGetMacro(PointId, vtkIdType);
204 
206 
209  vtkGetMacro(CellId, vtkIdType);
211 
213 
217  vtkGetMacro(SubId, int);
219 
221 
226  vtkGetVector3Macro(PCoords, double);
228 
233  vtkTexture* GetTexture() { return this->Texture; }
234 
236 
246  vtkSetMacro(PickTextureData, vtkTypeBool);
247  vtkBooleanMacro(PickTextureData, vtkTypeBool);
248  vtkGetMacro(PickTextureData, vtkTypeBool);
250 
251 protected:
252  vtkCellPicker();
253  ~vtkCellPicker() override;
254 
255  void Initialize() override;
256 
257  virtual void ResetPickInfo();
258 
259  double IntersectWithLine(const double p1[3], const double p2[3], double tol,
260  vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m) override;
261 
262  virtual double IntersectActorWithLine(const double p1[3], const double p2[3], double t1,
263  double t2, double tol, vtkProp3D* prop, vtkMapper* mapper);
264 
265  virtual bool IntersectDataSetWithLine(vtkDataSet* dataSet, const double p1[3], const double p2[3],
266  double t1, double t2, double tol, vtkAbstractCellLocator*& locator, vtkIdType& cellId,
267  int& subId, double& tMin, double& pDistMin, double xyz[3], double minPCoords[3]);
268 
270 
273  virtual double IntersectHyperTreeGridWithLine(
274  const double[3], const double[3], double, double, vtkAbstractHyperTreeGridMapper*);
275  virtual bool RecursivelyProcessTree(vtkHyperTreeGridNonOrientedGeometryCursor*, int);
277 
278  virtual double IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1,
279  double t2, vtkProp3D* prop, vtkAbstractVolumeMapper* mapper);
280 
281  virtual double IntersectImageWithLine(const double p1[3], const double p2[3], double t1,
282  double t2, vtkProp3D* prop, vtkImageMapper3D* mapper);
283 
284  virtual double IntersectProp3DWithLine(const double p1[3], const double p2[3], double t1,
285  double t2, double tol, vtkProp3D* prop, vtkAbstractMapper3D* mapper);
286 
287  static int ClipLineWithPlanes(vtkAbstractMapper3D* mapper, vtkMatrix4x4* propMatrix,
288  const double p1[3], const double p2[3], double& t1, double& t2, int& planeId);
289 
290  static int ClipLineWithExtent(const int extent[6], const double x1[3], const double x2[3],
291  double& t1, double& t2, int& planeId);
292 
293  static int ComputeSurfaceNormal(
294  vtkDataSet* data, vtkCell* cell, const double* weights, double normal[3]);
295 
296  static int ComputeSurfaceTCoord(
297  vtkDataSet* data, vtkCell* cell, const double* weights, double tcoord[3]);
298 
299  static vtkTypeBool HasSubCells(int cellType);
300 
301  static int GetNumberOfSubCells(vtkIdList* pointIds, int cellType);
302 
303  static void GetSubCell(
304  vtkDataSet* data, vtkIdList* pointIds, int subId, int cellType, vtkGenericCell* cell);
305 
306  static void SubCellFromCell(vtkGenericCell* cell, int subId);
307 
308  void SetImageDataPickInfo(const double x[3], const int extent[6]);
309 
310  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3], vtkImageData* data,
311  vtkDataArray* scalars, vtkPiecewiseFunction* scalarOpacity,
312  vtkPiecewiseFunction* gradientOpacity);
313 
315 
320 
323  int SubId;
324  double PCoords[3];
325 
326  int PointIJK[3];
327  int CellIJK[3];
328 
329  double PickNormal[3];
330  double MapperNormal[3];
331 
334 
336  double WordlPoint[3];
337 
338 private:
339  void ResetCellPickerInfo();
340 
341  vtkGenericCell* Cell; // used to accelerate picking
342  vtkIdList* PointIds; // used to accelerate picking
343  vtkDoubleArray* Gradients; // used in volume picking
344 
345  vtkCellPicker(const vtkCellPicker&) = delete;
346  void operator=(const vtkCellPicker&) = delete;
347 };
348 
349 VTK_ABI_NAMESPACE_END
350 #endif
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Defines a 1D piecewise function.
int Pick3DRay(VTK_FUTURE_CONST double selectionPt[3], VTK_FUTURE_CONST double orient[4], vtkRenderer *ren) override
Perform pick operation with selection point and orientation provided.
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:63
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:39
int vtkIdType
Definition: vtkType.h:363
vtkTypeBool UseVolumeGradientOpacity
provides thread-safe access to cells
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:52
dynamic, self-adjusting array of double
vtkIdType CellId
int vtkTypeBool
Definition: vtkABI.h:64
abstract class to specify cell behavior
Definition: vtkCell.h:50
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:45
list of point or cell ids
Definition: vtkIdList.h:25
vtkTypeBool PickClippingPlanes
static vtkPicker * New()
vtkBitArray * InMask
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
const std::string pointIds
handles properties associated with a texture map
Definition: vtkTexture.h:58
abstract class specifies interface to map 3D data
vtkCollection * Locators
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:77
#define VTK_MARSHALEXCLUDE(reason)
void Initialize() override
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:32
create and manipulate ordered lists of objects
Definition: vtkCollection.h:39
vtkTypeBool PickTextureData
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
#define VTK_MARSHALAUTO
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
RealT t2
Definition: PyrC2Basis.h:22
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform pick operation with selection point provided.
Abstract class for a HyperTreeGrid mapper.