VTK  9.7.1
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 #include <algorithm> // std::min, std::max
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkVolumeProperty;
34 
35 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridPreIntegration
37 {
38 public:
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
43  void Initialize(vtkVolume* volume, vtkDataArray* scalars) override;
44 
45  void Integrate(vtkDoubleArray* intersectionLengths, vtkDataArray* nearIntersections,
46  vtkDataArray* farIntersections, float color[4]) override;
47 
49 
53  vtkGetObjectMacro(Integrator, vtkUnstructuredGridVolumeRayIntegrator);
54  virtual void SetIntegrator(vtkUnstructuredGridVolumeRayIntegrator*);
56 
58 
61  vtkSetMacro(IntegrationTableScalarResolution, int);
62  vtkGetMacro(IntegrationTableScalarResolution, int);
63  vtkSetMacro(IntegrationTableLengthResolution, int);
64  vtkGetMacro(IntegrationTableLengthResolution, int);
66 
68 
71  virtual double GetIntegrationTableScalarShift(int component = 0);
72  virtual double GetIntegrationTableScalarScale(int component = 0);
73  virtual double GetIntegrationTableLengthScale();
75 
77 
83  vtkGetMacro(IncrementalPreIntegration, vtkTypeBool);
84  vtkSetMacro(IncrementalPreIntegration, vtkTypeBool);
85  vtkBooleanMacro(IncrementalPreIntegration, vtkTypeBool);
87 
99  virtual float* GetPreIntegrationTable(int component = 0);
100 
105  float* GetTableEntry(double scalar_front, double scalar_back, double length, int component = 0);
106 
112  float* GetIndexedTableEntry(
113  int scalar_front_index, int scalar_back_index, int length_index, int component = 0);
114 
115 protected:
118 
120 
123  double MaxLength;
124 
131 
134 
136 
137  virtual void BuildPreIntegrationTables(vtkDataArray* scalars);
138 
139 private:
141  void operator=(const vtkUnstructuredGridPreIntegration&) = delete;
142 };
143 
145  int scalar_front_index, int scalar_back_index, int length_index, int component)
146 {
147  // Snap entries to bounds. I don't really want to spend cycles doing
148  // this, but I've had the ray caster give me values that are noticeably
149  // out of bounds.
150  scalar_front_index = std::max(scalar_front_index, 0);
151  scalar_front_index = std::min(scalar_front_index, this->IntegrationTableScalarResolution - 1);
152  scalar_back_index = std::max(scalar_back_index, 0);
153  scalar_back_index = std::min(scalar_back_index, this->IntegrationTableScalarResolution - 1);
154  length_index = std::max(length_index, 0);
155  length_index = std::min(length_index, this->IntegrationTableLengthResolution - 1);
156 
157  return (this->IntegrationTable[component] +
158  4 *
159  (((length_index * this->IntegrationTableScalarResolution + scalar_back_index) *
161  scalar_front_index));
162 }
163 
165  double scalar_front, double scalar_back, double length, int component)
166 {
167  int sfi = static_cast<int>(scalar_front * this->IntegrationTableScalarScale[component] +
169  int sbi = static_cast<int>(scalar_back * this->IntegrationTableScalarScale[component] +
171  int li = static_cast<int>(length * this->IntegrationTableLengthScale + 0.5);
172  return this->GetIndexedTableEntry(sfi, sbi, li, component);
173 }
174 
175 VTK_ABI_NAMESPACE_END
176 #endif // vtkUnstructuredGridPreIntegration_h
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:40
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...
virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars)=0
Set up the integrator with the given properties and scalars.
vtkUnstructuredGridVolumeRayIntegrator * Integrator
record modification and/or execution time
Definition: vtkTimeStamp.h:24
dynamic, self-adjusting array of double
a superclass for volume ray integration functions
int vtkTypeBool
Definition: vtkABI.h:64
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
performs ray integration with pre-integration tables.
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.
represents the common properties for rendering a volume.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define max(a, b)
virtual void Integrate(vtkDoubleArray *intersectionLengths, vtkDataArray *nearIntersections, vtkDataArray *farIntersections, float color[4])=0
Given a set of intersections (defined by the three arrays), compute the piecewise integration of the ...