VTK  9.4.20241016
vtkHardwarePicker.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
27#ifndef vtkHardwarePicker_h
28#define vtkHardwarePicker_h
29
31#include "vtkNew.h" // For vtkNew
32#include "vtkRenderingCoreModule.h" // For export macro
33#include "vtkSmartPointer.h" // For vtkSmartPointer
34#include "vtkStringToken.h" // for vtkStringToken
35
36VTK_ABI_NAMESPACE_BEGIN
38class vtkCell;
40class vtkDataObject;
41class vtkDataSet;
42class vtkSelection;
43
44class VTKRENDERINGCORE_EXPORT vtkHardwarePicker : public vtkAbstractPropPicker
45{
46public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
52
56 vtkSetMacro(SnapToMeshPoint, bool);
57 vtkGetMacro(SnapToMeshPoint, bool);
58 vtkBooleanMacro(SnapToMeshPoint, bool);
60
62
66 vtkSetMacro(PixelTolerance, int);
67 vtkGetMacro(PixelTolerance, int);
69
71
76 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
78
80
86 vtkGetObjectMacro(DataSet, vtkDataSet);
88
90
96 vtkGetObjectMacro(DataObject, vtkDataObject);
98
100
106 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
108
110
115 vtkGetMacro(FlatBlockIndex, vtkIdType);
117
119
129 vtkGetMacro(PointId, vtkIdType);
131
133
143 vtkGetMacro(CellId, vtkIdType);
145
147
159 vtkGetMacro(SubId, int);
161
163
170 vtkGetMacro(CellGridCellTypeId, vtkIdType);
172
174
185 vtkGetMacro(CellGridSourceSpecId, vtkIdType);
187
189
196 vtkGetMacro(CellGridTupleId, vtkIdType);
198
200
212 vtkGetVector3Macro(PCoords, double);
214
216
229 vtkGetVectorMacro(PickNormal, double, 3);
231
238 vtkGetMacro(NormalFlipped, bool);
239
249 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
250
251protected:
254
255 void Initialize() override;
256 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
258
268
273 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
274
279
280 bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
281 int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
282
283 vtkNew<vtkPropCollection> PickableProps; // list of pickable props
284 vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
285
286 double NearRayPoint[3]; // near ray point
287 double FarRayPoint[3]; // far ray point
288
289 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
290 vtkDataSet* DataSet; // selected dataset (if there is one)
291 vtkDataObject* DataObject; // selected dataobject (useful when the picked object is directly
292 // derived from vtkDataObject)
293 vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
294 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
295
296 vtkIdType PointId; // id of the picked point
297 vtkIdType CellId; // id of the picked cell
298 int SubId; // sub id of the picked cell
299 vtkIdType CellGridCellTypeId; // id of the picked cell type in a vtkCellGrid
300 vtkIdType CellGridSourceSpecId; // id of the picked cell/side spec in a vtkCellGrid. 0 is for cell
301 // spec, 1+ is for side specs
303 CellGridTupleId; // id of the picked tuple in the cell/side connectivity of a vtkCellGrid
304 double PCoords[3]; // parametric coordinates of the picked point
305 double PickNormal[3]; // normal of the picked surface
306 bool NormalFlipped; // Flag to indicate if the normal has been flipped
307
308private:
309 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
310 void operator=(const vtkHardwarePicker&) = delete;
311};
312
313VTK_ABI_NAMESPACE_END
314#endif
abstract class specifies interface to map 3D data
abstract API for pickers that can pick an instance of vtkProp
abstract class to specify cell behavior
Definition vtkCell.h:130
abstract superclass for composite (multi-block or AMR) datasets
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
pick a point or snap to point of an actor/prop using graphics hardware
void Initialize() override
static vtkHardwarePicker * New()
~vtkHardwarePicker() override
vtkAbstractMapper3D * Mapper
vtkDataObject * DataObject
void ComputeIntersectionFromDataSet(vtkDataSet *ds)
Compute the intersection using provided dataset.
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform the pick operation set the PickedProp.
void FixNormalSign()
Fix normal sign in case the orientation of the picked cell is wrong.
vtkNew< vtkPropCollection > PickableProps
int TypeDecipher(vtkProp *, vtkAbstractMapper3D **)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCompositeDataSet * CompositeDataSet
vtkSmartPointer< vtkSelection > HardwareSelection
int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell, double *weights)
Compute the intersection normal either by interpolating the point normals at the intersected point,...
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
abstract specification for renderers
data object that represents a "selection" in VTK.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:315