VTK  9.5.2
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
23
24#ifndef vtkHardwarePicker_h
25#define vtkHardwarePicker_h
26
28#include "vtkNew.h" // For vtkNew
29#include "vtkRenderingCoreModule.h" // For export macro
30#include "vtkSmartPointer.h" // For vtkSmartPointer
31#include "vtkStringToken.h" // for vtkStringToken
32#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
33
34VTK_ABI_NAMESPACE_BEGIN
36class vtkCell;
38class vtkDataObject;
39class vtkDataSet;
40class vtkSelection;
41
42class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkHardwarePicker : public vtkAbstractPropPicker
43{
44public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
50
54 vtkSetMacro(SnapToMeshPoint, bool);
55 vtkGetMacro(SnapToMeshPoint, bool);
56 vtkBooleanMacro(SnapToMeshPoint, bool);
58
60
64 vtkSetMacro(PixelTolerance, int);
65 vtkGetMacro(PixelTolerance, int);
67
69
74 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
76
78
84 vtkGetObjectMacro(DataSet, vtkDataSet);
86
88
94 vtkGetObjectMacro(DataObject, vtkDataObject);
96
98
106
108
115
117
127 vtkGetMacro(PointId, vtkIdType);
129
131
141 vtkGetMacro(CellId, vtkIdType);
143
145
157 vtkGetMacro(SubId, int);
159
161
170
172
185
187
196
198
210 vtkGetVector3Macro(PCoords, double);
212
214
227 vtkGetVectorMacro(PickNormal, double, 3);
229
236 vtkGetMacro(NormalFlipped, bool);
237
247 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
248
249protected:
252
253 void Initialize() override;
254 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
256
266
271 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
272
277
278 bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
279 int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
280
281 vtkNew<vtkPropCollection> PickableProps; // list of pickable props
282 vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
283
284 double NearRayPoint[3]; // near ray point
285 double FarRayPoint[3]; // far ray point
286
287 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
288 vtkDataSet* DataSet; // selected dataset (if there is one)
289 vtkDataObject* DataObject; // selected dataobject (useful when the picked object is directly
290 // derived from vtkDataObject)
291 vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
292 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
293
294 vtkIdType PointId; // id of the picked point
295 vtkIdType CellId; // id of the picked cell
296 int SubId; // sub id of the picked cell
297 vtkIdType CellGridCellTypeId; // id of the picked cell type in a vtkCellGrid
298 vtkIdType CellGridSourceSpecId; // id of the picked cell/side spec in a vtkCellGrid. 0 is for cell
299 // spec, 1+ is for side specs
301 CellGridTupleId; // id of the picked tuple in the cell/side connectivity of a vtkCellGrid
302 double PCoords[3]; // parametric coordinates of the picked point
303 double PickNormal[3]; // normal of the picked surface
304 bool NormalFlipped; // Flag to indicate if the normal has been flipped
305
306private:
307 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
308 void operator=(const vtkHardwarePicker&) = delete;
309};
310
311VTK_ABI_NAMESPACE_END
312#endif
abstract class specifies interface to map 3D data
abstract class to specify cell behavior
Definition vtkCell.h:51
abstract superclass for composite (multi-block or AMR) datasets
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:56
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:29
Allocate and hold a VTK object.
Definition vtkNew.h:58
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:44
abstract specification for renderers
Definition vtkRenderer.h:60
data object that represents a "selection" in VTK.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:332
#define VTK_MARSHALAUTO