VTK  9.1.0
vtkVolumeTexture.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkVolumeTexture.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
65#ifndef vtkVolumeTexture_h
66#define vtkVolumeTexture_h
67#include <map> // For ImageDataBlockMap
68#include <vector> // For ImageDataBlocks
69
70#include "vtkMatrix4x4.h" // For vtkMatrix4
71#include "vtkNew.h" // For vtkNew
72#include "vtkObject.h"
73#include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
74#include "vtkSmartPointer.h" // For SmartPointer
75#include "vtkTimeStamp.h" // For UploadTime
76#include "vtkTuple.h" // For Size6 and Size3
77
78class vtkDataArray;
79class vtkDataSet;
80class vtkImageData;
81class vtkRenderer;
84class vtkWindow;
85
86class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkVolumeTexture : public vtkObject
87{
88 typedef vtkTuple<int, 6> Size6;
89 typedef vtkTuple<int, 3> Size3;
90
91public:
93
95 {
96 VolumeBlock(vtkDataSet* dataset, vtkTextureObject* tex, Size3 const& texSize)
97 {
98 // Block extent is stored in vtkDataSet
99 DataSet = dataset;
100 TextureObject = tex;
101 TextureSize = texSize;
102 TupleIndex = 0;
103
104 this->Extents[0] = VTK_INT_MAX;
105 this->Extents[1] = VTK_INT_MIN;
106 this->Extents[2] = VTK_INT_MAX;
107 this->Extents[3] = VTK_INT_MIN;
108 this->Extents[4] = VTK_INT_MAX;
109 this->Extents[5] = VTK_INT_MIN;
110 }
111
118
119 float CellStep[3];
120 double DatasetStepSize[3];
121
126 double LoadedBounds[6];
127 double LoadedBoundsAA[6];
128 double VolumeGeometry[24];
129 int Extents[6];
130 };
131
133 void PrintSelf(ostream& os, vtkIndent indent) override;
134
138 void SetPartitions(int const x, int const y, int const z);
140
147 bool LoadVolume(vtkRenderer* ren, vtkDataSet* data, vtkDataArray* scalars, int const isCell,
148 int const interpolation);
149
155
161
171
176
183 static void GetScaleAndBias(const int scalarType, float* scalarRange, float& scale, float& bias);
185
187 float Scale[4];
188 float Bias[4];
189 float ScalarRange[4][2];
190 float CellSpacing[3];
193
194 int IsCellData = 0;
196 float AdjustedTexMin[4];
197 float AdjustedTexMax[4];
198
200
201 int CoordsTexSizes[3];
202 float CoordsScale[3];
203 float CoordsBias[3];
204
206
207protected:
210
211private:
212 vtkVolumeTexture(const vtkVolumeTexture&) = delete;
213 void operator=(const vtkVolumeTexture&) = delete;
214
219 bool LoadTexture(int const interpolation, VolumeBlock* volBlock);
220
224 void SplitVolume(vtkImageData* imageData, Size3 const& part);
225
226 void CreateBlocks(unsigned int const format, unsigned int const internalFormat, int const type);
227
228 void AdjustExtentForCell(Size6& extent);
229 Size3 ComputeBlockSize(int* extent);
230
235 void SelectTextureFormat(unsigned int& format, unsigned int& internalFormat, int& type,
236 int const scalarType, int const noOfComponents);
237
241 void ClearBlocks();
242
246 // can be combined into one call
247 void ComputeBounds(VolumeBlock* block);
248 void UpdateTextureToDataMatrix(VolumeBlock* block);
249
268 void ComputeCellToPointMatrix(int extents[6]);
269
271
279 bool AreDimensionsValid(
280 vtkTextureObject* texture, int const width, int const height, int const depth);
281
282 bool SafeLoadTexture(vtkTextureObject* texture, int const width, int const height,
283 int const depth, int numComps, int dataType, void* dataPtr);
285
286 void UpdateInterpolationType(int const interpolation);
287 void SetInterpolation(int const interpolation);
288
289 //----------------------------------------------------------------------------
290 vtkTimeStamp UpdateTime;
291
293 std::vector<vtkDataSet*> ImageDataBlocks;
294 std::map<vtkDataSet*, VolumeBlock*> ImageDataBlockMap;
295 std::vector<VolumeBlock*> SortedVolumeBlocks;
296 size_t CurrentBlockIdx;
297 bool StreamBlocks;
298
299 std::vector<Size3> TextureSizes;
300 Size6 FullExtent;
301 Size3 FullSize;
302 Size3 Partitions;
303
304 vtkDataArray* Scalars;
305};
306
307#endif // vtkVolumeTexture_h
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
abstract base class for most VTK objects
Definition: vtkObject.h:73
abstract specification for renderers
Definition: vtkRenderer.h:173
abstracts an OpenGL texture object.
record modification and/or execution time
Definition: vtkTimeStamp.h:52
represents the common properties for rendering a volume.
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
vtkSmartPointer< vtkTextureObject > BlankingTex
vtkTimeStamp UploadTime
void SetPartitions(int const x, int const y, int const z)
Set a number of blocks per axis.
vtkNew< vtkMatrix4x4 > CellToPointMatrix
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.
bool LoadVolume(vtkRenderer *ren, vtkDataSet *data, vtkDataArray *scalars, int const isCell, int const interpolation)
Loads the data array into the texture in the case only a single block is is defined.
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()
void SortBlocksBackToFront(vtkRenderer *ren, vtkMatrix4x4 *volumeMat)
If streaming the data array as separate blocks, sort them back to front.
static void GetScaleAndBias(const int scalarType, float *scalarRange, float &scale, float &bias)
Get the scale and bias values given a VTK scalar type and a finite range.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ scale
Definition: vtkX3D.h:235
@ extent
Definition: vtkX3D.h:351
@ type
Definition: vtkX3D.h:522
@ height
Definition: vtkX3D.h:260
@ data
Definition: vtkX3D.h:321
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
VolumeBlock(vtkDataSet *dataset, vtkTextureObject *tex, Size3 const &texSize)
vtkNew< vtkMatrix4x4 > TextureToDataset
vtkNew< vtkMatrix4x4 > TextureToDatasetInv
vtkTextureObject * TextureObject
int vtkIdType
Definition: vtkType.h:332
#define VTK_INT_MIN
Definition: vtkType.h:154
#define VTK_INT_MAX
Definition: vtkType.h:155