VTK
dox/Rendering/vtkCellPicker.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCellPicker.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00046 #ifndef __vtkCellPicker_h
00047 #define __vtkCellPicker_h
00048 
00049 #include "vtkPicker.h"
00050 
00051 class vtkMapper;
00052 class vtkTexture;
00053 class vtkAbstractVolumeMapper;
00054 class vtkImageActor;
00055 class vtkPlaneCollection;
00056 class vtkPiecewiseFunction;
00057 class vtkDataArray;
00058 class vtkDoubleArray;
00059 class vtkIdList;
00060 class vtkCell;
00061 class vtkGenericCell;
00062 class vtkImageData;
00063 class vtkAbstractCellLocator;
00064 class vtkCollection;
00065 
00066 class VTK_RENDERING_EXPORT vtkCellPicker : public vtkPicker
00067 {
00068 public:
00069   static vtkCellPicker *New();
00070   vtkTypeMacro(vtkCellPicker, vtkPicker);
00071   void PrintSelf(ostream& os, vtkIndent indent);
00072 
00074 
00078   virtual int Pick(double selectionX, double selectionY, double selectionZ, 
00079                    vtkRenderer *renderer);  
00081 
00089   void AddLocator(vtkAbstractCellLocator *locator);
00090 
00094   void RemoveLocator(vtkAbstractCellLocator *locator);
00095 
00097   void RemoveAllLocators();
00098 
00100 
00106   vtkSetMacro(VolumeOpacityIsovalue, double);
00107   vtkGetMacro(VolumeOpacityIsovalue, double);
00109 
00111 
00115   vtkSetMacro(UseVolumeGradientOpacity, int);
00116   vtkBooleanMacro(UseVolumeGradientOpacity, int);
00117   vtkGetMacro(UseVolumeGradientOpacity, int);
00119 
00121 
00132   vtkSetMacro(PickClippingPlanes, int);
00133   vtkBooleanMacro(PickClippingPlanes, int);
00134   vtkGetMacro(PickClippingPlanes, int);
00136 
00138 
00144   vtkGetMacro(ClippingPlaneId, int);
00146 
00148 
00151   vtkGetVectorMacro(PickNormal, double, 3);
00153 
00155 
00157   vtkGetVector3Macro(MapperNormal, double);
00159 
00161 
00163   vtkGetVector3Macro(PointIJK, int);
00165 
00167 
00170   vtkGetVector3Macro(CellIJK, int);
00172 
00174 
00176   vtkGetMacro(PointId, vtkIdType);
00178 
00180 
00181   vtkGetMacro(CellId, vtkIdType);
00183 
00185 
00187   vtkGetMacro(SubId, int);
00189 
00191 
00194   vtkGetVector3Macro(PCoords, double);
00196 
00199   vtkTexture *GetTexture() { return this->Texture; };
00200 
00202 
00210   vtkSetMacro(PickTextureData, int);
00211   vtkBooleanMacro(PickTextureData, int);
00212   vtkGetMacro(PickTextureData, int);
00214 
00215 protected:
00216   vtkCellPicker();
00217   ~vtkCellPicker();
00218 
00219   void Initialize();
00220 
00221   virtual void ResetPickInfo();
00222 
00223   virtual double IntersectWithLine(double p1[3], double p2[3], double tol, 
00224                                   vtkAssemblyPath *path, vtkProp3D *p, 
00225                                   vtkAbstractMapper3D *m);
00226 
00227   virtual double IntersectActorWithLine(const double p1[3], const double p2[3],
00228                                         double t1, double t2, double tol, 
00229                                         vtkProp3D *prop, vtkMapper *mapper);
00230 
00231   virtual double IntersectVolumeWithLine(const double p1[3],
00232                                          const double p2[3],
00233                                          double t1, double t2,
00234                                          vtkProp3D *prop, 
00235                                          vtkAbstractVolumeMapper *mapper);
00236 
00237   virtual double IntersectImageActorWithLine(const double p1[3],
00238                                              const double p2[3],
00239                                              double t1, double t2,
00240                                              vtkImageActor *imageActor);
00241 
00242   virtual double IntersectProp3DWithLine(const double p1[3],
00243                                          const double p2[3],
00244                                          double t1, double t2, double tol, 
00245                                          vtkProp3D *prop,
00246                                          vtkAbstractMapper3D *mapper);
00247 
00248   static int ClipLineWithPlanes(vtkPlaneCollection *planes,
00249                                 const double p1[3], const double p2[3],
00250                                 double &t1, double &t2, int& planeId);
00251 
00252   static int ClipLineWithExtent(const int extent[6],
00253                                 const double x1[3], const double x2[3],
00254                                 double &t1, double &t2, int &planeId);
00255 
00256   static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell,
00257                                   const double *weights, double normal[3]);
00258 
00259   static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell,
00260                                   const double *weights, double tcoord[3]);
00261 
00262   static int HasSubCells(int cellType);
00263 
00264   static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType);
00265 
00266   static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId,
00267                          int cellType, vtkGenericCell *cell);
00268 
00269   static void SubCellFromCell(vtkGenericCell *cell, int subId);
00270 
00271   void SetImageDataPickInfo(const double x[3], const int extent[6]);
00272 
00273   double ComputeVolumeOpacity(const int xi[3], const double pcoords[3],
00274                               vtkImageData *data, vtkDataArray *scalars,
00275                               vtkPiecewiseFunction *scalarOpacity,
00276                               vtkPiecewiseFunction *gradientOpacity);
00277 
00278   vtkCollection *Locators;
00279 
00280   double VolumeOpacityIsovalue;
00281   int UseVolumeGradientOpacity;
00282   int PickClippingPlanes;
00283   int ClippingPlaneId;
00284 
00285   vtkIdType PointId;
00286   vtkIdType CellId;
00287   int SubId;
00288   double PCoords[3];
00289 
00290   int PointIJK[3];
00291   int CellIJK[3];
00292 
00293   double PickNormal[3];
00294   double MapperNormal[3];
00295 
00296   vtkTexture *Texture;
00297   int PickTextureData;
00298 
00299 private:
00300   void ResetCellPickerInfo();
00301 
00302   vtkGenericCell *Cell; //used to accelerate picking
00303   vtkIdList *PointIds; // used to accelerate picking
00304   vtkDoubleArray *Gradients; //used in volume picking
00305   
00306 private:
00307   vtkCellPicker(const vtkCellPicker&);  // Not implemented.
00308   void operator=(const vtkCellPicker&);  // Not implemented.
00309 };
00310 
00311 #endif
00312 
00313