VTK
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 
62 #ifndef vtkVolumeTexture_h
63 #define vtkVolumeTexture_h
64 
65 #include <map> // For ImageDataBlockMap
66 #include <vector> // For ImageDataBlocks
67 
68 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
69 #include "vtkObject.h"
70 #include "vtkTimeStamp.h" // For UploadTime
71 #include "vtkTuple.h" // For Size6 and Size3
72 
73 
74 class vtkDataArray;
75 class vtkImageData;
77 class vtkRenderer;
78 class vtkTextureObject;
79 
80 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkVolumeTexture : public vtkObject
81 {
82  typedef vtkTuple<int, 6> Size6;
83  typedef vtkTuple<int, 3> Size3;
84 
85 public:
86  static vtkVolumeTexture* New();
87 
88  struct VolumeBlock
89  {
90  VolumeBlock(vtkImageData* imData, vtkTextureObject* tex, Size3 const& texSize)
91  {
92  // Block extent is stored in vtkImageData
93  ImageData = imData;
94  TextureObject = tex;
95  TextureSize = texSize;
96  TupleIndex = 0;
97  }
98 
101  Size3 TextureSize;
103  };
104 
105  vtkTypeMacro(vtkVolumeTexture, vtkObject);
106  void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE;
107 
111  void SetMapper(vtkOpenGLGPUVolumeRayCastMapper* mapper);
112 
116  void SetPartitions(int const x, int const y, int const z);
117 
124  bool LoadVolume(vtkRenderer* ren, vtkImageData* data, vtkDataArray* scalars,
125  int const interpolation);
126 
127  void UpdateInterpolationType(int const interpolation);
128 
133  void SortBlocksBackToFront(vtkRenderer *ren, vtkMatrix4x4* volumeMat);
134 
140  VolumeBlock* GetNextBlock();
141 
145  void ReleaseGraphicsResources(vtkWindow* win);
146 
147  //----------------------------------------------------------------------------
148 
150  float Scale[4];
151  float Bias[4];
152  double ScalarRange[4][2];
155 
156 protected:
158  ~vtkVolumeTexture() VTK_OVERRIDE;
159 
160 private:
165  bool LoadTexture(int const interpolation, VolumeBlock* volBlock);
166 
170  void SplitVolume(vtkImageData* imageData, Size3 const & part);
171 
175  void SetInterpolation(int const interpolation);
176 
177  void CreateBlocks(unsigned int const format, unsigned int const internalFormat,
178  int const type);
179 
180  void AdjustExtentForCell(Size6& extent);
181  Size3 ComputeBlockSize(int* extent);
182 
187  void SelectTextureFormat(unsigned int& format, unsigned int& internalFormat,
188  int& type, int const scalarType, int const noOfComponents);
189 
193  void ClearBlocks();
194 
195  vtkVolumeTexture(const vtkVolumeTexture&) VTK_DELETE_FUNCTION;
196  void operator=(const vtkVolumeTexture&) VTK_DELETE_FUNCTION;
197 
199 
207  bool AreDimensionsValid(vtkTextureObject* texture, int const width,
208  int const height, int const depth);
209 
210  bool SafeLoadTexture(vtkTextureObject* texture, int const width,
211  int const height, int const depth, int numComps, int dataType, void* dataPtr);
213 
214  //----------------------------------------------------------------------------
215  vtkTextureObject* Texture;
216  std::vector<vtkImageData*> ImageDataBlocks;
217  std::map<vtkImageData*, VolumeBlock*> ImageDataBlockMap;
218  std::vector<VolumeBlock*> SortedVolumeBlocks;
219  size_t CurrentBlockIdx;
220  bool StreamBlocks;
221 
222  std::vector<Size3> TextureSizes;
223  Size6 FullExtent;
224  Size3 FullSize;
225  Size3 FullSizeAdjusted; /* Cell Adjusted */
226  Size3 Partitions;
227 
228  vtkDataArray* Scalars;
230 };
231 
232 #endif //vtkVolumeTexture_h
abstract base class for most VTK objects
Definition: vtkObject.h:53
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
record modification and/or execution time
Definition: vtkTimeStamp.h:32
abstract specification for renderers
Definition: vtkRenderer.h:57
int vtkIdType
Definition: vtkType.h:345
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
OpenGL subclass that draws the image to the screen.
vtkTextureObject * TextureObject
a simple class to control print indentation
Definition: vtkIndent.h:33
VolumeBlock(vtkImageData *imData, vtkTextureObject *tex, Size3 const &texSize)
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
abstracts an OpenGL texture object.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkTimeStamp UploadTime