00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00046 #ifndef __vtkUnstructuredGridPreIntegration_h
00047 #define __vtkUnstructuredGridPreIntegration_h
00048
00049 #include "vtkUnstructuredGridVolumeRayIntegrator.h"
00050
00051 class vtkVolumeProperty;
00052
00053 class VTK_VOLUMERENDERING_EXPORT vtkUnstructuredGridPreIntegration : public vtkUnstructuredGridVolumeRayIntegrator
00054 {
00055 public:
00056 vtkTypeRevisionMacro(vtkUnstructuredGridPreIntegration,
00057 vtkUnstructuredGridVolumeRayIntegrator);
00058 static vtkUnstructuredGridPreIntegration *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 vtkGetObjectMacro(Integrator, vtkUnstructuredGridVolumeRayIntegrator);
00072 virtual void SetIntegrator(vtkUnstructuredGridVolumeRayIntegrator *);
00074
00076
00077 vtkSetMacro(IntegrationTableScalarResolution, int);
00078 vtkGetMacro(IntegrationTableScalarResolution, int);
00079 vtkSetMacro(IntegrationTableLengthResolution, int);
00080 vtkGetMacro(IntegrationTableLengthResolution, int);
00082
00084
00085 virtual double GetIntegrationTableScalarShift(int component = 0);
00086 virtual double GetIntegrationTableScalarScale(int component = 0);
00087 virtual double GetIntegrationTableLengthScale();
00089
00091
00095 vtkGetMacro(IncrementalPreIntegration, int);
00096 vtkSetMacro(IncrementalPreIntegration, int);
00097 vtkBooleanMacro(IncrementalPreIntegration, int);
00099
00109 virtual float *GetPreIntegrationTable(int component = 0);
00110
00112
00114 float *GetTableEntry(double scalar_front, double scalar_back, double lenth,
00115 int component = 0);
00117
00119
00122 float *GetIndexedTableEntry(int scalar_front_index, int scalar_back_index,
00123 int length_index, int component = 0);
00125
00126 protected:
00127 vtkUnstructuredGridPreIntegration();
00128 ~vtkUnstructuredGridPreIntegration();
00129
00130 vtkUnstructuredGridVolumeRayIntegrator *Integrator;
00131
00132 vtkVolume *Volume;
00133 vtkVolumeProperty *Property;
00134 double MaxLength;
00135
00136 int NumComponents;
00137 float **IntegrationTable;
00138 double *IntegrationTableScalarShift;
00139 double *IntegrationTableScalarScale;
00140 double IntegrationTableLengthScale;
00141 vtkTimeStamp IntegrationTableBuilt;
00142
00143 int IntegrationTableScalarResolution;
00144 int IntegrationTableLengthResolution;
00145
00146 int IncrementalPreIntegration;
00147
00148 virtual void BuildPreIntegrationTables(vtkDataArray *scalars);
00149
00150 private:
00151 vtkUnstructuredGridPreIntegration(const vtkUnstructuredGridPreIntegration&);
00152 void operator=(const vtkUnstructuredGridPreIntegration&);
00153 };
00154
00155 inline float *vtkUnstructuredGridPreIntegration::GetIndexedTableEntry(
00156 int scalar_front_index,
00157 int scalar_back_index,
00158 int length_index,
00159 int component)
00160 {
00161
00162
00163
00164 if (scalar_front_index < 0) scalar_front_index = 0;
00165 if (scalar_front_index >= this->IntegrationTableScalarResolution)
00166 scalar_front_index = this->IntegrationTableScalarResolution - 1;
00167 if (scalar_back_index < 0) scalar_back_index = 0;
00168 if (scalar_back_index >= this->IntegrationTableScalarResolution)
00169 scalar_back_index = this->IntegrationTableScalarResolution - 1;
00170 if (length_index < 0) length_index = 0;
00171 if (length_index >= this->IntegrationTableLengthResolution)
00172 length_index = this->IntegrationTableLengthResolution - 1;
00173
00174 return ( this->IntegrationTable[component]
00175 + 4*( ( ( length_index*this->IntegrationTableScalarResolution
00176 + scalar_back_index)
00177 * this->IntegrationTableScalarResolution)
00178 + scalar_front_index));
00179 }
00180
00181 inline float *vtkUnstructuredGridPreIntegration::GetTableEntry(
00182 double scalar_front, double scalar_back, double length, int component)
00183 {
00184 int sfi = (int)( scalar_front
00185 *this->IntegrationTableScalarScale[component]
00186 + this->IntegrationTableScalarShift[component] + 0.5);
00187 int sbi = (int)( scalar_back*this->IntegrationTableScalarScale[component]
00188 + this->IntegrationTableScalarShift[component] + 0.5);
00189 int li = (int)(length*this->IntegrationTableLengthScale + 0.5);
00190 return this->GetIndexedTableEntry(sfi, sbi, li, component);
00191 }
00192
00193 #endif //__vtkUnstructuredGridPreIntegration_h