00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00043 #ifndef __vtkCellPicker_h
00044 #define __vtkCellPicker_h
00045
00046 #include "vtkPicker.h"
00047
00048 class vtkMapper;
00049 class vtkTexture;
00050 class vtkAbstractVolumeMapper;
00051 class vtkImageActor;
00052 class vtkPlaneCollection;
00053 class vtkPiecewiseFunction;
00054 class vtkDataArray;
00055 class vtkDoubleArray;
00056 class vtkIdList;
00057 class vtkCell;
00058 class vtkGenericCell;
00059 class vtkImageData;
00060 class vtkAbstractCellLocator;
00061 class vtkCollection;
00062
00063 class VTK_RENDERING_EXPORT vtkCellPicker : public vtkPicker
00064 {
00065 public:
00066 static vtkCellPicker *New();
00067 vtkTypeRevisionMacro(vtkCellPicker, vtkPicker);
00068 void PrintSelf(ostream& os, vtkIndent indent);
00069
00071
00075 virtual int Pick(double selectionX, double selectionY, double selectionZ,
00076 vtkRenderer *renderer);
00078
00086 void AddLocator(vtkAbstractCellLocator *locator);
00087
00091 void RemoveLocator(vtkAbstractCellLocator *locator);
00092
00094 void RemoveAllLocators();
00095
00097
00103 vtkSetMacro(VolumeOpacityIsovalue, double);
00104 vtkGetMacro(VolumeOpacityIsovalue, double);
00106
00108
00112 vtkSetMacro(UseVolumeGradientOpacity, int);
00113 vtkBooleanMacro(UseVolumeGradientOpacity, int);
00114 vtkGetMacro(UseVolumeGradientOpacity, int);
00116
00118
00129 vtkSetMacro(PickClippingPlanes, int);
00130 vtkBooleanMacro(PickClippingPlanes, int);
00131 vtkGetMacro(PickClippingPlanes, int);
00133
00135
00141 vtkGetMacro(ClippingPlaneId, int);
00143
00145
00148 vtkGetVectorMacro(PickNormal, double, 3);
00150
00152
00154 vtkGetVector3Macro(MapperNormal, double);
00156
00158
00160 vtkGetVector3Macro(PointIJK, int);
00162
00164
00167 vtkGetVector3Macro(CellIJK, int);
00169
00171
00173 vtkGetMacro(PointId, vtkIdType);
00175
00177
00178 vtkGetMacro(CellId, vtkIdType);
00180
00182
00184 vtkGetMacro(SubId, int);
00186
00188
00191 vtkGetVector3Macro(PCoords, double);
00193
00196 vtkTexture *GetTexture() { return this->Texture; };
00197
00199
00207 vtkSetMacro(PickTextureData, int);
00208 vtkBooleanMacro(PickTextureData, int);
00209 vtkGetMacro(PickTextureData, int);
00211
00212 protected:
00213 vtkCellPicker();
00214 ~vtkCellPicker();
00215
00216 void Initialize();
00217
00218 virtual void ResetPickInfo();
00219
00220 virtual double IntersectWithLine(double p1[3], double p2[3], double tol,
00221 vtkAssemblyPath *path, vtkProp3D *p,
00222 vtkAbstractMapper3D *m);
00223
00224 virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
00225 double t1, double t2, double tol,
00226 vtkProp3D *prop, vtkMapper *mapper);
00227
00228 virtual double IntersectVolumeWithLine(const double p1[3],
00229 const double p2[3],
00230 double t1, double t2,
00231 vtkProp3D *prop,
00232 vtkAbstractVolumeMapper *mapper);
00233
00234 virtual double IntersectImageActorWithLine(const double p1[3],
00235 const double p2[3],
00236 double t1, double t2,
00237 vtkImageActor *imageActor);
00238
00239 virtual double IntersectProp3DWithLine(const double p1[3],
00240 const double p2[3],
00241 double t1, double t2, double tol,
00242 vtkProp3D *prop,
00243 vtkAbstractMapper3D *mapper);
00244
00245 static int ClipLineWithPlanes(vtkPlaneCollection *planes,
00246 const double p1[3], const double p2[3],
00247 double &t1, double &t2, int& planeId);
00248
00249 static int ClipLineWithExtent(const int extent[6],
00250 const double x1[3], const double x2[3],
00251 double &t1, double &t2, int &planeId);
00252
00253 static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
00254 const double *weights, double normal[3]);
00255
00256 static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
00257 const double *weights, double tcoord[3]);
00258
00259 static int HasSubCells(int cellType);
00260
00261 static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
00262
00263 static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
00264 int cellType, vtkGenericCell *cell);
00265
00266 static void SubCellFromCell(vtkGenericCell *cell, int subId);
00267
00268 void SetImageDataPickInfo(const double x[3], const int extent[6]);
00269
00270 double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
00271 vtkImageData *data, vtkDataArray *scalars,
00272 vtkPiecewiseFunction *scalarOpacity,
00273 vtkPiecewiseFunction *gradientOpacity);
00274
00275 vtkCollection *Locators;
00276
00277 double VolumeOpacityIsovalue;
00278 int UseVolumeGradientOpacity;
00279 int PickClippingPlanes;
00280 int ClippingPlaneId;
00281
00282 vtkIdType PointId;
00283 vtkIdType CellId;
00284 int SubId;
00285 double PCoords[3];
00286
00287 int PointIJK[3];
00288 int CellIJK[3];
00289
00290 double PickNormal[3];
00291 double MapperNormal[3];
00292
00293 vtkTexture *Texture;
00294 int PickTextureData;
00295
00296 private:
00297 void ResetCellPickerInfo();
00298
00299 vtkGenericCell *Cell;
00300 vtkIdList *PointIds;
00301 vtkDoubleArray *Gradients;
00302
00303 private:
00304 vtkCellPicker(const vtkCellPicker&);
00305 void operator=(const vtkCellPicker&);
00306 };
00307
00308 #endif
00309
00310