VTK  9.3.0
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 
30 #include "vtkAbstractPropPicker.h"
31 #include "vtkNew.h" // For vtkNew
32 #include "vtkRenderingCoreModule.h" // For export macro
33 #include "vtkSmartPointer.h" // For vtkSmartPointer
34 
35 VTK_ABI_NAMESPACE_BEGIN
37 class vtkCell;
39 class vtkDataSet;
40 class vtkSelection;
41 
42 class VTKRENDERINGCORE_EXPORT vtkHardwarePicker : public vtkAbstractPropPicker
43 {
44 public:
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 
202 protected:
204  ~vtkHardwarePicker() override;
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 
252 private:
253  vtkHardwarePicker(const vtkHardwarePicker&) = delete;
254  void operator=(const vtkHardwarePicker&) = delete;
255 };
256 
257 VTK_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:50
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:53
pick a point or snap to point of an actor/prop using graphics hardware
void Initialize() override
~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.
static vtkHardwarePicker * New()
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
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
abstract specification for renderers
Definition: vtkRenderer.h:62
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:50
@ data
Definition: vtkX3D.h:315
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:28
int vtkIdType
Definition: vtkType.h:315