VTK  9.4.20241218
vtkVolumeTexture.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
53#ifndef vtkVolumeTexture_h
54#define vtkVolumeTexture_h
55#include <map> // For ImageDataBlockMap
56#include <vector> // For ImageDataBlocks
57
58#include "vtkMatrix4x4.h" // For vtkMatrix4
59#include "vtkNew.h" // For vtkNew
60#include "vtkObject.h"
61#include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
62#include "vtkSmartPointer.h" // For SmartPointer
63#include "vtkTimeStamp.h" // For UploadTime
64#include "vtkTuple.h" // For Size6 and Size3
65
66VTK_ABI_NAMESPACE_BEGIN
67class vtkDataArray;
68class vtkDataSet;
69class vtkImageData;
70class vtkRenderer;
73class vtkWindow;
74
75class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkVolumeTexture : public vtkObject
76{
77 typedef vtkTuple<int, 6> Size6;
78 typedef vtkTuple<int, 3> Size3;
79
80public:
82
84 {
85 VolumeBlock(vtkDataSet* dataset, vtkTextureObject* tex, Size3 const& texSize)
86 {
87 // Block extent is stored in vtkDataSet
88 DataSet = dataset;
89 TextureObject = tex;
90 TextureSize = texSize;
91 TupleIndex = 0;
92
93 this->Extents[0] = VTK_INT_MAX;
94 this->Extents[1] = VTK_INT_MIN;
95 this->Extents[2] = VTK_INT_MAX;
96 this->Extents[3] = VTK_INT_MIN;
97 this->Extents[4] = VTK_INT_MAX;
98 this->Extents[5] = VTK_INT_MIN;
99 }
100
107
108 float CellStep[3];
109 double DatasetStepSize[3];
110
115 double LoadedBounds[6];
116 double LoadedBoundsAA[6];
117 double VolumeGeometry[24];
118 int Extents[6];
119 };
120
122 void PrintSelf(ostream& os, vtkIndent indent) override;
123
127 void SetPartitions(int x, int y, int z);
129
137 vtkRenderer* ren, vtkDataSet* data, vtkDataArray* scalars, int isCell, int interpolation);
138
144
150
160
165
172 static void GetScaleAndBias(int scalarType, float* scalarRange, float& scale, float& bias);
174
176 float Scale[4];
177 float Bias[4];
178 float ScalarRange[4][2];
179 float CellSpacing[3];
182
183 int IsCellData = 0;
185 float AdjustedTexMin[4];
186 float AdjustedTexMax[4];
187
189
190 int CoordsTexSizes[3];
191 float CoordsScale[3];
192 float CoordsBias[3];
193
195
196protected:
199
200private:
201 vtkVolumeTexture(const vtkVolumeTexture&) = delete;
202 void operator=(const vtkVolumeTexture&) = delete;
203
208 bool LoadTexture(int interpolation, VolumeBlock* volBlock);
209
213 void SplitVolume(vtkImageData* imageData, Size3 const& part);
214
215 void CreateBlocks(unsigned int format, unsigned int internalFormat, int type);
216
217 void AdjustExtentForCell(Size6& extent);
218 Size3 ComputeBlockSize(int* extent);
219
224 void SelectTextureFormat(unsigned int& format, unsigned int& internalFormat, int& type,
225 int scalarType, int noOfComponents);
226
230 void ClearBlocks();
231
235 // can be combined into one call
236 void ComputeBounds(VolumeBlock* block);
237 void UpdateTextureToDataMatrix(VolumeBlock* block);
238
257 void ComputeCellToPointMatrix(int extents[6]);
258
260
268 bool AreDimensionsValid(vtkTextureObject* texture, int width, int height, int depth);
269
270 bool SafeLoadTexture(vtkTextureObject* texture, int width, int height, int depth, int numComps,
271 int dataType, void* dataPtr);
273
274 void UpdateInterpolationType(int interpolation);
275 void SetInterpolation(int interpolation);
276
277 //----------------------------------------------------------------------------
278 vtkTimeStamp UpdateTime;
279
281 std::vector<vtkDataSet*> ImageDataBlocks;
282 std::map<vtkDataSet*, VolumeBlock*> ImageDataBlockMap;
283 std::vector<VolumeBlock*> SortedVolumeBlocks;
284 size_t CurrentBlockIdx;
285 bool StreamBlocks;
286
287 std::vector<Size3> TextureSizes;
288 Size6 FullExtent;
289 Size3 FullSize;
290 Size3 Partitions;
291
292 vtkDataArray* Scalars;
293};
294
295VTK_ABI_NAMESPACE_END
296#endif // vtkVolumeTexture_h
abstract superclass for arrays of numeric data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract base class for most VTK objects
Definition vtkObject.h:162
abstract specification for renderers
Hold a reference to a vtkObjectBase instance.
abstracts an OpenGL texture object.
record modification and/or execution time
templated base type for containers of constant size.
Definition vtkTuple.h:27
represents the common properties for rendering a volume.
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
bool LoadVolume(vtkRenderer *ren, vtkDataSet *data, vtkDataArray *scalars, int isCell, int interpolation)
Loads the data array into the texture in the case only a single block is is defined.
vtkSmartPointer< vtkTextureObject > BlankingTex
vtkTimeStamp UploadTime
vtkNew< vtkMatrix4x4 > CellToPointMatrix
void SetPartitions(int x, int y, int z)
Set a number of blocks per axis.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void UpdateVolume(vtkVolumeProperty *property)
It currently only calls SetInterpolation internally.
void ReleaseGraphicsResources(vtkWindow *win)
Clean-up acquired graphics resources.
VolumeBlock * GetNextBlock()
Return the next volume block to be rendered and load its data.
static vtkVolumeTexture * New()
vtkDataArray * GetLoadedScalars()
vtkSmartPointer< vtkTextureObject > CoordsTex
VolumeBlock * GetCurrentBlock()
Return the currently loaded block.
~vtkVolumeTexture() override
const Size3 & GetPartitions()
static void GetScaleAndBias(int scalarType, float *scalarRange, float &scale, float &bias)
Get the scale and bias values given a VTK scalar type and a finite range.
void SortBlocksBackToFront(vtkRenderer *ren, vtkMatrix4x4 *volumeMat)
If streaming the data array as separate blocks, sort them back to front.
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
VolumeBlock(vtkDataSet *dataset, vtkTextureObject *tex, Size3 const &texSize)
vtkNew< vtkMatrix4x4 > TextureToDataset
vtkNew< vtkMatrix4x4 > TextureToDatasetInv
int vtkIdType
Definition vtkType.h:315
#define VTK_INT_MIN
Definition vtkType.h:143
#define VTK_INT_MAX
Definition vtkType.h:144