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 "vtkUnstructuredGridVolumeRayIntegrator.h" 00050 00051 class vtkVolumeProperty; 00052 00053 class VTK_VOLUMERENDERING_EXPORT vtkUnstructuredGridPreIntegration : public vtkUnstructuredGridVolumeRayIntegrator 00054 { 00055 public: 00056 vtkTypeMacro(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&); // Not implemented. 00152 void operator=(const vtkUnstructuredGridPreIntegration&); // Not implemented 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 // Snap entries to bounds. I don't really want to spend cycles doing 00162 // this, but I've had the ray caster give me values that are noticeably 00163 // out of bounds. 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 = static_cast<int>( scalar_front 00185 *this->IntegrationTableScalarScale[component] 00186 + this->IntegrationTableScalarShift[component] + 0.5); 00187 int sbi = static_cast<int>( scalar_back*this->IntegrationTableScalarScale[component] 00188 + this->IntegrationTableScalarShift[component] + 0.5); 00189 int li = static_cast<int>(length*this->IntegrationTableLengthScale + 0.5); 00190 return this->GetIndexedTableEntry(sfi, sbi, li, component); 00191 } 00192 00193 #endif //__vtkUnstructuredGridPreIntegration_h