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 "vtkRenderingCoreModule.h" // For export macro 00050 #include "vtkPicker.h" 00051 00052 class vtkMapper; 00053 class vtkTexture; 00054 class vtkAbstractVolumeMapper; 00055 class vtkImageMapper3D; 00056 class vtkPlaneCollection; 00057 class vtkPiecewiseFunction; 00058 class vtkDataArray; 00059 class vtkDoubleArray; 00060 class vtkIdList; 00061 class vtkCell; 00062 class vtkGenericCell; 00063 class vtkImageData; 00064 class vtkAbstractCellLocator; 00065 class vtkCollection; 00066 class vtkMatrix4x4; 00067 00068 class VTKRENDERINGCORE_EXPORT vtkCellPicker : public vtkPicker 00069 { 00070 public: 00071 static vtkCellPicker *New(); 00072 vtkTypeMacro(vtkCellPicker, vtkPicker); 00073 void PrintSelf(ostream& os, vtkIndent indent); 00074 00076 00080 virtual int Pick(double selectionX, double selectionY, double selectionZ, 00081 vtkRenderer *renderer); 00083 00091 void AddLocator(vtkAbstractCellLocator *locator); 00092 00096 void RemoveLocator(vtkAbstractCellLocator *locator); 00097 00099 void RemoveAllLocators(); 00100 00102 00108 vtkSetMacro(VolumeOpacityIsovalue, double); 00109 vtkGetMacro(VolumeOpacityIsovalue, double); 00111 00113 00117 vtkSetMacro(UseVolumeGradientOpacity, int); 00118 vtkBooleanMacro(UseVolumeGradientOpacity, int); 00119 vtkGetMacro(UseVolumeGradientOpacity, int); 00121 00123 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 IntersectImageWithLine(const double p1[3], 00238 const double p2[3], 00239 double t1, double t2, 00240 vtkProp3D *prop, 00241 vtkImageMapper3D *mapper); 00242 00243 virtual double IntersectProp3DWithLine(const double p1[3], 00244 const double p2[3], 00245 double t1, double t2, double tol, 00246 vtkProp3D *prop, 00247 vtkAbstractMapper3D *mapper); 00248 00249 static int ClipLineWithPlanes(vtkAbstractMapper3D *mapper, 00250 vtkMatrix4x4 *propMatrix, 00251 const double p1[3], const double p2[3], 00252 double &t1, double &t2, int& planeId); 00253 00254 static int ClipLineWithExtent(const int extent[6], 00255 const double x1[3], const double x2[3], 00256 double &t1, double &t2, int &planeId); 00257 00258 static int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell, 00259 const double *weights, double normal[3]); 00260 00261 static int ComputeSurfaceTCoord(vtkDataSet *data, vtkCell *cell, 00262 const double *weights, double tcoord[3]); 00263 00264 static int HasSubCells(int cellType); 00265 00266 static int GetNumberOfSubCells(vtkIdList *pointIds, int cellType); 00267 00268 static void GetSubCell(vtkDataSet *data, vtkIdList *pointIds, int subId, 00269 int cellType, vtkGenericCell *cell); 00270 00271 static void SubCellFromCell(vtkGenericCell *cell, int subId); 00272 00273 void SetImageDataPickInfo(const double x[3], const int extent[6]); 00274 00275 double ComputeVolumeOpacity(const int xi[3], const double pcoords[3], 00276 vtkImageData *data, vtkDataArray *scalars, 00277 vtkPiecewiseFunction *scalarOpacity, 00278 vtkPiecewiseFunction *gradientOpacity); 00279 00280 vtkCollection *Locators; 00281 00282 double VolumeOpacityIsovalue; 00283 int UseVolumeGradientOpacity; 00284 int PickClippingPlanes; 00285 int ClippingPlaneId; 00286 00287 vtkIdType PointId; 00288 vtkIdType CellId; 00289 int SubId; 00290 double PCoords[3]; 00291 00292 int PointIJK[3]; 00293 int CellIJK[3]; 00294 00295 double PickNormal[3]; 00296 double MapperNormal[3]; 00297 00298 vtkTexture *Texture; 00299 int PickTextureData; 00300 00301 private: 00302 void ResetCellPickerInfo(); 00303 00304 vtkGenericCell *Cell; //used to accelerate picking 00305 vtkIdList *PointIds; // used to accelerate picking 00306 vtkDoubleArray *Gradients; //used in volume picking 00307 00308 private: 00309 vtkCellPicker(const vtkCellPicker&); // Not implemented. 00310 void operator=(const vtkCellPicker&); // Not implemented. 00311 }; 00312 00313 #endif 00314 00315