VTK  9.2.6
vtkHardwarePicker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHardwarePicker.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
39 #ifndef vtkHardwarePicker_h
40 #define vtkHardwarePicker_h
41 
42 #include "vtkAbstractPropPicker.h"
43 #include "vtkNew.h" // For vtkNew
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkSmartPointer.h" // For vtkSmartPointer
46 
48 class vtkCell;
50 class vtkDataSet;
51 class vtkSelection;
52 
53 class VTKRENDERINGCORE_EXPORT vtkHardwarePicker : public vtkAbstractPropPicker
54 {
55 public:
56  static vtkHardwarePicker* New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
61 
65  vtkSetMacro(SnapToMeshPoint, bool);
66  vtkGetMacro(SnapToMeshPoint, bool);
67  vtkBooleanMacro(SnapToMeshPoint, bool);
69 
71 
75  vtkSetMacro(PixelTolerance, int);
76  vtkGetMacro(PixelTolerance, int);
78 
80 
85  vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
87 
89 
95  vtkGetObjectMacro(DataSet, vtkDataSet);
97 
99 
105  vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
107 
109 
114  vtkGetMacro(FlatBlockIndex, vtkIdType);
116 
118 
128  vtkGetMacro(PointId, vtkIdType);
130 
132 
142  vtkGetMacro(CellId, vtkIdType);
144 
146 
158  vtkGetMacro(SubId, int);
160 
162 
174  vtkGetVector3Macro(PCoords, double);
176 
178 
191  vtkGetVectorMacro(PickNormal, double, 3);
193 
200  vtkGetMacro(NormalFlipped, bool);
201 
211  int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
212 
213 protected:
215  ~vtkHardwarePicker() override;
216 
217  void Initialize() override;
218  // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
219  int TypeDecipher(vtkProp*, vtkAbstractMapper3D**);
220 
229  void FixNormalSign();
230 
235  int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
236 
240  void ComputeIntersectionFromDataSet(vtkDataSet* ds);
241 
242  bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
243  int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
244 
245  vtkNew<vtkPropCollection> PickableProps; // list of pickable props
246  vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
247 
248  double NearRayPoint[3]; // near ray point
249  double FarRayPoint[3]; // far ray point
250 
251  vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
252  vtkDataSet* DataSet; // selected dataset (if there is one)
253  vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
254  vtkIdType FlatBlockIndex; // flat block index, for a composite data set
255 
256  vtkIdType PointId; // id of the picked point
257  vtkIdType CellId; // id of the picked cell
258  int SubId; // sub id of the picked cell
259  double PCoords[3]; // parametric coordinates of the picked point
260  double PickNormal[3]; // normal of the picked surface
261  bool NormalFlipped; // Flag to indicate if the normal has been flipped
262 
263 private:
264  vtkHardwarePicker(const vtkHardwarePicker&) = delete;
265  void operator=(const vtkHardwarePicker&) = delete;
266 };
267 
268 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkAbstractMapper3D * Mapper
vtkCompositeDataSet * CompositeDataSet
abstract specification for renderers
Definition: vtkRenderer.h:72
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:59
int vtkIdType
Definition: vtkType.h:332
void Initialize() override
abstract class to specify cell behavior
Definition: vtkCell.h:60
abstract superclass for composite (multi-block or AMR) datasets
a simple class to control print indentation
Definition: vtkIndent.h:39
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:39
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.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkPropCollection > PickableProps