VTK  9.7.20260720
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
55
56#ifndef vtkVolumeTexture_h
57#define vtkVolumeTexture_h
58#include <map> // For ImageDataBlockMap
59#include <vector> // For ImageDataBlocks
60
61#include "vtkMatrix4x4.h" // For vtkMatrix4
62#include "vtkNew.h" // For vtkNew
63#include "vtkObject.h"
64#include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
65#include "vtkSmartPointer.h" // For SmartPointer
66#include "vtkTimeStamp.h" // For UploadTime
67#include "vtkTuple.h" // For Size6 and Size3
68
69VTK_ABI_NAMESPACE_BEGIN
70class vtkDataArray;
71class vtkDataSet;
72class vtkImageData;
73class vtkRenderer;
76class vtkWindow;
77
78class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkVolumeTexture : public vtkObject
79{
80 typedef vtkTuple<int, 6> Size6;
81 typedef vtkTuple<int, 3> Size3;
82
83public:
85
87 {
88 VolumeBlock(vtkDataSet* dataset, vtkTextureObject* tex, Size3 const& texSize)
89 {
90 // Block extent is stored in vtkDataSet
91 DataSet = dataset;
92 TextureObject = tex;
93 TextureSize = texSize;
94 TupleIndex = 0;
95
96 this->Extents[0] = VTK_INT_MAX;
97 this->Extents[1] = VTK_INT_MIN;
98 this->Extents[2] = VTK_INT_MAX;
99 this->Extents[3] = VTK_INT_MIN;
100 this->Extents[4] = VTK_INT_MAX;
101 this->Extents[5] = VTK_INT_MIN;
102 }
103
110
111 float CellStep[3];
113
118 double LoadedBounds[6];
119 double LoadedBoundsAA[6];
120 double VolumeGeometry[24];
121 int Extents[6];
122 };
123
125 void PrintSelf(ostream& os, vtkIndent indent) override;
126
130 void SetPartitions(int x, int y, int z);
131 const Size3& GetPartitions();
132
140 vtkRenderer* ren, vtkDataSet* data, vtkDataArray* scalars, int isCell, int interpolation);
141
147
153
163
168
175 static void GetScaleAndBias(int scalarType, float* scalarRange, float& scale, float& bias);
177
179 float Scale[4];
180 float Bias[4];
181 float ScalarRange[4][2];
182 float CellSpacing[3];
185
186 int IsCellData = 0;
190
192
194 float CoordsScale[3];
195 float CoordsBias[3];
196
198
199protected:
202
203private:
204 vtkVolumeTexture(const vtkVolumeTexture&) = delete;
205 void operator=(const vtkVolumeTexture&) = delete;
206
211 bool LoadTexture(int interpolation, VolumeBlock* volBlock);
212
216 void SplitVolume(vtkImageData* imageData, Size3 const& part);
217
218 void CreateBlocks(unsigned int format, unsigned int internalFormat, int type);
219
220 void AdjustExtentForCell(Size6& extent);
221 Size3 ComputeBlockSize(VTK_FUTURE_CONST int extent[6]);
222
227 void SelectTextureFormat(unsigned int& format, unsigned int& internalFormat, int& type,
228 int scalarType, int noOfComponents);
229
233 void ClearBlocks();
234
238 // can be combined into one call
239 void ComputeBounds(VolumeBlock* block);
240 void UpdateTextureToDataMatrix(VolumeBlock* block);
241
260 void ComputeCellToPointMatrix(int extents[6]);
261
263
271 bool AreDimensionsValid(vtkTextureObject* texture, int width, int height, int depth);
272
273 bool SafeLoadTexture(vtkTextureObject* texture, int width, int height, int depth, int numComps,
274 int dataType, void* dataPtr);
276
277 void UpdateInterpolationType(int interpolation);
278 void SetInterpolation(int interpolation);
279
280 //----------------------------------------------------------------------------
281 vtkTimeStamp UpdateTime;
282
284 std::vector<vtkDataSet*> ImageDataBlocks;
285 std::map<vtkDataSet*, VolumeBlock*> ImageDataBlockMap;
286 std::vector<VolumeBlock*> SortedVolumeBlocks;
287 size_t CurrentBlockIdx;
288 bool StreamBlocks;
289
290 std::vector<Size3> TextureSizes;
291 Size6 FullExtent;
292 Size3 FullSize;
293 Size3 Partitions;
294
295 vtkDataArray* Scalars;
296};
297
298VTK_ABI_NAMESPACE_END
299#endif // vtkVolumeTexture_h
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:168
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:30
represents the common properties for rendering a volume.
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()
float ScalarRange[4][2]
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:62
VolumeBlock(vtkDataSet *dataset, vtkTextureObject *tex, Size3 const &texSize)
vtkNew< vtkMatrix4x4 > TextureToDataset
vtkNew< vtkMatrix4x4 > TextureToDatasetInv
double LoadedBounds[6]
LoadedBounds are corrected for cell-data (if that is the case).
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
#define VTK_INT_MIN
Definition vtkType.h:191
#define VTK_INT_MAX
Definition vtkType.h:192