VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkUnstructuredGridPreIntegration.h 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 00046 #ifndef __vtkUnstructuredGridPreIntegration_h 00047 #define __vtkUnstructuredGridPreIntegration_h 00048 00049 #include "vtkRenderingVolumeModule.h" // For export macro 00050 #include "vtkUnstructuredGridVolumeRayIntegrator.h" 00051 00052 class vtkVolumeProperty; 00053 00054 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridPreIntegration : public vtkUnstructuredGridVolumeRayIntegrator 00055 { 00056 public: 00057 vtkTypeMacro(vtkUnstructuredGridPreIntegration, 00058 vtkUnstructuredGridVolumeRayIntegrator); 00059 static vtkUnstructuredGridPreIntegration *New(); 00060 virtual void PrintSelf(ostream &os, vtkIndent indent); 00061 00062 virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars); 00063 00064 virtual void Integrate(vtkDoubleArray *intersectionLengths, 00065 vtkDataArray *nearIntersections, 00066 vtkDataArray *farIntersections, 00067 float color[4]); 00068 00070 00072 vtkGetObjectMacro(Integrator, vtkUnstructuredGridVolumeRayIntegrator); 00073 virtual void SetIntegrator(vtkUnstructuredGridVolumeRayIntegrator *); 00075 00077 00078 vtkSetMacro(IntegrationTableScalarResolution, int); 00079 vtkGetMacro(IntegrationTableScalarResolution, int); 00080 vtkSetMacro(IntegrationTableLengthResolution, int); 00081 vtkGetMacro(IntegrationTableLengthResolution, int); 00083 00085 00086 virtual double GetIntegrationTableScalarShift(int component = 0); 00087 virtual double GetIntegrationTableScalarScale(int component = 0); 00088 virtual double GetIntegrationTableLengthScale(); 00090 00092 00096 vtkGetMacro(IncrementalPreIntegration, int); 00097 vtkSetMacro(IncrementalPreIntegration, int); 00098 vtkBooleanMacro(IncrementalPreIntegration, int); 00100 00110 virtual float *GetPreIntegrationTable(int component = 0); 00111 00113 00115 float *GetTableEntry(double scalar_front, double scalar_back, double lenth, 00116 int component = 0); 00118 00120 00123 float *GetIndexedTableEntry(int scalar_front_index, int scalar_back_index, 00124 int length_index, int component = 0); 00126 00127 protected: 00128 vtkUnstructuredGridPreIntegration(); 00129 ~vtkUnstructuredGridPreIntegration(); 00130 00131 vtkUnstructuredGridVolumeRayIntegrator *Integrator; 00132 00133 vtkVolume *Volume; 00134 vtkVolumeProperty *Property; 00135 double MaxLength; 00136 00137 int NumComponents; 00138 float **IntegrationTable; 00139 double *IntegrationTableScalarShift; 00140 double *IntegrationTableScalarScale; 00141 double IntegrationTableLengthScale; 00142 vtkTimeStamp IntegrationTableBuilt; 00143 00144 int IntegrationTableScalarResolution; 00145 int IntegrationTableLengthResolution; 00146 00147 int IncrementalPreIntegration; 00148 00149 virtual void BuildPreIntegrationTables(vtkDataArray *scalars); 00150 00151 private: 00152 vtkUnstructuredGridPreIntegration(const vtkUnstructuredGridPreIntegration&); // Not implemented. 00153 void operator=(const vtkUnstructuredGridPreIntegration&); // Not implemented 00154 }; 00155 00156 inline float *vtkUnstructuredGridPreIntegration::GetIndexedTableEntry( 00157 int scalar_front_index, 00158 int scalar_back_index, 00159 int length_index, 00160 int component) 00161 { 00162 // Snap entries to bounds. I don't really want to spend cycles doing 00163 // this, but I've had the ray caster give me values that are noticeably 00164 // out of bounds. 00165 if (scalar_front_index < 0) scalar_front_index = 0; 00166 if (scalar_front_index >= this->IntegrationTableScalarResolution) 00167 scalar_front_index = this->IntegrationTableScalarResolution - 1; 00168 if (scalar_back_index < 0) scalar_back_index = 0; 00169 if (scalar_back_index >= this->IntegrationTableScalarResolution) 00170 scalar_back_index = this->IntegrationTableScalarResolution - 1; 00171 if (length_index < 0) length_index = 0; 00172 if (length_index >= this->IntegrationTableLengthResolution) 00173 length_index = this->IntegrationTableLengthResolution - 1; 00174 00175 return ( this->IntegrationTable[component] 00176 + 4*( ( ( length_index*this->IntegrationTableScalarResolution 00177 + scalar_back_index) 00178 * this->IntegrationTableScalarResolution) 00179 + scalar_front_index)); 00180 } 00181 00182 inline float *vtkUnstructuredGridPreIntegration::GetTableEntry( 00183 double scalar_front, double scalar_back, double length, int component) 00184 { 00185 int sfi = static_cast<int>( scalar_front 00186 *this->IntegrationTableScalarScale[component] 00187 + this->IntegrationTableScalarShift[component] + 0.5); 00188 int sbi = static_cast<int>( scalar_back*this->IntegrationTableScalarScale[component] 00189 + this->IntegrationTableScalarShift[component] + 0.5); 00190 int li = static_cast<int>(length*this->IntegrationTableLengthScale + 0.5); 00191 return this->GetIndexedTableEntry(sfi, sbi, li, component); 00192 } 00193 00194 #endif //__vtkUnstructuredGridPreIntegration_h