VTK
|
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 vtkImageMapper3D; 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 class vtkMatrix4x4; 00066 00067 class VTK_RENDERING_EXPORT vtkCellPicker : public vtkPicker 00068 { 00069 public: 00070 static vtkCellPicker *New(); 00071 vtkTypeMacro(vtkCellPicker, vtkPicker); 00072 void PrintSelf(ostream& os, vtkIndent indent); 00073 00075 00079 virtual int Pick(double selectionX, double selectionY, double selectionZ, 00080 vtkRenderer *renderer); 00082 00090 void AddLocator(vtkAbstractCellLocator *locator); 00091 00095 void RemoveLocator(vtkAbstractCellLocator *locator); 00096 00098 void RemoveAllLocators(); 00099 00101 00107 vtkSetMacro(VolumeOpacityIsovalue, double); 00108 vtkGetMacro(VolumeOpacityIsovalue, double); 00110 00112 00116 vtkSetMacro(UseVolumeGradientOpacity, int); 00117 vtkBooleanMacro(UseVolumeGradientOpacity, int); 00118 vtkGetMacro(UseVolumeGradientOpacity, int); 00120 00122 00131 vtkSetMacro(PickClippingPlanes, int); 00132 vtkBooleanMacro(PickClippingPlanes, int); 00133 vtkGetMacro(PickClippingPlanes, int); 00135 00137 00143 vtkGetMacro(ClippingPlaneId, int); 00145 00147 00150 vtkGetVectorMacro(PickNormal, double, 3); 00152 00154 00156 vtkGetVector3Macro(MapperNormal, double); 00158 00160 00162 vtkGetVector3Macro(PointIJK, int); 00164 00166 00169 vtkGetVector3Macro(CellIJK, int); 00171 00173 00175 vtkGetMacro(PointId, vtkIdType); 00177 00179 00180 vtkGetMacro(CellId, vtkIdType); 00182 00184 00186 vtkGetMacro(SubId, int); 00188 00190 00193 vtkGetVector3Macro(PCoords, double); 00195 00198 vtkTexture *GetTexture() { return this->Texture; }; 00199 00201 00209 vtkSetMacro(PickTextureData, int); 00210 vtkBooleanMacro(PickTextureData, int); 00211 vtkGetMacro(PickTextureData, int); 00213 00214 protected: 00215 vtkCellPicker(); 00216 ~vtkCellPicker(); 00217 00218 void Initialize(); 00219 00220 virtual void ResetPickInfo(); 00221 00222 virtual double IntersectWithLine(double p1[3], double p2[3], double tol, 00223 vtkAssemblyPath *path, vtkProp3D *p, 00224 vtkAbstractMapper3D *m); 00225 00226 virtual double IntersectActorWithLine(const double p1[3], const double p2[3], 00227 double t1, double t2, double tol, 00228 vtkProp3D *prop, vtkMapper *mapper); 00229 00230 virtual double IntersectVolumeWithLine(const double p1[3], 00231 const double p2[3], 00232 double t1, double t2, 00233 vtkProp3D *prop, 00234 vtkAbstractVolumeMapper *mapper); 00235 00236 virtual double IntersectImageWithLine(const double p1[3], 00237 const double p2[3], 00238 double t1, double t2, 00239 vtkProp3D *prop, 00240 vtkImageMapper3D *mapper); 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(vtkAbstractMapper3D *mapper, 00249 vtkMatrix4x4 *propMatrix, 00250 const double p1[3], const double p2[3], 00251 double &t1, double &t2, int& planeId); 00252 00253 static int ClipLineWithExtent(const int extent[6], 00254 const double x1[3], const double x2[3], 00255 double &t1, double &t2, int &planeId); 00256 00257 static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell, 00258 const double *weights, double normal[3]); 00259 00260 static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell, 00261 const double *weights, double tcoord[3]); 00262 00263 static int HasSubCells(int cellType); 00264 00265 static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType); 00266 00267 static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId, 00268 int cellType, vtkGenericCell *cell); 00269 00270 static void SubCellFromCell(vtkGenericCell *cell, int subId); 00271 00272 void SetImageDataPickInfo(const double x[3], const int extent[6]); 00273 00274 double ComputeVolumeOpacity(const int xi[3], const double pcoords[3], 00275 vtkImageData *data, vtkDataArray *scalars, 00276 vtkPiecewiseFunction *scalarOpacity, 00277 vtkPiecewiseFunction *gradientOpacity); 00278 00279 vtkCollection *Locators; 00280 00281 double VolumeOpacityIsovalue; 00282 int UseVolumeGradientOpacity; 00283 int PickClippingPlanes; 00284 int ClippingPlaneId; 00285 00286 vtkIdType PointId; 00287 vtkIdType CellId; 00288 int SubId; 00289 double PCoords[3]; 00290 00291 int PointIJK[3]; 00292 int CellIJK[3]; 00293 00294 double PickNormal[3]; 00295 double MapperNormal[3]; 00296 00297 vtkTexture *Texture; 00298 int PickTextureData; 00299 00300 private: 00301 void ResetCellPickerInfo(); 00302 00303 vtkGenericCell *Cell; //used to accelerate picking 00304 vtkIdList *PointIds; // used to accelerate picking 00305 vtkDoubleArray *Gradients; //used in volume picking 00306 00307 private: 00308 vtkCellPicker(const vtkCellPicker&); // Not implemented. 00309 void operator=(const vtkCellPicker&); // Not implemented. 00310 }; 00311 00312 #endif 00313 00314