VTK
vtkCellPicker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellPicker.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 =========================================================================*/
46 #ifndef __vtkCellPicker_h
47 #define __vtkCellPicker_h
48 
49 #include "vtkPicker.h"
50 
51 class vtkMapper;
52 class vtkTexture;
54 class vtkImageMapper3D;
55 class vtkPlaneCollection;
57 class vtkDataArray;
58 class vtkDoubleArray;
59 class vtkIdList;
60 class vtkCell;
61 class vtkGenericCell;
62 class vtkImageData;
64 class vtkCollection;
65 class vtkMatrix4x4;
66 
68 {
69 public:
70  static vtkCellPicker *New();
71  vtkTypeMacro(vtkCellPicker, vtkPicker);
72  void PrintSelf(ostream& os, vtkIndent indent);
73 
75 
79  virtual int Pick(double selectionX, double selectionY, double selectionZ,
80  vtkRenderer *renderer);
82 
90  void AddLocator(vtkAbstractCellLocator *locator);
91 
95  void RemoveLocator(vtkAbstractCellLocator *locator);
96 
98  void RemoveAllLocators();
99 
101 
107  vtkSetMacro(VolumeOpacityIsovalue, double);
108  vtkGetMacro(VolumeOpacityIsovalue, double);
110 
112 
116  vtkSetMacro(UseVolumeGradientOpacity, int);
117  vtkBooleanMacro(UseVolumeGradientOpacity, int);
118  vtkGetMacro(UseVolumeGradientOpacity, int);
120 
122 
131  vtkSetMacro(PickClippingPlanes, int);
132  vtkBooleanMacro(PickClippingPlanes, int);
133  vtkGetMacro(PickClippingPlanes, int);
135 
137 
143  vtkGetMacro(ClippingPlaneId, int);
145 
147 
150  vtkGetVectorMacro(PickNormal, double, 3);
152 
154 
156  vtkGetVector3Macro(MapperNormal, double);
158 
160 
162  vtkGetVector3Macro(PointIJK, int);
164 
166 
169  vtkGetVector3Macro(CellIJK, int);
171 
173 
175  vtkGetMacro(PointId, vtkIdType);
177 
179 
180  vtkGetMacro(CellId, vtkIdType);
182 
184 
186  vtkGetMacro(SubId, int);
188 
190 
193  vtkGetVector3Macro(PCoords, double);
195 
198  vtkTexture *GetTexture() { return this->Texture; };
199 
201 
209  vtkSetMacro(PickTextureData, int);
210  vtkBooleanMacro(PickTextureData, int);
211  vtkGetMacro(PickTextureData, int);
213 
214 protected:
215  vtkCellPicker();
216  ~vtkCellPicker();
217 
218  void Initialize();
219 
220  virtual void ResetPickInfo();
221 
222  virtual double IntersectWithLine(double p1[3], double p2[3], double tol,
223  vtkAssemblyPath *path, vtkProp3D *p,
225 
226  virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
227  double t1, double t2, double tol,
228  vtkProp3D *prop, vtkMapper *mapper);
229 
230  virtual double IntersectVolumeWithLine(const double p1[3],
231  const double p2[3],
232  double t1, double t2,
233  vtkProp3D *prop,
234  vtkAbstractVolumeMapper *mapper);
235 
236  virtual double IntersectImageWithLine(const double p1[3],
237  const double p2[3],
238  double t1, double t2,
239  vtkProp3D *prop,
240  vtkImageMapper3D *mapper);
241 
242  virtual double IntersectProp3DWithLine(const double p1[3],
243  const double p2[3],
244  double t1, double t2, double tol,
245  vtkProp3D *prop,
246  vtkAbstractMapper3D *mapper);
247 
248  static int ClipLineWithPlanes(vtkAbstractMapper3D *mapper,
249  vtkMatrix4x4 *propMatrix,
250  const double p1[3], const double p2[3],
251  double &t1, double &t2, int& planeId);
252 
253  static int ClipLineWithExtent(const int extent[6],
254  const double x1[3], const double x2[3],
255  double &t1, double &t2, int &planeId);
256 
257  static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
258  const double *weights, double normal[3]);
259 
260  static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
261  const double *weights, double tcoord[3]);
262 
263  static int HasSubCells(int cellType);
264 
265  static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
266 
267  static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
268  int cellType, vtkGenericCell *cell);
269 
270  static void SubCellFromCell(vtkGenericCell *cell, int subId);
271 
272  void SetImageDataPickInfo(const double x[3], const int extent[6]);
273 
274  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
275  vtkImageData *data, vtkDataArray *scalars,
276  vtkPiecewiseFunction *scalarOpacity,
277  vtkPiecewiseFunction *gradientOpacity);
278 
280 
285 
288  int SubId;
289  double PCoords[3];
290 
291  int PointIJK[3];
292  int CellIJK[3];
293 
294  double PickNormal[3];
295  double MapperNormal[3];
296 
299 
300 private:
301  void ResetCellPickerInfo();
302 
303  vtkGenericCell *Cell; //used to accelerate picking
304  vtkIdList *PointIds; // used to accelerate picking
305  vtkDoubleArray *Gradients; //used in volume picking
306 
307 private:
308  vtkCellPicker(const vtkCellPicker&); // Not implemented.
309  void operator=(const vtkCellPicker&); // Not implemented.
310 };
311 
312 #endif
313 
314