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 
44 #ifndef vtkUnstructuredGridPartialPreIntegration_h
45 #define vtkUnstructuredGridPartialPreIntegration_h
46 
47 #include "vtkRenderingVolumeModule.h" // For export macro
49 #include "vtkMath.h" // For all the inline methods
50 
51 class vtkPartialPreIntegrationTransferFunction;
52 class vtkVolumeProperty;
53 
55 {
56 public:
60  virtual void PrintSelf(ostream &os, vtkIndent indent);
61 
62  virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars);
63 
64  virtual void Integrate(vtkDoubleArray *intersectionLengths,
65  vtkDataArray *nearIntersections,
66  vtkDataArray *farIntersections,
67  float color[4]);
68 
70 
72  static void IntegrateRay(double length,
73  double intensity_front, double attenuation_front,
74  double intensity_back, double attenuation_back,
75  float color[4]);
76  static void IntegrateRay(double length,
77  const double color_front[3],
78  double attenuation_front,
79  const double color_back[3],
80  double attenuation_back,
81  float color[4]);
83 
85 
89  static float Psi(float taufD, float taubD);
90  static float *GetPsiTable(int &size);
91  static void BuildPsiTable();
93 
94 protected:
97 
99 
100  vtkPartialPreIntegrationTransferFunction *TransferFunctions;
103 
104 //BTX
105  enum {PSI_TABLE_SIZE = 512};
106 //ETX
107  static float PsiTable[PSI_TABLE_SIZE*PSI_TABLE_SIZE];
108  static int PsiTableBuilt;
109 
110 private:
112  void operator=(const vtkUnstructuredGridPartialPreIntegration&); // Not implemented.
113 };
114 
116  float taubD)
117 {
118  float gammaf = taufD/(taufD+1);
119  float gammab = taubD/(taubD+1);
120  int gammafi = vtkMath::Floor(gammaf*PSI_TABLE_SIZE);
121  int gammabi = vtkMath::Floor(gammab*PSI_TABLE_SIZE);
122  return PsiTable[gammafi*PSI_TABLE_SIZE + gammabi];
123 }
124 
126 {
127  size = PSI_TABLE_SIZE;
128  return PsiTable;
129 }
130 
132  double length,
133  double intensity_front,
134  double attenuation_front,
135  double intensity_back,
136  double attenuation_back,
137  float color[4])
138 {
139  float taufD = length*attenuation_front;
140  float taubD = length*attenuation_back;
142  float zeta = static_cast<float>(exp(-0.5*(taufD+taubD)));
143  float alpha = 1-zeta;
144 
145  float newintensity = (1-color[3])*( intensity_front*(1-Psi)
146  + intensity_back*(Psi-zeta) );
147  // Is setting the RGB values the same the right thing to do?
148  color[0] += newintensity;
149  color[1] += newintensity;
150  color[2] += newintensity;
151  color[3] += (1-color[3])*alpha;
152 }
153 
155  double length,
156  const double color_front[3],
157  double attenuation_front,
158  const double color_back[3],
159  double attenuation_back,
160  float color[4])
161 {
162  float taufD = length*attenuation_front;
163  float taubD = length*attenuation_back;
165  float zeta = static_cast<float>(exp(-0.5*(taufD+taubD)));
166  float alpha = 1-zeta;
167 
168  color[0] += (1-color[3])*(color_front[0]*(1-Psi) + color_back[0]*(Psi-zeta));
169  color[1] += (1-color[3])*(color_front[1]*(1-Psi) + color_back[1]*(Psi-zeta));
170  color[2] += (1-color[3])*(color_front[2]*(1-Psi) + color_back[2]*(Psi-zeta));
171  color[3] += (1-color[3])*alpha;
172 }
173 
174 #endif //vtkUnstructuredGridPartialPreIntegration_h
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:49
virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars)=0
#define VTKRENDERINGVOLUME_EXPORT
record modification and/or execution time
Definition: vtkTimeStamp.h:34
static float PsiTable[PSI_TABLE_SIZE *PSI_TABLE_SIZE]
vtkPartialPreIntegrationTransferFunction * TransferFunctions
dynamic, self-adjusting array of double
a superclass for volume ray integration functions
static void IntegrateRay(double length, double intensity_front, double attenuation_front, double intensity_back, double attenuation_back, float color[4])
a simple class to control print indentation
Definition: vtkIndent.h:38
static int Floor(double x)
Definition: vtkMath.h:1017
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
represents the common properties for rendering a volume.
virtual void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
virtual void Integrate(vtkDoubleArray *intersectionLengths, vtkDataArray *nearIntersections, vtkDataArray *farIntersections, float color[4])=0