00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkVolume.h,v $ 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 =========================================================================*/ 00033 #ifndef __vtkVolume_h 00034 #define __vtkVolume_h 00035 00036 #include "vtkProp3D.h" 00037 00038 class vtkRenderer; 00039 class vtkPropCollection; 00040 class vtkVolumeCollection; 00041 class vtkWindow; 00042 class vtkVolumeProperty; 00043 class vtkAbstractVolumeMapper; 00044 00045 class VTK_RENDERING_EXPORT vtkVolume : public vtkProp3D 00046 { 00047 public: 00048 vtkTypeRevisionMacro(vtkVolume,vtkProp3D); 00049 void PrintSelf(ostream& os, vtkIndent indent); 00050 00054 static vtkVolume *New(); 00055 00057 00058 void SetMapper(vtkAbstractVolumeMapper *mapper); 00059 vtkGetObjectMacro(Mapper, vtkAbstractVolumeMapper); 00061 00063 00064 void SetProperty(vtkVolumeProperty *property); 00065 vtkVolumeProperty *GetProperty(); 00067 00071 void GetVolumes(vtkPropCollection *vc); 00072 00074 void Update(); 00075 00077 00079 double *GetBounds(); 00080 void GetBounds(double bounds[6]) { this->vtkProp3D::GetBounds( bounds ); }; 00081 double GetMinXBound(); 00082 double GetMaxXBound(); 00083 double GetMinYBound(); 00084 double GetMaxYBound(); 00085 double GetMinZBound(); 00086 double GetMaxZBound(); 00088 00090 unsigned long int GetMTime(); 00091 00096 unsigned long GetRedrawMTime(); 00097 00099 void ShallowCopy(vtkProp *prop); 00100 00101 //BTX 00107 int RenderVolumetricGeometry(vtkViewport *viewport); 00108 00113 void ReleaseGraphicsResources(vtkWindow *); 00114 00116 00118 float *GetCorrectedScalarOpacityArray(int); 00119 float *GetCorrectedScalarOpacityArray() 00120 {return this->GetCorrectedScalarOpacityArray(0);}; 00122 00124 00126 float *GetScalarOpacityArray(int); 00127 float *GetScalarOpacityArray(){return this->GetScalarOpacityArray(0);}; 00129 00131 00133 float *GetGradientOpacityArray(int); 00134 float *GetGradientOpacityArray(){return this->GetGradientOpacityArray(0);}; 00136 00138 00140 float *GetGrayArray(int); 00141 float *GetGrayArray(){return this->GetGrayArray(0);}; 00143 00145 00147 float *GetRGBArray(int); 00148 float *GetRGBArray(){return this->GetRGBArray(0);}; 00150 00152 00154 float GetGradientOpacityConstant(int); 00155 float GetGradientOpacityConstant() 00156 {return this->GetGradientOpacityConstant(0);}; 00158 00161 float GetArraySize () { return static_cast<float>(this->ArraySize); }; 00162 00165 void UpdateTransferFunctions( vtkRenderer *ren ); 00166 00168 00170 void UpdateScalarOpacityforSampleSize( vtkRenderer *ren, 00171 float sample_distance ); 00173 00174 //ETX 00175 00176 protected: 00177 vtkVolume(); 00178 ~vtkVolume(); 00179 00180 vtkAbstractVolumeMapper *Mapper; 00181 vtkVolumeProperty *Property; 00182 00183 // The rgb transfer function array - for unsigned char data this 00184 // is 256 elements, for short or unsigned short it is 65536 elements 00185 // This is a sample at each scalar value of the rgb transfer 00186 // function. A time stamp is kept to know when it needs rebuilding 00187 float *RGBArray[VTK_MAX_VRCOMP]; 00188 vtkTimeStamp RGBArrayMTime[VTK_MAX_VRCOMP]; 00189 00190 // The gray transfer function array - for unsigned char data this 00191 // is 256 elements, for short or unsigned short it is 65536 elements 00192 // This is a sample at each scalar value of the gray transfer 00193 // function. A time stamp is kept to know when it needs rebuilding 00194 float *GrayArray[VTK_MAX_VRCOMP]; 00195 vtkTimeStamp GrayArrayMTime[VTK_MAX_VRCOMP]; 00196 00197 // The scalar opacity transfer function array - for unsigned char data this 00198 // is 256 elements, for short or unsigned short it is 65536 elements 00199 // This is a sample at each scalar value of the opacity transfer 00200 // function. A time stamp is kept to know when it needs rebuilding 00201 float *ScalarOpacityArray[VTK_MAX_VRCOMP]; 00202 vtkTimeStamp ScalarOpacityArrayMTime[VTK_MAX_VRCOMP]; 00203 00204 // The corrected scalar opacity transfer function array - this is identical 00205 // to the opacity transfer function array when the step size is 1. 00206 // In other cases, it is corrected to reflect the new material thickness 00207 // modeled by a step size different than 1. 00208 float *CorrectedScalarOpacityArray[VTK_MAX_VRCOMP]; 00209 vtkTimeStamp CorrectedScalarOpacityArrayMTime[VTK_MAX_VRCOMP]; 00210 00211 // CorrectedStepSize is the step size currently modeled by 00212 // CorrectedArray. It is used to determine when the 00213 // CorrectedArray needs to be updated to match SampleDistance 00214 // in the volume mapper. 00215 float CorrectedStepSize; 00216 00217 // Number of elements in the rgb, gray, and opacity transfer function arrays 00218 int ArraySize; 00219 00220 // The magnitude of gradient opacity transfer function array 00221 float GradientOpacityArray[VTK_MAX_VRCOMP][256]; 00222 float GradientOpacityConstant[VTK_MAX_VRCOMP]; 00223 vtkTimeStamp GradientOpacityArrayMTime[VTK_MAX_VRCOMP]; 00224 00225 // Function to compute screen coverage of this volume 00226 float ComputeScreenCoverage( vtkViewport *vp ); 00227 00228 private: 00229 vtkVolume(const vtkVolume&); // Not implemented. 00230 void operator=(const vtkVolume&); // Not implemented. 00231 }; 00232 00233 #endif 00234