VTK
vtkUnstructuredGridPartialPreIntegration.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUnstructuredGridPartialPreIntegration.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 /*
17  * Copyright 2004 Sandia Corporation.
18  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
19  * license for use of this work by or on behalf of the
20  * U.S. Government. Redistribution and use in source and binary forms, with
21  * or without modification, are permitted provided that this Notice and any
22  * statement of authorship are reproduced on all copies.
23  */
24 
45 #ifndef vtkUnstructuredGridPartialPreIntegration_h
46 #define vtkUnstructuredGridPartialPreIntegration_h
47 
48 #include "vtkRenderingVolumeModule.h" // For export macro
50 #include "vtkMath.h" // For all the inline methods
51 
52 class vtkPartialPreIntegrationTransferFunction;
53 class vtkVolumeProperty;
54 
56 {
57 public:
61  virtual void PrintSelf(ostream &os, vtkIndent indent);
62 
63  virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars);
64 
65  virtual void Integrate(vtkDoubleArray *intersectionLengths,
66  vtkDataArray *nearIntersections,
67  vtkDataArray *farIntersections,
68  float color[4]);
69 
71 
75  static void IntegrateRay(double length,
76  double intensity_front, double attenuation_front,
77  double intensity_back, double attenuation_back,
78  float color[4]);
79  static void IntegrateRay(double length,
80  const double color_front[3],
81  double attenuation_front,
82  const double color_back[3],
83  double attenuation_back,
84  float color[4]);
86 
88 
94  static float Psi(float taufD, float taubD);
95  static float *GetPsiTable(int &size);
96  static void BuildPsiTable();
98 
99 protected:
102 
104 
105  vtkPartialPreIntegrationTransferFunction *TransferFunctions;
108 
109  enum {PSI_TABLE_SIZE = 512};
110 
111  static float PsiTable[PSI_TABLE_SIZE*PSI_TABLE_SIZE];
112  static int PsiTableBuilt;
113 
114 private:
116  void operator=(const vtkUnstructuredGridPartialPreIntegration&) VTK_DELETE_FUNCTION;
117 };
118 
120  float taubD)
121 {
122  float gammaf = taufD/(taufD+1);
123  float gammab = taubD/(taubD+1);
124  int gammafi = vtkMath::Floor(gammaf*PSI_TABLE_SIZE);
125  int gammabi = vtkMath::Floor(gammab*PSI_TABLE_SIZE);
126  return PsiTable[gammafi*PSI_TABLE_SIZE + gammabi];
127 }
128 
130 {
132  return PsiTable;
133 }
134 
136  double length,
137  double intensity_front,
138  double attenuation_front,
139  double intensity_back,
140  double attenuation_back,
141  float color[4])
142 {
143  float taufD = length*attenuation_front;
144  float taubD = length*attenuation_back;
146  float zeta = static_cast<float>(exp(-0.5*(taufD+taubD)));
147  float alpha = 1-zeta;
148 
149  float newintensity = (1-color[3])*( intensity_front*(1-Psi)
150  + intensity_back*(Psi-zeta) );
151  // Is setting the RGB values the same the right thing to do?
152  color[0] += newintensity;
153  color[1] += newintensity;
154  color[2] += newintensity;
155  color[3] += (1-color[3])*alpha;
156 }
157 
159  double length,
160  const double color_front[3],
161  double attenuation_front,
162  const double color_back[3],
163  double attenuation_back,
164  float color[4])
165 {
166  float taufD = length*attenuation_front;
167  float taubD = length*attenuation_back;
169  float zeta = static_cast<float>(exp(-0.5*(taufD+taubD)));
170  float alpha = 1-zeta;
171 
172  color[0] += (1-color[3])*(color_front[0]*(1-Psi) + color_back[0]*(Psi-zeta));
173  color[1] += (1-color[3])*(color_front[1]*(1-Psi) + color_back[1]*(Psi-zeta));
174  color[2] += (1-color[3])*(color_front[2]*(1-Psi) + color_back[2]*(Psi-zeta));
175  color[3] += (1-color[3])*alpha;
176 }
177 
178 #endif //vtkUnstructuredGridPartialPreIntegration_h
vtkUnstructuredGridVolumeRayIntegrator
a superclass for volume ray integration functions
Definition: vtkUnstructuredGridVolumeRayIntegrator.h:45
vtkMath::Floor
static int Floor(double x)
Rounds a double to the nearest integer not greater than itself.
Definition: vtkMath.h:1244
vtkUnstructuredGridPartialPreIntegration::BuildPsiTable
static void BuildPsiTable()
vtkX3D::alpha
@ alpha
Definition: vtkX3D.h:250
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:51
vtkMath.h
vtkUnstructuredGridPartialPreIntegration::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkUnstructuredGridPartialPreIntegration::PsiTableBuilt
static int PsiTableBuilt
Definition: vtkUnstructuredGridPartialPreIntegration.h:112
vtkX3D::length
@ length
Definition: vtkX3D.h:393
vtkUnstructuredGridPartialPreIntegration::TransferFunctions
vtkPartialPreIntegrationTransferFunction * TransferFunctions
Definition: vtkUnstructuredGridPartialPreIntegration.h:105
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkUnstructuredGridPartialPreIntegration::Property
vtkVolumeProperty * Property
Definition: vtkUnstructuredGridPartialPreIntegration.h:103
vtkUnstructuredGridPartialPreIntegration::New
static vtkUnstructuredGridPartialPreIntegration * New()
vtkUnstructuredGridPartialPreIntegration::~vtkUnstructuredGridPartialPreIntegration
~vtkUnstructuredGridPartialPreIntegration()
vtkUnstructuredGridPartialPreIntegration::PsiTable
static float PsiTable[PSI_TABLE_SIZE *PSI_TABLE_SIZE]
Definition: vtkUnstructuredGridPartialPreIntegration.h:111
vtkUnstructuredGridPartialPreIntegration::TransferFunctionsModified
vtkTimeStamp TransferFunctionsModified
Definition: vtkUnstructuredGridPartialPreIntegration.h:106
vtkUnstructuredGridPartialPreIntegration::GetPsiTable
static float * GetPsiTable(int &size)
Definition: vtkUnstructuredGridPartialPreIntegration.h:129
vtkX3D::color
@ color
Definition: vtkX3D.h:221
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkUnstructuredGridPartialPreIntegration::vtkUnstructuredGridPartialPreIntegration
vtkUnstructuredGridPartialPreIntegration()
vtkUnstructuredGridPartialPreIntegration::NumIndependentComponents
int NumIndependentComponents
Definition: vtkUnstructuredGridPartialPreIntegration.h:107
vtkUnstructuredGridVolumeRayIntegrator.h
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkUnstructuredGridPartialPreIntegration
performs piecewise linear ray integration.
Definition: vtkUnstructuredGridPartialPreIntegration.h:56
vtkUnstructuredGridPartialPreIntegration::Integrate
virtual void Integrate(vtkDoubleArray *intersectionLengths, vtkDataArray *nearIntersections, vtkDataArray *farIntersections, float color[4])
Given a set of intersections (defined by the three arrays), compute the peicewise integration of the ...
vtkUnstructuredGridPartialPreIntegration::IntegrateRay
static void IntegrateRay(double length, double intensity_front, double attenuation_front, double intensity_back, double attenuation_back, float color[4])
Integrates a single ray segment.
Definition: vtkUnstructuredGridPartialPreIntegration.h:135
vtkUnstructuredGridPartialPreIntegration::PSI_TABLE_SIZE
@ PSI_TABLE_SIZE
Definition: vtkUnstructuredGridPartialPreIntegration.h:109
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:42
vtkUnstructuredGridPartialPreIntegration::Psi
static float Psi(float taufD, float taubD)
Looks up Psi (as defined by Moreland and Angel, "A Fast High Accuracy Volume Renderer for Unstructure...
Definition: vtkUnstructuredGridPartialPreIntegration.h:119
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:61
vtkUnstructuredGridPartialPreIntegration::Initialize
virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars)
Set up the integrator with the given properties and scalars.