Classes | Defines | Functions | Variables

vtkMitkOpenGLVolumeTextureMapper3D.cpp File Reference

#include "vtkWindows.h"
#include "vtkMitkOpenGLVolumeTextureMapper3D.h"
#include "mitkCommon.h"
#include "vtkImageData.h"
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
#include "vtkPlane.h"
#include "vtkPlaneCollection.h"
#include "vtkPointData.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkTimerLog.h"
#include "vtkVolumeProperty.h"
#include "vtkTransform.h"
#include "vtkLightCollection.h"
#include "vtkLight.h"
#include "vtkCamera.h"
#include "vtkMath.h"
#include "vtkOpenGLExtensionManager.h"
#include "vtkgl.h"
#include "vtkOpenGLRenderWindow.h"

Go to the source code of this file.

Classes

class  ScalarGradientCompute< T >
class  RGBACompute

Defines

#define GPU_INFO   MITK_INFO("mapper.vr")
#define GPU_WARN   MITK_WARN("mapper.vr")
#define myGL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
#define myGL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT   0x8C72
#define myGL_COMPRESSED_RGBA_S3TC_DXT5_EXT   0x83F3

Functions

 vtkCxxRevisionMacro (vtkMitkOpenGLVolumeTextureMapper3D,"$Revision: 1.21 $")
 vtkStandardNewMacro (vtkMitkOpenGLVolumeTextureMapper3D)
template<class T >
void vtkVolumeTextureMapper3DComputeScalars (T *dataPtr, vtkMitkVolumeTextureMapper3D *me, float offset, float scale, GLuint volume1, GLuint)
void vtkVolumeTextureMapper3DComputeRGBA (unsigned char *dataPtr, vtkMitkVolumeTextureMapper3D *me, GLuint volume1, GLuint volume2)

Variables

const char * vtkMitkVolumeTextureMapper3D_FourDependentShadeFP = "END\n"
const char * vtkMitkVolumeTextureMapper3D_OneComponentShadeFP = "END\n"

Define Documentation

#define GPU_INFO   MITK_INFO("mapper.vr")

Definition at line 26 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.

#define GPU_WARN   MITK_WARN("mapper.vr")
#define myGL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT   0x8C72

Definition at line 51 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.

#define myGL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0

Definition at line 50 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.

#define myGL_COMPRESSED_RGBA_S3TC_DXT5_EXT   0x83F3

Definition at line 52 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.


Function Documentation

vtkCxxRevisionMacro ( vtkMitkOpenGLVolumeTextureMapper3D  ,
"$Revision: 1.21 $"   
)
vtkStandardNewMacro ( vtkMitkOpenGLVolumeTextureMapper3D   )
void vtkVolumeTextureMapper3DComputeRGBA ( unsigned char *  dataPtr,
vtkMitkVolumeTextureMapper3D me,
GLuint  volume1,
GLuint  volume2 
)

Definition at line 1368 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.

References RGBACompute::fillSlices(), GL_RGB, GL_RGBA, GL_UNSIGNED_BYTE, glBindTexture(), and MITK_INFO.

{
  unsigned char  *inPtr;
  // unsigned char  *outPtr, *outPtr2;
  // int             i, j, k;
  // int             idx;

  int   inputDimensions[3];
  double inputSpacing[3];
  vtkImageData *input = me->GetInput();

  input->GetDimensions( inputDimensions );
  input->GetSpacing( inputSpacing );

  int   outputDimensions[3];
  float outputSpacing[3];
  me->GetVolumeDimensions( outputDimensions );
  me->GetVolumeSpacing( outputSpacing );

  int components = input->GetNumberOfScalarComponents();

  MITK_INFO << "components are " << components;

  // double wx, wy, wz;
  // double fx, fy, fz;
  // int x, y, z;

  double sampleRate[3];
  sampleRate[0] = outputSpacing[0] / static_cast<double>(inputSpacing[0]);
  sampleRate[1] = outputSpacing[1] / static_cast<double>(inputSpacing[1]);
  sampleRate[2] = outputSpacing[2] / static_cast<double>(inputSpacing[2]);

  int fullX = outputDimensions[0];
  int fullY = outputDimensions[1];
  int fullZ = outputDimensions[2];

  int sizeX = inputDimensions[0];
  int sizeY = inputDimensions[1];
  int sizeZ = inputDimensions[2];

  int chunkSize = 64;
  
  if(fullZ < chunkSize) chunkSize=fullZ;

  int numChunks = ( fullZ + (chunkSize-1) ) / chunkSize;

  inPtr = dataPtr;

  unsigned char *tmpPtr  = new unsigned char[fullX*fullY*chunkSize*4];
  unsigned char *tmpPtr2 = new unsigned char[fullX*fullY*chunkSize*3];

  // For each Chunk
  {
    RGBACompute sgc(dataPtr,tmpPtr,tmpPtr2,sizeX,sizeY,sizeZ,fullX,fullY,fullZ);

    int currentChunk = 0;

    while(currentChunk < numChunks)
    {
//      MITK_INFO << "processing chunk " << currentChunk;
      
      int currentChunkStart = currentChunk * chunkSize;
      int currentChunkEnd   = currentChunkStart + chunkSize - 1 ;
      
      if( currentChunkEnd > (fullZ-1) )
        currentChunkEnd = (fullZ-1);
      
      int currentChunkSize = currentChunkEnd - currentChunkStart + 1;
    
      sgc.fillSlices( currentChunkStart , currentChunkEnd );

      glBindTexture(vtkgl::TEXTURE_3D, volume1);
      vtkgl::TexSubImage3D(vtkgl::TEXTURE_3D,0,0,0,currentChunkStart,fullX,fullY,currentChunkSize,GL_RGBA,GL_UNSIGNED_BYTE,tmpPtr);
                                                  
      glBindTexture(vtkgl::TEXTURE_3D, volume2);
      vtkgl::TexSubImage3D(vtkgl::TEXTURE_3D,0,0,0,currentChunkStart,fullX,fullY,currentChunkSize,GL_RGB,GL_UNSIGNED_BYTE,tmpPtr2);
                                                    
      currentChunk ++;
    }
  }
  
  delete tmpPtr;
  delete tmpPtr2;
}
template<class T >
void vtkVolumeTextureMapper3DComputeScalars ( T *  dataPtr,
vtkMitkVolumeTextureMapper3D me,
float  offset,
float  scale,
GLuint  volume1,
GLuint   
)

Definition at line 1032 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.

References ScalarGradientCompute< T >::fillSlices(), GL_RGBA, GL_UNSIGNED_BYTE, and glBindTexture().

{
  T              *inPtr;
  // unsigned char  *outPtr, *outPtr2;
  // int             i, j, k;
  // int             idx;

  int   inputDimensions[3];
  double inputSpacing[3];
  vtkImageData *input = me->GetInput();

  input->GetDimensions( inputDimensions );
  input->GetSpacing( inputSpacing );

  int   outputDimensions[3];
  float outputSpacing[3];
  me->GetVolumeDimensions( outputDimensions );
  me->GetVolumeSpacing( outputSpacing );

  // int components = input->GetNumberOfScalarComponents();

  // double wx, wy, wz;
  // double fx, fy, fz;
  // int x, y, z;

  double sampleRate[3];
  sampleRate[0] = outputSpacing[0] / static_cast<double>(inputSpacing[0]);
  sampleRate[1] = outputSpacing[1] / static_cast<double>(inputSpacing[1]);
  sampleRate[2] = outputSpacing[2] / static_cast<double>(inputSpacing[2]);

  int fullX = outputDimensions[0];
  int fullY = outputDimensions[1];
  int fullZ = outputDimensions[2];

  int sizeX = inputDimensions[0];
  int sizeY = inputDimensions[1];
  int sizeZ = inputDimensions[2];

  int chunkSize = 64;
  
  if(fullZ < chunkSize) chunkSize=fullZ;

  int numChunks = ( fullZ + (chunkSize-1) ) / chunkSize;

  inPtr = dataPtr;

  unsigned char *tmpPtr  = new unsigned char[fullX*fullY*chunkSize*4];
  unsigned char *tmpPtr2 = 0;//new unsigned char[fullX*fullY*chunkSize*3];

  // For each Chunk
  {
    ScalarGradientCompute<T> sgc(dataPtr,tmpPtr,tmpPtr2,sizeX,sizeY,sizeZ,fullX,fullY,fullZ,offset,scale);

    int currentChunk = 0;

    while(currentChunk < numChunks)
    {
//      MITK_INFO << "processing chunk " << currentChunk;
      
      int currentChunkStart = currentChunk * chunkSize;
      int currentChunkEnd   = currentChunkStart + chunkSize - 1 ;
      
      if( currentChunkEnd > (fullZ-1) )
        currentChunkEnd = (fullZ-1);
      
      int currentChunkSize = currentChunkEnd - currentChunkStart + 1;
    
      sgc.fillSlices( currentChunkStart , currentChunkEnd );

      glBindTexture(vtkgl::TEXTURE_3D, volume1);
      vtkgl::TexSubImage3D(vtkgl::TEXTURE_3D,0,0,0,currentChunkStart,fullX,fullY,currentChunkSize,GL_RGBA,GL_UNSIGNED_BYTE,tmpPtr);
                                                  /*
      glBindTexture(vtkgl::TEXTURE_3D, volume2);
      vtkgl::TexSubImage3D(vtkgl::TEXTURE_3D,0,0,0,currentChunkStart,fullX,fullY,currentChunkSize,GL_RGB,GL_UNSIGNED_BYTE,tmpPtr2);
                                                    */
      currentChunk ++;
    }
  }
  
  delete tmpPtr;
 // delete tmpPtr2;
}

Variable Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines