Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkUnstructuredGridPartialPreIntegration.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkUnstructuredGridPartialPreIntegration.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 =========================================================================*/
00015 
00016 /*
00017  * Copyright 2004 Sandia Corporation.
00018  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00019  * license for use of this work by or on behalf of the
00020  * U.S. Government. Redistribution and use in source and binary forms, with
00021  * or without modification, are permitted provided that this Notice and any
00022  * statement of authorship are reproduced on all copies.
00023  */
00024 
00044 #ifndef __vtkUnstructuredGridPartialPreIntegration_h
00045 #define __vtkUnstructuredGridPartialPreIntegration_h
00046 
00047 #include "vtkUnstructuredGridVolumeRayIntegrator.h"
00048 #include "vtkMath.h" // For all the inline methods
00049 
00050 class vtkPartialPreIntegrationTransferFunction;
00051 class vtkVolumeProperty;
00052 
00053 class VTK_VOLUMERENDERING_EXPORT vtkUnstructuredGridPartialPreIntegration : public vtkUnstructuredGridVolumeRayIntegrator
00054 {
00055 public:
00056   vtkTypeRevisionMacro(vtkUnstructuredGridPartialPreIntegration,
00057                        vtkUnstructuredGridVolumeRayIntegrator);
00058   static vtkUnstructuredGridPartialPreIntegration *New();
00059   virtual void PrintSelf(ostream &os, vtkIndent indent);
00060 
00061   virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars);
00062 
00063   virtual void Integrate(vtkDoubleArray *intersectionLengths,
00064                          vtkDataArray *nearIntersections,
00065                          vtkDataArray *farIntersections,
00066                          float color[4]);
00067 
00069 
00071   static void IntegrateRay(double length,
00072                            double intensity_front, double attenuation_front,
00073                            double intensity_back, double attenuation_back,
00074                            float color[4]);
00075   static void IntegrateRay(double length,
00076                            const double color_front[3],
00077                            double attenuation_front,
00078                            const double color_back[3],
00079                            double attenuation_back,
00080                            float color[4]);
00082 
00087   static float Psi(float taufD, float taubD);
00088 
00089   static void BuildPsiTable();
00090 
00091 protected:
00092   vtkUnstructuredGridPartialPreIntegration();
00093   ~vtkUnstructuredGridPartialPreIntegration();
00094 
00095   vtkVolumeProperty *Property;
00096 
00097   vtkPartialPreIntegrationTransferFunction *TransferFunctions;
00098   vtkTimeStamp TransferFunctionsModified;
00099   int NumIndependentComponents;
00100 
00101 //BTX
00102   enum {PSI_TABLE_SIZE = 512};
00103 //ETX
00104   static float PsiTable[PSI_TABLE_SIZE*PSI_TABLE_SIZE];
00105   static int PsiTableBuilt;
00106 
00107 private:
00108   vtkUnstructuredGridPartialPreIntegration(const vtkUnstructuredGridPartialPreIntegration&);  // Not implemented.
00109   void operator=(const vtkUnstructuredGridPartialPreIntegration&);  // Not implemented.
00110 };
00111 
00112 inline float vtkUnstructuredGridPartialPreIntegration::Psi(float taufD,
00113                                                            float taubD)
00114 {
00115   float gammaf = taufD/(taufD+1);
00116   float gammab = taubD/(taubD+1);
00117   int gammafi = vtkMath::Floor(gammaf*PSI_TABLE_SIZE);
00118   int gammabi = vtkMath::Floor(gammab*PSI_TABLE_SIZE);
00119   return PsiTable[gammafi*PSI_TABLE_SIZE + gammabi];
00120 }
00121 
00122 inline void vtkUnstructuredGridPartialPreIntegration::IntegrateRay(
00123                                                        double length,
00124                                                        double intensity_front,
00125                                                        double attenuation_front,
00126                                                        double intensity_back,
00127                                                        double attenuation_back,
00128                                                        float color[4])
00129 {
00130   float taufD = length*attenuation_front;
00131   float taubD = length*attenuation_back;
00132   float Psi = vtkUnstructuredGridPartialPreIntegration::Psi(taufD, taubD);
00133   float zeta = (float)exp(-0.5*(taufD+taubD));
00134   float alpha = 1-zeta;
00135 
00136   float newintensity = (1-color[3])*(  intensity_front*(1-Psi)
00137                                      + intensity_back*(Psi-zeta) );
00138   // Is setting the RGB values the same the right thing to do?
00139   color[0] += newintensity;
00140   color[1] += newintensity;
00141   color[2] += newintensity;
00142   color[3] += (1-color[3])*alpha;
00143 }
00144 
00145 inline void vtkUnstructuredGridPartialPreIntegration::IntegrateRay(
00146                                                     double length,
00147                                                     const double color_front[3],
00148                                                     double attenuation_front,
00149                                                     const double color_back[3],
00150                                                     double attenuation_back,
00151                                                     float color[4])
00152 {
00153   float taufD = length*attenuation_front;
00154   float taubD = length*attenuation_back;
00155   float Psi = vtkUnstructuredGridPartialPreIntegration::Psi(taufD, taubD);
00156   float zeta = (float)exp(-0.5*(taufD+taubD));
00157   float alpha = 1-zeta;
00158 
00159   color[0] += (1-color[3])*(color_front[0]*(1-Psi) + color_back[0]*(Psi-zeta));
00160   color[1] += (1-color[3])*(color_front[1]*(1-Psi) + color_back[1]*(Psi-zeta));
00161   color[2] += (1-color[3])*(color_front[2]*(1-Psi) + color_back[2]*(Psi-zeta));
00162   color[3] += (1-color[3])*alpha;
00163 }
00164 
00165 #endif //__vtkUnstructuredGridPartialPreIntegration_h

Generated on Mon Jan 21 23:07:37 2008 for VTK by  doxygen 1.4.3-20050530