VTK  9.3.20240327
vtkUnstructuredGridPreIntegration.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2004 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
24 #ifndef vtkUnstructuredGridPreIntegration_h
25 #define vtkUnstructuredGridPreIntegration_h
26 
27 #include "vtkRenderingVolumeModule.h" // For export macro
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkVolumeProperty;
32 
33 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridPreIntegration
35 {
36 public:
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
41  void Initialize(vtkVolume* volume, vtkDataArray* scalars) override;
42 
43  void Integrate(vtkDoubleArray* intersectionLengths, vtkDataArray* nearIntersections,
44  vtkDataArray* farIntersections, float color[4]) override;
45 
47 
51  vtkGetObjectMacro(Integrator, vtkUnstructuredGridVolumeRayIntegrator);
54 
56 
59  vtkSetMacro(IntegrationTableScalarResolution, int);
60  vtkGetMacro(IntegrationTableScalarResolution, int);
61  vtkSetMacro(IntegrationTableLengthResolution, int);
62  vtkGetMacro(IntegrationTableLengthResolution, int);
64 
66 
69  virtual double GetIntegrationTableScalarShift(int component = 0);
70  virtual double GetIntegrationTableScalarScale(int component = 0);
73 
75 
81  vtkGetMacro(IncrementalPreIntegration, vtkTypeBool);
82  vtkSetMacro(IncrementalPreIntegration, vtkTypeBool);
83  vtkBooleanMacro(IncrementalPreIntegration, vtkTypeBool);
85 
97  virtual float* GetPreIntegrationTable(int component = 0);
98 
103  float* GetTableEntry(double scalar_front, double scalar_back, double length, int component = 0);
104 
110  float* GetIndexedTableEntry(
111  int scalar_front_index, int scalar_back_index, int length_index, int component = 0);
112 
113 protected:
116 
118 
121  double MaxLength;
122 
129 
132 
134 
135  virtual void BuildPreIntegrationTables(vtkDataArray* scalars);
136 
137 private:
139  void operator=(const vtkUnstructuredGridPreIntegration&) = delete;
140 };
141 
143  int scalar_front_index, int scalar_back_index, int length_index, int component)
144 {
145  // Snap entries to bounds. I don't really want to spend cycles doing
146  // this, but I've had the ray caster give me values that are noticeably
147  // out of bounds.
148  if (scalar_front_index < 0)
149  scalar_front_index = 0;
150  if (scalar_front_index >= this->IntegrationTableScalarResolution)
151  scalar_front_index = this->IntegrationTableScalarResolution - 1;
152  if (scalar_back_index < 0)
153  scalar_back_index = 0;
154  if (scalar_back_index >= this->IntegrationTableScalarResolution)
155  scalar_back_index = this->IntegrationTableScalarResolution - 1;
156  if (length_index < 0)
157  length_index = 0;
158  if (length_index >= this->IntegrationTableLengthResolution)
159  length_index = this->IntegrationTableLengthResolution - 1;
160 
161  return (this->IntegrationTable[component] +
162  4 *
163  (((length_index * this->IntegrationTableScalarResolution + scalar_back_index) *
165  scalar_front_index));
166 }
167 
169  double scalar_front, double scalar_back, double length, int component)
170 {
171  int sfi = static_cast<int>(scalar_front * this->IntegrationTableScalarScale[component] +
173  int sbi = static_cast<int>(scalar_back * this->IntegrationTableScalarScale[component] +
175  int li = static_cast<int>(length * this->IntegrationTableLengthScale + 0.5);
176  return this->GetIndexedTableEntry(sfi, sbi, li, component);
177 }
178 
179 VTK_ABI_NAMESPACE_END
180 #endif // vtkUnstructuredGridPreIntegration_h
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:108
record modification and/or execution time
Definition: vtkTimeStamp.h:44
performs ray integration with pre-integration tables.
float * GetIndexedTableEntry(int scalar_front_index, int scalar_back_index, int length_index, int component=0)
Like GetTableEntry, except the inputs are scaled indices into the table rather than than the actual s...
void Integrate(vtkDoubleArray *intersectionLengths, vtkDataArray *nearIntersections, vtkDataArray *farIntersections, float color[4]) override
Given a set of intersections (defined by the three arrays), compute the piecewise integration of the ...
virtual double GetIntegrationTableScalarScale(int component=0)
Get how an integration table is indexed.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float * GetTableEntry(double scalar_front, double scalar_back, double length, int component=0)
Get an entry (RGBA) in one of the pre-integration tables.
virtual double GetIntegrationTableScalarShift(int component=0)
Get how an integration table is indexed.
virtual double GetIntegrationTableLengthScale()
Get how an integration table is indexed.
virtual void BuildPreIntegrationTables(vtkDataArray *scalars)
virtual float * GetPreIntegrationTable(int component=0)
Get the partial pre-integration table for the given scalar component.
static vtkUnstructuredGridPreIntegration * New()
void Initialize(vtkVolume *volume, vtkDataArray *scalars) override
Set up the integrator with the given properties and scalars.
virtual void SetIntegrator(vtkUnstructuredGridVolumeRayIntegrator *)
The class used to fill the pre integration table.
vtkUnstructuredGridVolumeRayIntegrator * Integrator
a superclass for volume ray integration functions
represents the common properties for rendering a volume.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:119
@ component
Definition: vtkX3D.h:175
@ length
Definition: vtkX3D.h:393
@ color
Definition: vtkX3D.h:221
int vtkTypeBool
Definition: vtkABI.h:64