VTK  9.2.6
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 
78 class vtkDataArray;
79 class vtkDataSet;
80 class vtkImageData;
81 class vtkRenderer;
82 class vtkTextureObject;
83 class vtkVolumeProperty;
84 class vtkWindow;
85 
86 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkVolumeTexture : public vtkObject
87 {
88  typedef vtkTuple<int, 6> Size6;
89  typedef vtkTuple<int, 3> Size3;
90 
91 public:
92  static vtkVolumeTexture* New();
93 
94  struct VolumeBlock
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 
114  Size3 TextureSize;
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 
132  vtkTypeMacro(vtkVolumeTexture, vtkObject);
133  void PrintSelf(ostream& os, vtkIndent indent) override;
134 
138  void SetPartitions(int const x, int const y, int const z);
139  const Size3& GetPartitions();
140 
147  bool LoadVolume(vtkRenderer* ren, vtkDataSet* data, vtkDataArray* scalars, int const isCell,
148  int const interpolation);
149 
154  void UpdateVolume(vtkVolumeProperty* property);
155 
160  void SortBlocksBackToFront(vtkRenderer* ren, vtkMatrix4x4* volumeMat);
161 
166  VolumeBlock* GetNextBlock();
170  VolumeBlock* GetCurrentBlock();
171 
175  void ReleaseGraphicsResources(vtkWindow* win);
176 
183  static void GetScaleAndBias(const int scalarType, float* scalarRange, float& scale, float& bias);
184  vtkDataArray* GetLoadedScalars();
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 
207 protected:
209  ~vtkVolumeTexture() override;
210 
211 private:
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
VolumeBlock(vtkDataSet *dataset, vtkTextureObject *tex, Size3 const &texSize)
abstract base class for most VTK objects
Definition: vtkObject.h:62
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
#define VTK_INT_MAX
Definition: vtkType.h:155
record modification and/or execution time
Definition: vtkTimeStamp.h:35
abstract specification for renderers
Definition: vtkRenderer.h:72
int vtkIdType
Definition: vtkType.h:332
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkTextureObject * TextureObject
vtkSmartPointer< vtkTextureObject > BlankingTex
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
represents the common properties for rendering a volume.
vtkNew< vtkMatrix4x4 > TextureToDataset
vtkSmartPointer< vtkTextureObject > CoordsTex
abstracts an OpenGL texture object.
vtkNew< vtkMatrix4x4 > TextureToDatasetInv
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkMatrix4x4 > CellToPointMatrix
vtkTimeStamp UploadTime
#define VTK_INT_MIN
Definition: vtkType.h:154