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
43#include "vtkNew.h" // For vtkNew
44#include "vtkRenderingCoreModule.h" // For export macro
45#include "vtkSmartPointer.h" // For vtkSmartPointer
46
48class vtkCell;
50class vtkDataSet;
51class vtkSelection;
52
53class VTKRENDERINGCORE_EXPORT vtkHardwarePicker : public vtkAbstractPropPicker
54{
55public:
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
213protected:
216
217 void Initialize() override;
218 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
220
230
235 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
236
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
263private:
264 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
265 void operator=(const vtkHardwarePicker&) = delete;
266};
267
268#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:61
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
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:40
Allocate and hold a VTK object.
Definition: vtkNew.h:62
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
abstract specification for renderers
Definition: vtkRenderer.h:73
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:60
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:332