VTK  9.3.20240527
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
35VTK_ABI_NAMESPACE_BEGIN
37class vtkCell;
39class vtkDataSet;
40class vtkSelection;
41
42class VTKRENDERINGCORE_EXPORT 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(CompositeDataSet, vtkCompositeDataSet);
96
98
103 vtkGetMacro(FlatBlockIndex, vtkIdType);
105
107
117 vtkGetMacro(PointId, vtkIdType);
119
121
131 vtkGetMacro(CellId, vtkIdType);
133
135
147 vtkGetMacro(SubId, int);
149
151
163 vtkGetVector3Macro(PCoords, double);
165
167
180 vtkGetVectorMacro(PickNormal, double, 3);
182
189 vtkGetMacro(NormalFlipped, bool);
190
200 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
201
202protected:
205
206 void Initialize() override;
207 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
209
219
224 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
225
230
231 bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
232 int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
233
234 vtkNew<vtkPropCollection> PickableProps; // list of pickable props
235 vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
236
237 double NearRayPoint[3]; // near ray point
238 double FarRayPoint[3]; // far ray point
239
240 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
241 vtkDataSet* DataSet; // selected dataset (if there is one)
242 vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
243 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
244
245 vtkIdType PointId; // id of the picked point
246 vtkIdType CellId; // id of the picked cell
247 int SubId; // sub id of the picked cell
248 double PCoords[3]; // parametric coordinates of the picked point
249 double PickNormal[3]; // normal of the picked surface
250 bool NormalFlipped; // Flag to indicate if the normal has been flipped
251
252private:
253 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
254 void operator=(const vtkHardwarePicker&) = delete;
255};
256
257VTK_ABI_NAMESPACE_END
258#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
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
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:160
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