00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkVolume.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00040 #ifndef __vtkVolume_h 00041 #define __vtkVolume_h 00042 00043 #include "vtkProp3D.h" 00044 00045 class vtkRenderer; 00046 class vtkPropCollection; 00047 class vtkVolumeCollection; 00048 class vtkWindow; 00049 class vtkVolumeProperty; 00050 class vtkVolumeMapper; 00051 00052 class VTK_RENDERING_EXPORT vtkVolume : public vtkProp3D 00053 { 00054 public: 00055 vtkTypeRevisionMacro(vtkVolume,vtkProp3D); 00056 void PrintSelf(ostream& os, vtkIndent indent); 00057 00061 static vtkVolume *New(); 00062 00064 00065 void SetMapper(vtkVolumeMapper *mapper); 00066 vtkGetObjectMacro(Mapper, vtkVolumeMapper); 00068 00070 00071 void SetProperty(vtkVolumeProperty *property); 00072 vtkVolumeProperty *GetProperty(); 00074 00078 void GetVolumes(vtkPropCollection *vc); 00079 00081 void Update(); 00082 00084 00086 float *GetBounds(); 00087 void GetBounds(float bounds[6]) { this->vtkProp3D::GetBounds( bounds ); }; 00088 float GetMinXBound(); 00089 float GetMaxXBound(); 00090 float GetMinYBound(); 00091 float GetMaxYBound(); 00092 float GetMinZBound(); 00093 float GetMaxZBound(); 00095 00097 unsigned long int GetMTime(); 00098 00103 unsigned long GetRedrawMTime(); 00104 00106 void ShallowCopy(vtkProp *prop); 00107 00108 //BTX 00114 int RenderTranslucentGeometry(vtkViewport *viewport); 00115 00120 void ReleaseGraphicsResources(vtkWindow *); 00121 00123 00125 float *GetCorrectedScalarOpacityArray(int); 00126 float *GetCorrectedScalarOpacityArray() 00127 {return this->GetCorrectedScalarOpacityArray(0);}; 00129 00131 00133 float *GetScalarOpacityArray(int); 00134 float *GetScalarOpacityArray(){return this->GetScalarOpacityArray(0);}; 00136 00138 00140 float *GetGradientOpacityArray(int); 00141 float *GetGradientOpacityArray(){return this->GetGradientOpacityArray(0);}; 00143 00145 00147 float *GetGrayArray(int); 00148 float *GetGrayArray(){return this->GetGrayArray(0);}; 00150 00152 00154 float *GetRGBArray(int); 00155 float *GetRGBArray(){return this->GetRGBArray(0);}; 00157 00159 00161 float GetGradientOpacityConstant(int); 00162 float GetGradientOpacityConstant() 00163 {return this->GetGradientOpacityConstant(0);}; 00165 00168 float GetArraySize () { return static_cast<float>(this->ArraySize); }; 00169 00172 void UpdateTransferFunctions( vtkRenderer *ren ); 00173 00175 00177 void UpdateScalarOpacityforSampleSize( vtkRenderer *ren, 00178 float sample_distance ); 00180 00181 //ETX 00182 00183 protected: 00184 vtkVolume(); 00185 ~vtkVolume(); 00186 00187 vtkVolumeMapper *Mapper; 00188 vtkVolumeProperty *Property; 00189 00190 // The rgb 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 rgb transfer 00193 // function. A time stamp is kept to know when it needs rebuilding 00194 float *RGBArray[VTK_MAX_VRCOMP]; 00195 vtkTimeStamp RGBArrayMTime[VTK_MAX_VRCOMP]; 00196 00197 // The gray 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 gray transfer 00200 // function. A time stamp is kept to know when it needs rebuilding 00201 float *GrayArray[VTK_MAX_VRCOMP]; 00202 vtkTimeStamp GrayArrayMTime[VTK_MAX_VRCOMP]; 00203 00204 // The scalar opacity transfer function array - for unsigned char data this 00205 // is 256 elements, for short or unsigned short it is 65536 elements 00206 // This is a sample at each scalar value of the opacity transfer 00207 // function. A time stamp is kept to know when it needs rebuilding 00208 float *ScalarOpacityArray[VTK_MAX_VRCOMP]; 00209 vtkTimeStamp ScalarOpacityArrayMTime[VTK_MAX_VRCOMP]; 00210 00211 // The corrected scalar opacity transfer function array - this is identical 00212 // to the opacity transfer function array when the step size is 1. 00213 // In other cases, it is corrected to reflect the new material thickness 00214 // modeled by a step size different than 1. 00215 float *CorrectedScalarOpacityArray[VTK_MAX_VRCOMP]; 00216 vtkTimeStamp CorrectedScalarOpacityArrayMTime[VTK_MAX_VRCOMP]; 00217 00218 // CorrectedStepSize is the step size currently modeled by 00219 // CorrectedArray. It is used to determine when the 00220 // CorrectedArray needs to be updated to match SampleDistance 00221 // in the volume mapper. 00222 float CorrectedStepSize; 00223 00224 // Number of elements in the rgb, gray, and opacity transfer function arrays 00225 int ArraySize; 00226 00227 // The magnitude of gradient opacity transfer function array 00228 float GradientOpacityArray[VTK_MAX_VRCOMP][256]; 00229 float GradientOpacityConstant[VTK_MAX_VRCOMP]; 00230 vtkTimeStamp GradientOpacityArrayMTime[VTK_MAX_VRCOMP]; 00231 00232 // Function to compute screen coverage of this volume 00233 float ComputeScreenCoverage( vtkViewport *vp ); 00234 00235 private: 00236 vtkVolume(const vtkVolume&); // Not implemented. 00237 void operator=(const vtkVolume&); // Not implemented. 00238 }; 00239 00240 #endif 00241