00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkVolume.h,v $ 00005 Language: C++ 00006 00007 00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 00009 All rights reserved. 00010 00011 Redistribution and use in source and binary forms, with or without 00012 modification, are permitted provided that the following conditions are met: 00013 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 00017 * Redistributions in binary form must reproduce the above copyright notice, 00018 this list of conditions and the following disclaimer in the documentation 00019 and/or other materials provided with the distribution. 00020 00021 * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names 00022 of any contributors may be used to endorse or promote products derived 00023 from this software without specific prior written permission. 00024 00025 * Modified source versions must be plainly marked as such, and must not be 00026 misrepresented as being the original software. 00027 00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00038 00039 =========================================================================*/ 00064 #ifndef __vtkVolume_h 00065 #define __vtkVolume_h 00066 00067 #include "vtkProp3D.h" 00068 #include "vtkTransform.h" 00069 #include "vtkVolumeProperty.h" 00070 #include "vtkVolumeMapper.h" 00071 00072 class vtkRenderer; 00073 class vtkPropCollection; 00074 class vtkVolumeCollection; 00075 class vtkWindow; 00076 00077 class VTK_RENDERING_EXPORT vtkVolume : public vtkProp3D 00078 { 00079 public: 00080 vtkTypeMacro(vtkVolume,vtkProp3D); 00081 void PrintSelf(ostream& os, vtkIndent indent); 00082 00086 static vtkVolume *New(); 00087 00089 00090 void SetMapper(vtkVolumeMapper *mapper); 00091 vtkGetObjectMacro(Mapper, vtkVolumeMapper); 00093 00095 00096 void SetProperty(vtkVolumeProperty *property); 00097 vtkVolumeProperty *GetProperty(); 00099 00103 void GetVolumes(vtkPropCollection *vc); 00104 00106 void Update(); 00107 00109 00111 float *GetBounds(); 00112 void GetBounds(float bounds[6]) { this->vtkProp3D::GetBounds( bounds ); }; 00113 float GetMinXBound(); 00114 float GetMaxXBound(); 00115 float GetMinYBound(); 00116 float GetMaxYBound(); 00117 float GetMinZBound(); 00118 float GetMaxZBound(); 00120 00122 unsigned long int GetMTime(); 00123 00128 unsigned long GetRedrawMTime(); 00129 00131 void ShallowCopy(vtkProp *prop); 00132 00133 //BTX 00139 int RenderTranslucentGeometry(vtkViewport *viewport); 00140 00145 void ReleaseGraphicsResources(vtkWindow *); 00146 00149 float *GetCorrectedScalarOpacityArray () { return this->CorrectedScalarOpacityArray; }; 00150 00153 float *GetScalarOpacityArray () { return this->ScalarOpacityArray; }; 00154 00157 float *GetGradientOpacityArray () { return this->GradientOpacityArray; }; 00158 00161 float *GetGrayArray () { return this->GrayArray; }; 00162 00165 float *GetRGBArray () { return this->RGBArray; }; 00166 00169 float GetGradientOpacityConstant () { return this->GradientOpacityConstant; }; 00170 00173 float GetArraySize () { return this->ArraySize; }; 00174 00177 void UpdateTransferFunctions( vtkRenderer *ren ); 00178 00181 void UpdateScalarOpacityforSampleSize( vtkRenderer *ren, float sample_distance ); 00182 00183 //ETX 00184 00185 protected: 00186 vtkVolume(); 00187 ~vtkVolume(); 00188 00189 vtkVolumeMapper *Mapper; 00190 vtkVolumeProperty *Property; 00191 00192 // The rgb transfer function array - for unsigned char data this 00193 // is 256 elements, for short or unsigned short it is 65536 elements 00194 // This is a sample at each scalar value of the rgb transfer 00195 // function. A time stamp is kept to know when it needs rebuilding 00196 float *RGBArray; 00197 vtkTimeStamp RGBArrayMTime; 00198 00199 // The gray transfer function array - for unsigned char data this 00200 // is 256 elements, for short or unsigned short it is 65536 elements 00201 // This is a sample at each scalar value of the gray transfer 00202 // function. A time stamp is kept to know when it needs rebuilding 00203 float *GrayArray; 00204 vtkTimeStamp GrayArrayMTime; 00205 00206 // The scalar opacity transfer function array - for unsigned char data this 00207 // is 256 elements, for short or unsigned short it is 65536 elements 00208 // This is a sample at each scalar value of the opacity transfer 00209 // function. A time stamp is kept to know when it needs rebuilding 00210 float *ScalarOpacityArray; 00211 vtkTimeStamp ScalarOpacityArrayMTime; 00212 00213 // The corrected scalar opacity transfer function array - this is identical 00214 // to the opacity transfer function array when the step size is 1. 00215 // In other cases, it is corrected to reflect the new material thickness 00216 // modeled by a step size different than 1. 00217 float *CorrectedScalarOpacityArray; 00218 00219 // CorrectedStepSize is the step size currently modeled by 00220 // CorrectedArray. It is used to determine when the 00221 // CorrectedArray needs to be updated to match SampleDistance 00222 // in the volume mapper. 00223 float CorrectedStepSize; 00224 00225 // CorrectedSOArrayMTime - compared with OpacityArrayMTime for update 00226 vtkTimeStamp CorrectedScalarOpacityArrayMTime; 00227 00228 // Number of elements in the rgb, gray, and opacity transfer function arrays 00229 int ArraySize; 00230 00231 // The magnitude of gradient opacity transfer function array 00232 float GradientOpacityArray[256]; 00233 float GradientOpacityConstant; 00234 vtkTimeStamp GradientOpacityArrayMTime; 00235 00236 // Function to compute screen coverage of this volume 00237 float ComputeScreenCoverage( vtkViewport *vp ); 00238 private: 00239 vtkVolume(const vtkVolume&); // Not implemented. 00240 void operator=(const vtkVolume&); // Not implemented. 00241 }; 00242 00243 #endif 00244