VTK  9.7.1
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
30 #ifndef vtkHardwarePicker_h
31 #define vtkHardwarePicker_h
32 
33 #include "vtkAbstractPropPicker.h"
34 #include "vtkNew.h" // For vtkNew
35 #include "vtkRenderingCoreModule.h" // For export macro
36 #include "vtkSmartPointer.h" // For vtkSmartPointer
37 #include "vtkStringToken.h" // for vtkStringToken
38 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
39 
40 VTK_ABI_NAMESPACE_BEGIN
42 class vtkCell;
44 class vtkDataObject;
45 class vtkDataSet;
46 class vtkSelection;
47 
48 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkHardwarePicker : public vtkAbstractPropPicker
49 {
50 public:
51  static vtkHardwarePicker* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
60  vtkSetMacro(SnapToMeshPoint, bool);
61  vtkGetMacro(SnapToMeshPoint, bool);
62  vtkBooleanMacro(SnapToMeshPoint, bool);
64 
66 
70  vtkSetMacro(PixelTolerance, int);
71  vtkGetMacro(PixelTolerance, int);
73 
75 
80  vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
82 
84 
90  vtkGetObjectMacro(DataSet, vtkDataSet);
92 
94 
100  vtkGetObjectMacro(DataObject, vtkDataObject);
102 
104 
110  vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
112 
114 
119  vtkGetMacro(FlatBlockIndex, vtkIdType);
121 
123 
133  vtkGetMacro(PointId, vtkIdType);
135 
137 
147  vtkGetMacro(CellId, vtkIdType);
149 
151 
163  vtkGetMacro(SubId, int);
165 
167 
174  vtkGetMacro(CellGridCellTypeId, vtkIdType);
176 
178 
189  vtkGetMacro(CellGridSourceSpecId, vtkIdType);
191 
193 
200  vtkGetMacro(CellGridTupleId, vtkIdType);
202 
204 
216  vtkGetVector3Macro(PCoords, double);
218 
220 
233  vtkGetVectorMacro(PickNormal, double, 3);
235 
242  vtkGetMacro(NormalFlipped, bool);
243 
253  int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
254 
255 protected:
257  ~vtkHardwarePicker() override;
258 
259  void Initialize() override;
260  // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
261  int TypeDecipher(vtkProp*, vtkAbstractMapper3D**);
262 
271  void FixNormalSign();
272 
277  int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
278 
282  void ComputeIntersectionFromDataSet(vtkDataSet* ds);
283 
284  bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
285  int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
286 
287  vtkNew<vtkPropCollection> PickableProps; // list of pickable props
288  vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
289 
290  double NearRayPoint[3]; // near ray point
291  double FarRayPoint[3]; // far ray point
292 
293  vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
294  vtkDataSet* DataSet; // selected dataset (if there is one)
295  vtkDataObject* DataObject; // selected dataobject (useful when the picked object is directly
296  // derived from vtkDataObject)
297  vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
298  vtkIdType FlatBlockIndex; // flat block index, for a composite data set
299 
300  vtkIdType PointId; // id of the picked point
301  vtkIdType CellId; // id of the picked cell
302  int SubId; // sub id of the picked cell
303  vtkIdType CellGridCellTypeId; // id of the picked cell type in a vtkCellGrid
304  vtkIdType CellGridSourceSpecId; // id of the picked cell/side spec in a vtkCellGrid. 0 is for cell
305  // spec, 1+ is for side specs
306  vtkIdType
307  CellGridTupleId; // id of the picked tuple in the cell/side connectivity of a vtkCellGrid
308  double PCoords[3]; // parametric coordinates of the picked point
309  double PickNormal[3]; // normal of the picked surface
310  bool NormalFlipped; // Flag to indicate if the normal has been flipped
311 
312 private:
313  vtkHardwarePicker(const vtkHardwarePicker&) = delete;
314  void operator=(const vtkHardwarePicker&) = delete;
315 };
316 
317 VTK_ABI_NAMESPACE_END
318 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
vtkIdType CellGridCellTypeId
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkAbstractMapper3D * Mapper
vtkCompositeDataSet * CompositeDataSet
abstract specification for renderers
Definition: vtkRenderer.h:63
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:49
int vtkIdType
Definition: vtkType.h:363
vtkIdType CellGridSourceSpecId
void Initialize() override
vtkDataObject * DataObject
abstract class to specify cell behavior
Definition: vtkCell.h:50
abstract superclass for composite (multi-block or AMR) datasets
a simple class to control print indentation
Definition: vtkIndent.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:28
abstract class specifies interface to map 3D data
pick a point or snap to point of an actor/prop using graphics hardware
abstract API for pickers that can pick an instance of vtkProp
vtkSmartPointer< vtkSelection > HardwareSelection
virtual int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer)=0
Perform pick operation with selection point provided.
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
general representation of visualization data
Definition: vtkDataObject.h:55
vtkNew< vtkPropCollection > PickableProps