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 vtkImageActor;
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 
67 {
68 public:
69  static vtkCellPicker *New();
70  vtkTypeMacro(vtkCellPicker, vtkPicker);
71  void PrintSelf(ostream& os, vtkIndent indent);
72 
74 
78  virtual int Pick(double selectionX, double selectionY, double selectionZ,
79  vtkRenderer *renderer);
81 
89  void AddLocator(vtkAbstractCellLocator *locator);
90 
94  void RemoveLocator(vtkAbstractCellLocator *locator);
95 
97  void RemoveAllLocators();
98 
100 
106  vtkSetMacro(VolumeOpacityIsovalue, double);
107  vtkGetMacro(VolumeOpacityIsovalue, double);
109 
111 
115  vtkSetMacro(UseVolumeGradientOpacity, int);
116  vtkBooleanMacro(UseVolumeGradientOpacity, int);
117  vtkGetMacro(UseVolumeGradientOpacity, int);
119 
121 
132  vtkSetMacro(PickClippingPlanes, int);
133  vtkBooleanMacro(PickClippingPlanes, int);
134  vtkGetMacro(PickClippingPlanes, int);
136 
138 
144  vtkGetMacro(ClippingPlaneId, int);
146 
148 
151  vtkGetVectorMacro(PickNormal, double, 3);
153 
155 
157  vtkGetVector3Macro(MapperNormal, double);
159 
161 
163  vtkGetVector3Macro(PointIJK, int);
165 
167 
170  vtkGetVector3Macro(CellIJK, int);
172 
174 
176  vtkGetMacro(PointId, vtkIdType);
178 
180 
181  vtkGetMacro(CellId, vtkIdType);
183 
185 
187  vtkGetMacro(SubId, int);
189 
191 
194  vtkGetVector3Macro(PCoords, double);
196 
199  vtkTexture *GetTexture() { return this->Texture; };
200 
202 
210  vtkSetMacro(PickTextureData, int);
211  vtkBooleanMacro(PickTextureData, int);
212  vtkGetMacro(PickTextureData, int);
214 
215 protected:
216  vtkCellPicker();
217  ~vtkCellPicker();
218 
219  void Initialize();
220 
221  virtual void ResetPickInfo();
222 
223  virtual double IntersectWithLine(double p1[3], double p2[3], double tol,
224  vtkAssemblyPath *path, vtkProp3D *p,
226 
227  virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
228  double t1, double t2, double tol,
229  vtkProp3D *prop, vtkMapper *mapper);
230 
231  virtual double IntersectVolumeWithLine(const double p1[3],
232  const double p2[3],
233  double t1, double t2,
234  vtkProp3D *prop,
235  vtkAbstractVolumeMapper *mapper);
236 
237  virtual double IntersectImageActorWithLine(const double p1[3],
238  const double p2[3],
239  double t1, double t2,
240  vtkImageActor *imageActor);
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(vtkPlaneCollection *planes,
249  const double p1[3], const double p2[3],
250  double &t1, double &t2, int& planeId);
251 
252  static int ClipLineWithExtent(const int extent[6],
253  const double x1[3], const double x2[3],
254  double &t1, double &t2, int &planeId);
255 
256  static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
257  const double *weights, double normal[3]);
258 
259  static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
260  const double *weights, double tcoord[3]);
261 
262  static int HasSubCells(int cellType);
263 
264  static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
265 
266  static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
267  int cellType, vtkGenericCell *cell);
268 
269  static void SubCellFromCell(vtkGenericCell *cell, int subId);
270 
271  void SetImageDataPickInfo(const double x[3], const int extent[6]);
272 
273  double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
274  vtkImageData *data, vtkDataArray *scalars,
275  vtkPiecewiseFunction *scalarOpacity,
276  vtkPiecewiseFunction *gradientOpacity);
277 
279 
284 
287  int SubId;
288  double PCoords[3];
289 
290  int PointIJK[3];
291  int CellIJK[3];
292 
293  double PickNormal[3];
294  double MapperNormal[3];
295 
298 
299 private:
300  void ResetCellPickerInfo();
301 
302  vtkGenericCell *Cell; //used to accelerate picking
303  vtkIdList *PointIds; // used to accelerate picking
304  vtkDoubleArray *Gradients; //used in volume picking
305 
306 private:
307  vtkCellPicker(const vtkCellPicker&); // Not implemented.
308  void operator=(const vtkCellPicker&); // Not implemented.
309 };
310 
311 #endif
312 
313