#include <vtkMitkOpenGLVolumeTextureMapper3D.h>


Public Member Functions | |
| vtkTypeRevisionMacro (vtkMitkOpenGLVolumeTextureMapper3D, vtkMitkVolumeTextureMapper3D) | |
| void | PrintSelf (ostream &os, vtkIndent indent) |
| int | IsRenderSupported (vtkRenderer *ren, vtkVolumeProperty *) |
| virtual void | Render (vtkRenderer *ren, vtkVolume *vol) |
| vtkGetMacro (Initialized, int) | |
| void | ReleaseGraphicsResources (vtkWindow *) |
Static Public Member Functions | |
| static vtkMitkOpenGLVolumeTextureMapper3D * | New () |
Protected Member Functions | |
| vtkMitkOpenGLVolumeTextureMapper3D () | |
| ~vtkMitkOpenGLVolumeTextureMapper3D () | |
| void | GetLightInformation (vtkRenderer *ren, vtkVolume *vol, GLfloat lightDirection[2][4], GLfloat lightDiffuseColor[2][4], GLfloat lightSpecularColor[2][4], GLfloat halfwayVector[2][4], GLfloat *ambient) |
| void | Initialize (vtkRenderer *r) |
| virtual void | RenderFP (vtkRenderer *ren, vtkVolume *vol) |
| void | SetupOneIndependentTextures (vtkRenderer *ren, vtkVolume *vol) |
| void | RenderOneIndependentShadeFP (vtkRenderer *ren, vtkVolume *vol) |
| void | SetupRGBATextures (vtkRenderer *ren, vtkVolume *vol) |
| void | RenderRGBAShadeFP (vtkRenderer *ren, vtkVolume *vol) |
| void | DeleteTextureIndex (GLuint *index) |
| void | CreateTextureIndex (GLuint *index) |
| void | RenderPolygons (vtkRenderer *ren, vtkVolume *vol, int stages[4]) |
| void | SetupProgramLocalsForShadingFP (vtkRenderer *ren, vtkVolume *vol) |
| void | Setup3DTextureParameters (bool linear) |
| void | ComputeVolumeDimensions () |
| bool | UpdateVolumes (vtkVolume *) |
| bool | UpdateVolumesRGBA (vtkVolume *) |
Protected Attributes | |
| bool | RenderPossible |
| int | Initialized |
| GLuint | Volume1Index |
| GLuint | Volume2Index |
| GLuint | Volume3Index |
| GLuint | ColorLookupIndex |
| GLuint | AlphaLookupIndex |
| GLuint | prgOneComponentShade |
| GLuint | prgRGBAShade |
| vtkRenderWindow * | RenderWindow |
| bool | SupportsCompressedTexture |
Definition at line 43 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
| vtkMitkOpenGLVolumeTextureMapper3D::vtkMitkOpenGLVolumeTextureMapper3D | ( | ) | [protected] |
Definition at line 301 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References AlphaLookupIndex, ColorLookupIndex, Initialized, prgOneComponentShade, prgRGBAShade, RenderWindow, SupportsCompressedTexture, Volume1Index, Volume2Index, and Volume3Index.
{
//GPU_INFO << "vtkMitkOpenGLVolumeTextureMapper3D";
this->Initialized = 0;
this->Volume1Index = 0;
this->Volume2Index = 0;
this->Volume3Index = 0;
this->ColorLookupIndex = 0;
this->AlphaLookupIndex = 0;
this->RenderWindow = NULL;
this->SupportsCompressedTexture = false;
prgOneComponentShade = 0;
prgRGBAShade = 0;
}
| vtkMitkOpenGLVolumeTextureMapper3D::~vtkMitkOpenGLVolumeTextureMapper3D | ( | ) | [protected] |
Definition at line 318 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References prgOneComponentShade, and prgRGBAShade.
{
//GPU_INFO << "~vtkMitkOpenGLVolumeTextureMapper3D";
if(prgOneComponentShade)
vtkgl::DeleteProgramsARB( 1, &prgOneComponentShade );
if(prgRGBAShade)
vtkgl::DeleteProgramsARB( 1, &prgRGBAShade );
}
| void vtkMitkOpenGLVolumeTextureMapper3D::ComputeVolumeDimensions | ( | ) | [protected] |
Definition at line 1458 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References MITK_WARN, vtkMitkVolumeTextureMapper3D::SupportsNonPowerOfTwoTextures, vtkMitkVolumeTextureMapper3D::VolumeDimensions, and vtkMitkVolumeTextureMapper3D::VolumeSpacing.
{
// Get the image data
vtkImageData *input = this->GetInput();
// How big does the Volume need to be?
int dim[3];
input->GetDimensions(dim);
int powerOfTwoDim[3];
if(this->SupportsNonPowerOfTwoTextures)
{
for ( int i = 0; i < 3; i++ )
powerOfTwoDim[i]=(dim[i]+1)&~1;
// MITK_INFO << "using non-power-two even textures (" << (1.0-double(dim[0]*dim[1]*dim[2])/double(powerOfTwoDim[0]*powerOfTwoDim[1]*powerOfTwoDim[2])) * 100.0 << "% memory wasted)";
}
else
{
for ( int i = 0; i < 3; i++ )
{
powerOfTwoDim[i] = 4;
while ( powerOfTwoDim[i] < dim[i] )
powerOfTwoDim[i] *= 2;
}
MITK_WARN << "using power-two textures (" << (1.0-double(dim[0]*dim[1]*dim[2])/double(powerOfTwoDim[0]*powerOfTwoDim[1]*powerOfTwoDim[2])) * 100.0 << "% memory wasted)";
}
// Save the volume size
this->VolumeDimensions[0] = powerOfTwoDim[0];
this->VolumeDimensions[1] = powerOfTwoDim[1];
this->VolumeDimensions[2] = powerOfTwoDim[2];
// What is the spacing?
double spacing[3];
input->GetSpacing(spacing);
// Compute the new spacing
this->VolumeSpacing[0] = ( dim[0] -1.01)*spacing[0] / static_cast<double>(this->VolumeDimensions[0]-1);
this->VolumeSpacing[1] = ( dim[1] -1.01)*spacing[1] / static_cast<double>(this->VolumeDimensions[1]-1);
this->VolumeSpacing[2] = ((dim[2])-1.01)*spacing[2] / static_cast<double>(this->VolumeDimensions[2]-1);
}
| void vtkMitkOpenGLVolumeTextureMapper3D::CreateTextureIndex | ( | GLuint * | index ) | [protected] |
Definition at line 500 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References glGenTextures().
{
//GPU_INFO << "CreateTextureIndex";
GLuint tempIndex=0;
glGenTextures(1, &tempIndex);
*index = static_cast<long>(tempIndex);
}
| void vtkMitkOpenGLVolumeTextureMapper3D::DeleteTextureIndex | ( | GLuint * | index ) | [protected] |
Definition at line 487 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References glDeleteTextures(), and glIsTexture().
Referenced by ReleaseGraphicsResources().
{
//GPU_INFO << "DeleteTextureIndex";
if (glIsTexture(*index))
{
GLuint tempIndex;
tempIndex = *index;
glDeleteTextures(1, &tempIndex);
*index = 0;
}
}
| void vtkMitkOpenGLVolumeTextureMapper3D::GetLightInformation | ( | vtkRenderer * | ren, |
| vtkVolume * | vol, | ||
| GLfloat | lightDirection[2][4], | ||
| GLfloat | lightDiffuseColor[2][4], | ||
| GLfloat | lightSpecularColor[2][4], | ||
| GLfloat | halfwayVector[2][4], | ||
| GLfloat * | ambient | ||
| ) | [protected] |
| void vtkMitkOpenGLVolumeTextureMapper3D::Initialize | ( | vtkRenderer * | r ) | [protected] |
Definition at line 2221 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References GPU_WARN, Initialized, prgOneComponentShade, prgRGBAShade, RenderPossible, SupportsCompressedTexture, vtkMitkVolumeTextureMapper3D::SupportsNonPowerOfTwoTextures, vtkMitkVolumeTextureMapper3D_FourDependentShadeFP, and vtkMitkVolumeTextureMapper3D_OneComponentShadeFP.
Referenced by IsRenderSupported(), and Render().
{
//GPU_INFO << "Initialize";
this->Initialized = 1;
// vtkOpenGLExtensionManager * extensions = vtkOpenGLExtensionManager::New();
//extensions->SetRenderWindow(NULL); // set render window to the current one.
vtkOpenGLExtensionManager *extensions=static_cast<vtkOpenGLRenderWindow *>(renderer->GetRenderWindow())->GetExtensionManager();
int supports_texture3D=extensions->ExtensionSupported( "GL_VERSION_1_2" );
if(supports_texture3D)
{
extensions->LoadExtension("GL_VERSION_1_2");
}
else
{
supports_texture3D=extensions->ExtensionSupported( "GL_EXT_texture3D" );
if(supports_texture3D)
{
extensions->LoadCorePromotedExtension("GL_EXT_texture3D");
}
}
int supports_multitexture=extensions->ExtensionSupported( "GL_VERSION_1_3" );
if(supports_multitexture)
{
extensions->LoadExtension("GL_VERSION_1_3");
}
else
{
supports_multitexture=
extensions->ExtensionSupported("GL_ARB_multitexture");
if(supports_multitexture)
{
extensions->LoadCorePromotedExtension("GL_ARB_multitexture");
}
}
this->SupportsCompressedTexture=extensions->ExtensionSupported("GL_VERSION_1_3")==1;
if(!this->SupportsCompressedTexture)
{
this->SupportsCompressedTexture=
extensions->ExtensionSupported("GL_ARB_texture_compression")==1;
if(this->SupportsCompressedTexture)
{
extensions->LoadCorePromotedExtension("GL_ARB_texture_compression");
}
}
//GPU_INFO(this->SupportsCompressedTexture) << "supporting compressed textures";
this->SupportsNonPowerOfTwoTextures=
extensions->ExtensionSupported("GL_VERSION_2_0")
|| extensions->ExtensionSupported("GL_ARB_texture_non_power_of_two");
//GPU_INFO << "np2: " << (this->SupportsNonPowerOfTwoTextures?1:0);
int supports_GL_ARB_fragment_program = extensions->ExtensionSupported( "GL_ARB_fragment_program" );
if(supports_GL_ARB_fragment_program)
{
extensions->LoadExtension( "GL_ARB_fragment_program" );
}
int supports_GL_ARB_vertex_program = extensions->ExtensionSupported( "GL_ARB_vertex_program" );
if(supports_GL_ARB_vertex_program)
{
extensions->LoadExtension( "GL_ARB_vertex_program" );
}
RenderPossible = 0;
if ( supports_texture3D &&
supports_multitexture &&
supports_GL_ARB_fragment_program &&
supports_GL_ARB_vertex_program &&
vtkgl::TexImage3D &&
vtkgl::ActiveTexture &&
vtkgl::MultiTexCoord3fv &&
vtkgl::GenProgramsARB &&
vtkgl::DeleteProgramsARB &&
vtkgl::BindProgramARB &&
vtkgl::ProgramStringARB &&
vtkgl::ProgramLocalParameter4fARB )
{
RenderPossible = 1;
}
else
{
std::string errString = "no gpu-acceleration possible cause following extensions/methods are missing or unsupported:";
if(!supports_texture3D) errString += " EXT_TEXTURE3D";
if(!supports_multitexture) errString += " EXT_MULTITEXTURE";
if(!supports_GL_ARB_fragment_program) errString += " ARB_FRAGMENT_PROGRAM";
if(!supports_GL_ARB_vertex_program) errString += " ARB_VERTEX_PROGRAM";
if(!vtkgl::TexImage3D) errString += " glTexImage3D";
if(!vtkgl::ActiveTexture) errString += " glActiveTexture";
if(!vtkgl::MultiTexCoord3fv) errString += " glMultiTexCoord3fv";
if(!vtkgl::GenProgramsARB) errString += " glGenProgramsARB";
if(!vtkgl::DeleteProgramsARB) errString += " glDeleteProgramsARB";
if(!vtkgl::BindProgramARB) errString += " glBindProgramARB";
if(!vtkgl::ProgramStringARB) errString += " glProgramStringARB";
if(!vtkgl::ProgramLocalParameter4fARB) errString += " glProgramLocalParameter4fARB";
GPU_WARN << errString;
};
if(RenderPossible)
{
vtkgl::GenProgramsARB( 1, &prgOneComponentShade );
vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, prgOneComponentShade );
vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB,
vtkgl::PROGRAM_FORMAT_ASCII_ARB,
static_cast<GLsizei>(strlen(vtkMitkVolumeTextureMapper3D_OneComponentShadeFP)),
vtkMitkVolumeTextureMapper3D_OneComponentShadeFP );
vtkgl::GenProgramsARB( 1, &prgRGBAShade );
vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, prgRGBAShade );
vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB,
vtkgl::PROGRAM_FORMAT_ASCII_ARB,
static_cast<GLsizei>(strlen(vtkMitkVolumeTextureMapper3D_FourDependentShadeFP)),
vtkMitkVolumeTextureMapper3D_FourDependentShadeFP );
}
}
| int vtkMitkOpenGLVolumeTextureMapper3D::IsRenderSupported | ( | vtkRenderer * | ren, |
| vtkVolumeProperty * | property | ||
| ) | [virtual] |
Implements vtkMitkVolumeTextureMapper3D.
Definition at line 2192 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References Initialize(), Initialized, and RenderPossible.
{
//GPU_INFO << "IsRenderSupported";
if ( !this->Initialized )
{
//this->Initialize();
this->Initialize(renderer);
}
if ( !this->RenderPossible )
{
return 0;
}
if ( !this->GetInput() )
{
return 0;
}
if ( this->GetInput()->GetNumberOfScalarComponents() > 1 &&
property->GetIndependentComponents() )
{
return 0;
}
return 1;
}
| static vtkMitkOpenGLVolumeTextureMapper3D* vtkMitkOpenGLVolumeTextureMapper3D::New | ( | ) | [static] |
Reimplemented from vtkMitkVolumeTextureMapper3D.
Referenced by mitk::GPUVolumeMapper3D::InitGPU(), Render(), RenderPolygons(), and SetupProgramLocalsForShadingFP().
| void vtkMitkOpenGLVolumeTextureMapper3D::PrintSelf | ( | ostream & | os, |
| vtkIndent | indent | ||
| ) |
Reimplemented from vtkMitkVolumeTextureMapper3D.
Definition at line 2345 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References Initialized, and RenderWindow.
{
// vtkOpenGLExtensionManager * extensions = vtkOpenGLExtensionManager::New();
// extensions->SetRenderWindow(NULL); // set render window to current render window
os << indent << "Initialized " << this->Initialized << endl;
/* if ( this->Initialized )
{
os << indent << "Supports GL_VERSION_1_2:"
<< extensions->ExtensionSupported( "GL_VERSION_1_2" ) << endl;
os << indent << "Supports GL_EXT_texture3D:"
<< extensions->ExtensionSupported( "GL_EXT_texture3D" ) << endl;
os << indent << "Supports GL_VERSION_1_3:"
<< extensions->ExtensionSupported( "GL_VERSION_1_3" ) << endl;
os << indent << "Supports GL_ARB_multitexture: "
<< extensions->ExtensionSupported( "GL_ARB_multitexture" ) << endl;
os << indent << "Supports GL_NV_texture_shader2: "
<< extensions->ExtensionSupported( "GL_NV_texture_shader2" ) << endl;
os << indent << "Supports GL_NV_register_combiners2: "
<< extensions->ExtensionSupported( "GL_NV_register_combiners2" )
<< endl;
os << indent << "Supports GL_ATI_fragment_shader: "
<< extensions->ExtensionSupported( "GL_ATI_fragment_shader" ) << endl;
os << indent << "Supports GL_ARB_fragment_program: "
<< extensions->ExtensionSupported( "GL_ARB_fragment_program" ) << endl;
os << indent << "Supports GL_ARB_texture_compression: "
<< extensions->ExtensionSupported( "GL_ARB_texture_compression" )
<< endl;
os << indent << "Supports GL_VERSION_2_0:"
<< extensions->ExtensionSupported( "GL_VERSION_2_0" )
<< endl;
os << indent << "Supports GL_ARB_texture_non_power_of_two:"
<< extensions->ExtensionSupported( "GL_ARB_texture_non_power_of_two" )
<< endl;
}
extensions->Delete();
*/
if(this->RenderWindow!=0)
{
vtkOpenGLExtensionManager *extensions=
static_cast<vtkOpenGLRenderWindow *>(this->RenderWindow)->GetExtensionManager();
if ( this->Initialized )
{
os << indent << "Supports GL_VERSION_1_2:"
<< extensions->ExtensionSupported( "GL_VERSION_1_2" ) << endl;
os << indent << "Supports GL_EXT_texture3D:"
<< extensions->ExtensionSupported( "GL_EXT_texture3D" ) << endl;
os << indent << "Supports GL_VERSION_1_3:"
<< extensions->ExtensionSupported( "GL_VERSION_1_3" ) << endl;
os << indent << "Supports GL_ARB_multitexture: "
<< extensions->ExtensionSupported( "GL_ARB_multitexture" ) << endl;
os << indent << "Supports GL_NV_texture_shader2: "
<< extensions->ExtensionSupported( "GL_NV_texture_shader2" ) << endl;
os << indent << "Supports GL_NV_register_combiners2: "
<< extensions->ExtensionSupported( "GL_NV_register_combiners2" )
<< endl;
os << indent << "Supports GL_ATI_fragment_shader: "
<< extensions->ExtensionSupported( "GL_ATI_fragment_shader" ) << endl;
os << indent << "Supports GL_ARB_fragment_program: "
<< extensions->ExtensionSupported( "GL_ARB_fragment_program" )
<< endl;
os << indent << "Supports GL_ARB_texture_compression: "
<< extensions->ExtensionSupported( "GL_ARB_texture_compression" )
<< endl;
os << indent << "Supports GL_VERSION_2_0:"
<< extensions->ExtensionSupported( "GL_VERSION_2_0" )
<< endl;
os << indent << "Supports GL_ARB_texture_non_power_of_two:"
<< extensions->ExtensionSupported( "GL_ARB_texture_non_power_of_two" )
<< endl;
}
}
this->Superclass::PrintSelf(os,indent);
}
| void vtkMitkOpenGLVolumeTextureMapper3D::ReleaseGraphicsResources | ( | vtkWindow * | renWin ) |
Definition at line 329 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References AlphaLookupIndex, ColorLookupIndex, DeleteTextureIndex(), RenderWindow, SupportsCompressedTexture, vtkMitkVolumeTextureMapper3D::SupportsNonPowerOfTwoTextures, Volume1Index, Volume2Index, and Volume3Index.
{
//GPU_INFO << "ReleaseGraphicsResources";
if (( this->Volume1Index || this->Volume2Index ||
this->Volume3Index || this->ColorLookupIndex) && renWin)
{
static_cast<vtkRenderWindow *>(renWin)->MakeCurrent();
#ifdef GL_VERSION_1_1
// free any textures
this->DeleteTextureIndex( &this->Volume1Index );
this->DeleteTextureIndex( &this->Volume2Index );
this->DeleteTextureIndex( &this->Volume3Index );
this->DeleteTextureIndex( &this->ColorLookupIndex );
this->DeleteTextureIndex( &this->AlphaLookupIndex );
#endif
}
this->Volume1Index = 0;
this->Volume2Index = 0;
this->Volume3Index = 0;
this->ColorLookupIndex = 0;
this->RenderWindow = NULL;
this->SupportsCompressedTexture=false;
this->SupportsNonPowerOfTwoTextures=false;
this->Modified();
}
| void vtkMitkOpenGLVolumeTextureMapper3D::Render | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [virtual] |
Reimplemented from vtkMitkVolumeTextureMapper3D.
Definition at line 358 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References GL_CLIP_PLANE0, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_ENABLE_BIT, GL_LIGHTING, GL_MODELVIEW, GL_POLYGON_BIT, GL_STENCIL_BUFFER_BIT, GL_TEXTURE_BIT, glClipPlane(), glColor4f(), glDisable(), glEnable(), glMatrixMode(), glMultMatrixd(), glPopAttrib(), glPopMatrix(), glPushAttrib(), glPushMatrix(), Initialize(), Initialized, matrix(), New(), RenderFP(), and RenderPossible.
{
//GPU_INFO << "Render";
ren->GetRenderWindow()->MakeCurrent();
if ( !this->Initialized )
{
//this->Initialize();
this->Initialize(ren);
}
if ( !this->RenderPossible )
{
vtkErrorMacro( "required extensions not supported" );
return;
}
vtkMatrix4x4 *matrix = vtkMatrix4x4::New();
vtkPlaneCollection *clipPlanes;
vtkPlane *plane;
int numClipPlanes = 0;
double planeEquation[4];
// build transformation
vol->GetMatrix(matrix);
matrix->Transpose();
glPushAttrib(GL_ENABLE_BIT |
GL_COLOR_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_POLYGON_BIT |
GL_TEXTURE_BIT);
int i;
// Use the OpenGL clip planes
clipPlanes = this->ClippingPlanes;
if ( clipPlanes )
{
numClipPlanes = clipPlanes->GetNumberOfItems();
if (numClipPlanes > 6)
{
vtkErrorMacro(<< "OpenGL guarantees only 6 additional clipping planes");
}
for (i = 0; i < numClipPlanes; i++)
{
glEnable(static_cast<GLenum>(GL_CLIP_PLANE0+i));
plane = static_cast<vtkPlane *>(clipPlanes->GetItemAsObject(i));
planeEquation[0] = plane->GetNormal()[0];
planeEquation[1] = plane->GetNormal()[1];
planeEquation[2] = plane->GetNormal()[2];
planeEquation[3] = -(planeEquation[0]*plane->GetOrigin()[0]+
planeEquation[1]*plane->GetOrigin()[1]+
planeEquation[2]*plane->GetOrigin()[2]);
glClipPlane(static_cast<GLenum>(GL_CLIP_PLANE0+i),planeEquation);
}
}
// insert model transformation
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glMultMatrixd(matrix->Element[0]);
glColor4f( 1.0, 1.0, 1.0, 1.0 );
// Turn lighting off - the polygon textures already have illumination
glDisable( GL_LIGHTING );
vtkGraphicErrorMacro(ren->GetRenderWindow(),"Before actual render method");
this->RenderFP(ren,vol);
// pop transformation matrix
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
matrix->Delete();
glPopAttrib();
}
| void vtkMitkOpenGLVolumeTextureMapper3D::RenderFP | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [protected, virtual] |
Definition at line 447 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References GL_BLEND, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_TEXTURE_2D, glBlendFunc(), glDisable(), glEnable(), RenderOneIndependentShadeFP(), and RenderRGBAShadeFP().
Referenced by Render().
{
//GPU_INFO << "RenderFP";
/*
glAlphaFunc (GL_GREATER, static_cast<GLclampf>(1.0/255.0));
glEnable (GL_ALPHA_TEST);
*/
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
int components = this->GetInput()->GetNumberOfScalarComponents();
switch ( components )
{
case 1:
this->RenderOneIndependentShadeFP(ren,vol);
break;
case 4:
this->RenderRGBAShadeFP(ren,vol);
break;
}
vtkgl::ActiveTexture( vtkgl::TEXTURE2);
glDisable( GL_TEXTURE_2D );
glDisable( vtkgl::TEXTURE_3D );
vtkgl::ActiveTexture( vtkgl::TEXTURE1);
glDisable( GL_TEXTURE_2D );
glDisable( vtkgl::TEXTURE_3D );
vtkgl::ActiveTexture( vtkgl::TEXTURE0);
glDisable( GL_TEXTURE_2D );
glDisable( vtkgl::TEXTURE_3D );
glDisable( GL_BLEND );
}
| void vtkMitkOpenGLVolumeTextureMapper3D::RenderOneIndependentShadeFP | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [protected] |
Definition at line 1830 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References ColorLookupIndex, GL_TEXTURE_2D, glBindTexture(), glDisable(), glEnable(), prgOneComponentShade, RenderPolygons(), SetupOneIndependentTextures(), SetupProgramLocalsForShadingFP(), Volume1Index, and Volume2Index.
Referenced by RenderFP().
{
//GPU_INFO << "RenderOneIndependentShadeFP";
this->SetupOneIndependentTextures( ren, vol );
glEnable( vtkgl::FRAGMENT_PROGRAM_ARB );
vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, prgOneComponentShade );
this->SetupProgramLocalsForShadingFP( ren, vol );
// Bind Textures
{
vtkgl::ActiveTexture( vtkgl::TEXTURE0 );
glDisable( GL_TEXTURE_2D );
glEnable( vtkgl::TEXTURE_3D );
glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index);
vtkgl::ActiveTexture( vtkgl::TEXTURE1 );
glEnable( GL_TEXTURE_2D );
glDisable( vtkgl::TEXTURE_3D );
glBindTexture(GL_TEXTURE_2D, this->ColorLookupIndex);
vtkgl::ActiveTexture( vtkgl::TEXTURE2 );
glDisable( GL_TEXTURE_2D );
glEnable( vtkgl::TEXTURE_3D );
glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index);
}
int stages[4] = {1,1,1,0};
this->RenderPolygons( ren, vol, stages );
glDisable( vtkgl::FRAGMENT_PROGRAM_ARB );
}
| void vtkMitkOpenGLVolumeTextureMapper3D::RenderPolygons | ( | vtkRenderer * | ren, |
| vtkVolume * | vol, | ||
| int | stages[4] | ||
| ) | [protected] |
Definition at line 509 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References vtkMitkVolumeTextureMapper3D::ComputePolygons(), GL_TRIANGLE_FAN, glBegin(), glEnd(), glVertex3fv(), New(), vtkMitkVolumeTextureMapper3D::NumberOfPolygons, and vtkMitkVolumeTextureMapper3D::PolygonBuffer.
Referenced by RenderOneIndependentShadeFP(), and RenderRGBAShadeFP().
{
//GPU_INFO << "RenderPolygons";
vtkRenderWindow *renWin = ren->GetRenderWindow();
if ( renWin->CheckAbortStatus() )
{
return;
}
double bounds[27][6];
float distance2[27];
int numIterations;
int i, j, k;
// No cropping case - render the whole thing
if ( !this->Cropping )
{
// Use the input data bounds - we'll take care of the volume's
// matrix during rendering
this->GetInput()->GetBounds(bounds[0]);
numIterations = 1;
}
// Simple cropping case - render the subvolume
else if ( this->CroppingRegionFlags == 0x2000 )
{
this->GetCroppingRegionPlanes(bounds[0]);
numIterations = 1;
}
// Complex cropping case - render each region in back-to-front order
else
{
// Get the camera position
double camPos[4];
ren->GetActiveCamera()->GetPosition(camPos);
double volBounds[6];
this->GetInput()->GetBounds(volBounds);
// Pass camera through inverse volume matrix
// so that we are in the same coordinate system
vtkMatrix4x4 *volMatrix = vtkMatrix4x4::New();
vol->GetMatrix( volMatrix );
camPos[3] = 1.0;
volMatrix->Invert();
volMatrix->MultiplyPoint( camPos, camPos );
volMatrix->Delete();
if ( camPos[3] )
{
camPos[0] /= camPos[3];
camPos[1] /= camPos[3];
camPos[2] /= camPos[3];
}
// These are the region limits for x (first four), y (next four) and
// z (last four). The first region limit is the lower bound for
// that axis, the next two are the region planes along that axis, and
// the final one in the upper bound for that axis.
float limit[12];
for ( i = 0; i < 3; i++ )
{
limit[i*4 ] = volBounds[i*2];
limit[i*4+1] = this->CroppingRegionPlanes[i*2];
limit[i*4+2] = this->CroppingRegionPlanes[i*2+1];
limit[i*4+3] = volBounds[i*2+1];
}
// For each of the 27 possible regions, find out if it is enabled,
// and if so, compute the bounds and the distance from the camera
// to the center of the region.
int numRegions = 0;
int region;
for ( region = 0; region < 27; region++ )
{
int regionFlag = 1<<region;
if ( this->CroppingRegionFlags & regionFlag )
{
// what is the coordinate in the 3x3x3 grid
int loc[3];
loc[0] = region%3;
loc[1] = (region/3)%3;
loc[2] = (region/9)%3;
// compute the bounds and center
float center[3];
for ( i = 0; i < 3; i++ )
{
bounds[numRegions][i*2 ] = limit[4*i+loc[i]];
bounds[numRegions][i*2+1] = limit[4*i+loc[i]+1];
center[i] =
(bounds[numRegions][i*2 ] +
bounds[numRegions][i*2+1])/2.0;
}
// compute the distance squared to the center
distance2[numRegions] =
(camPos[0]-center[0])*(camPos[0]-center[0]) +
(camPos[1]-center[1])*(camPos[1]-center[1]) +
(camPos[2]-center[2])*(camPos[2]-center[2]);
// we've added one region
numRegions++;
}
}
// Do a quick bubble sort on distance
for ( i = 1; i < numRegions; i++ )
{
for ( j = i; j > 0 && distance2[j] > distance2[j-1]; j-- )
{
float tmpBounds[6];
float tmpDistance2;
for ( k = 0; k < 6; k++ )
{
tmpBounds[k] = bounds[j][k];
}
tmpDistance2 = distance2[j];
for ( k = 0; k < 6; k++ )
{
bounds[j][k] = bounds[j-1][k];
}
distance2[j] = distance2[j-1];
for ( k = 0; k < 6; k++ )
{
bounds[j-1][k] = tmpBounds[k];
}
distance2[j-1] = tmpDistance2;
}
}
numIterations = numRegions;
}
// loop over all regions we need to render
for ( int loop = 0;
loop < numIterations;
loop++ )
{
// Compute the set of polygons for this region
// according to the bounds
this->ComputePolygons( ren, vol, bounds[loop] );
// Loop over the polygons
for ( i = 0; i < this->NumberOfPolygons; i++ )
{
if ( renWin->CheckAbortStatus() )
{
return;
}
float *ptr = this->PolygonBuffer + 36*i;
glBegin( GL_TRIANGLE_FAN );
for ( j = 0; j < 6; j++ )
{
if ( ptr[0] < 0.0 )
{
break;
}
for ( k = 0; k < 4; k++ )
{
if ( stages[k] )
{
vtkgl::MultiTexCoord3fv( vtkgl::TEXTURE0 + k, ptr );
}
}
glVertex3fv( ptr+3 );
ptr += 6;
}
glEnd();
}
}
}
| void vtkMitkOpenGLVolumeTextureMapper3D::RenderRGBAShadeFP | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [protected] |
Definition at line 1868 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References GL_TEXTURE_2D, glBindTexture(), glDisable(), glEnable(), prgRGBAShade, RenderPolygons(), SetupProgramLocalsForShadingFP(), SetupRGBATextures(), Volume1Index, and Volume2Index.
Referenced by RenderFP().
{
this->SetupRGBATextures(ren, vol);
glEnable( vtkgl::FRAGMENT_PROGRAM_ARB );
vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, prgRGBAShade );
this->SetupProgramLocalsForShadingFP( ren, vol );
// Bind Textures
{
vtkgl::ActiveTexture( vtkgl::TEXTURE0 );
glDisable( GL_TEXTURE_2D );
glEnable( vtkgl::TEXTURE_3D );
glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index);
vtkgl::ActiveTexture( vtkgl::TEXTURE1 );
glDisable( GL_TEXTURE_2D );
glEnable( vtkgl::TEXTURE_3D );
glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index);
}
int stages[4] = {1,1,1,0};
this->RenderPolygons( ren, vol, stages );
glDisable( vtkgl::FRAGMENT_PROGRAM_ARB );
}
| void vtkMitkOpenGLVolumeTextureMapper3D::Setup3DTextureParameters | ( | bool | linear ) | [protected] |
Definition at line 1674 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References GL_CLAMP, GL_LINEAR, GL_NEAREST, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, and glTexParameterf().
{
//GPU_INFO << "Setup3DTextureParameters";
if( linear )
{
glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
else
{
glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
}
glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP );
}
| void vtkMitkOpenGLVolumeTextureMapper3D::SetupOneIndependentTextures | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [protected] |
Referenced by RenderOneIndependentShadeFP().
| void vtkMitkOpenGLVolumeTextureMapper3D::SetupProgramLocalsForShadingFP | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [protected] |
Definition at line 2028 of file vtkMitkOpenGLVolumeTextureMapper3D.cpp.
References New().
Referenced by RenderOneIndependentShadeFP(), and RenderRGBAShadeFP().
{
//GPU_INFO << "SetupProgramLocalsForShadingFP";
GLfloat lightDirection[2][4];
GLfloat lightDiffuseColor[2][4];
GLfloat lightSpecularColor[2][4];
GLfloat halfwayVector[2][4];
GLfloat ambientColor[4];
float ambient = vol->GetProperty()->GetAmbient();
float diffuse = vol->GetProperty()->GetDiffuse();
float specular = vol->GetProperty()->GetSpecular();
float specularPower = vol->GetProperty()->GetSpecularPower();
vtkTransform *volumeTransform = vtkTransform::New();
volumeTransform->SetMatrix( vol->GetMatrix() );
volumeTransform->Inverse();
vtkLightCollection *lights = ren->GetLights();
lights->InitTraversal();
vtkLight *light[2];
light[0] = lights->GetNextItem();
light[1] = lights->GetNextItem();
int lightIndex = 0;
double cameraPosition[3];
double cameraFocalPoint[3];
ren->GetActiveCamera()->GetPosition( cameraPosition );
ren->GetActiveCamera()->GetFocalPoint( cameraFocalPoint );
volumeTransform->TransformPoint( cameraPosition, cameraPosition );
volumeTransform->TransformPoint( cameraFocalPoint, cameraFocalPoint );
double viewDirection[4];
viewDirection[0] = cameraFocalPoint[0] - cameraPosition[0];
viewDirection[1] = cameraFocalPoint[1] - cameraPosition[1];
viewDirection[2] = cameraFocalPoint[2] - cameraPosition[2];
viewDirection[3] = 0.0;
vtkMath::Normalize( viewDirection );
ambientColor[0] = 0.0;
ambientColor[1] = 0.0;
ambientColor[2] = 0.0;
ambientColor[3] = 0.0;
for ( lightIndex = 0; lightIndex < 2; lightIndex++ )
{
float dir[3] = {0,0,0};
float half[3] = {0,0,0};
if ( light[lightIndex] == NULL ||
light[lightIndex]->GetSwitch() == 0 )
{
lightDiffuseColor[lightIndex][0] = 0.0;
lightDiffuseColor[lightIndex][1] = 0.0;
lightDiffuseColor[lightIndex][2] = 0.0;
lightDiffuseColor[lightIndex][3] = 0.0;
lightSpecularColor[lightIndex][0] = 0.0;
lightSpecularColor[lightIndex][1] = 0.0;
lightSpecularColor[lightIndex][2] = 0.0;
lightSpecularColor[lightIndex][3] = 0.0;
}
else
{
float lightIntensity = light[lightIndex]->GetIntensity();
double lightColor[3];
light[lightIndex]->GetDiffuseColor( lightColor );
double lightPosition[3];
double lightFocalPoint[3];
light[lightIndex]->GetTransformedPosition( lightPosition );
light[lightIndex]->GetTransformedFocalPoint( lightFocalPoint );
volumeTransform->TransformPoint( lightPosition, lightPosition );
volumeTransform->TransformPoint( lightFocalPoint, lightFocalPoint );
dir[0] = lightPosition[0] - lightFocalPoint[0];
dir[1] = lightPosition[1] - lightFocalPoint[1];
dir[2] = lightPosition[2] - lightFocalPoint[2];
vtkMath::Normalize( dir );
lightDiffuseColor[lightIndex][0] = lightColor[0]*diffuse*lightIntensity;
lightDiffuseColor[lightIndex][1] = lightColor[1]*diffuse*lightIntensity;
lightDiffuseColor[lightIndex][2] = lightColor[2]*diffuse*lightIntensity;
lightDiffuseColor[lightIndex][3] = 0.0;
lightSpecularColor[lightIndex][0]= lightColor[0]*specular*lightIntensity;
lightSpecularColor[lightIndex][1]= lightColor[1]*specular*lightIntensity;
lightSpecularColor[lightIndex][2]= lightColor[2]*specular*lightIntensity;
lightSpecularColor[lightIndex][3] = 0.0;
half[0] = dir[0] - viewDirection[0];
half[1] = dir[1] - viewDirection[1];
half[2] = dir[2] - viewDirection[2];
vtkMath::Normalize( half );
ambientColor[0] += ambient*lightColor[0];
ambientColor[1] += ambient*lightColor[1];
ambientColor[2] += ambient*lightColor[2];
}
lightDirection[lightIndex][0] = dir[0];
lightDirection[lightIndex][1] = dir[1];
lightDirection[lightIndex][2] = dir[2];
lightDirection[lightIndex][3] = 0.0;
halfwayVector[lightIndex][0] = half[0];
halfwayVector[lightIndex][1] = half[1];
halfwayVector[lightIndex][2] = half[2];
halfwayVector[lightIndex][3] = 0.0;
}
volumeTransform->Delete();
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 0,
lightDirection[0][0],
lightDirection[0][1],
lightDirection[0][2],
lightDirection[0][3] );
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 1,
halfwayVector[0][0],
halfwayVector[0][1],
halfwayVector[0][2],
halfwayVector[0][3] );
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 2,
ambient, diffuse, specular, specularPower );
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 3,
lightDiffuseColor[0][0],
lightDiffuseColor[0][1],
lightDiffuseColor[0][2],
lightDiffuseColor[0][3] );
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 4,
lightSpecularColor[0][0],
lightSpecularColor[0][1],
lightSpecularColor[0][2],
lightSpecularColor[0][3] );
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 5,
viewDirection[0],
viewDirection[1],
viewDirection[2],
viewDirection[3] );
vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 6,
2.0, -1.0, 0.0, 0.0 );
}
| void vtkMitkOpenGLVolumeTextureMapper3D::SetupRGBATextures | ( | vtkRenderer * | ren, |
| vtkVolume * | vol | ||
| ) | [protected] |
Referenced by RenderRGBAShadeFP().
| bool vtkMitkOpenGLVolumeTextureMapper3D::UpdateVolumes | ( | vtkVolume * | ) | [protected] |
| bool vtkMitkOpenGLVolumeTextureMapper3D::UpdateVolumesRGBA | ( | vtkVolume * | ) | [protected] |
| vtkMitkOpenGLVolumeTextureMapper3D::vtkGetMacro | ( | Initialized | , |
| int | |||
| ) |
| vtkMitkOpenGLVolumeTextureMapper3D::vtkTypeRevisionMacro | ( | vtkMitkOpenGLVolumeTextureMapper3D | , |
| vtkMitkVolumeTextureMapper3D | |||
| ) |
Definition at line 102 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by ReleaseGraphicsResources(), and vtkMitkOpenGLVolumeTextureMapper3D().
Definition at line 101 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by ReleaseGraphicsResources(), RenderOneIndependentShadeFP(), and vtkMitkOpenGLVolumeTextureMapper3D().
int vtkMitkOpenGLVolumeTextureMapper3D::Initialized [protected] |
Definition at line 97 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by Initialize(), IsRenderSupported(), PrintSelf(), Render(), and vtkMitkOpenGLVolumeTextureMapper3D().
Definition at line 104 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by Initialize(), RenderOneIndependentShadeFP(), vtkMitkOpenGLVolumeTextureMapper3D(), and ~vtkMitkOpenGLVolumeTextureMapper3D().
Definition at line 105 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by Initialize(), RenderRGBAShadeFP(), vtkMitkOpenGLVolumeTextureMapper3D(), and ~vtkMitkOpenGLVolumeTextureMapper3D().
bool vtkMitkOpenGLVolumeTextureMapper3D::RenderPossible [protected] |
Definition at line 84 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by Initialize(), IsRenderSupported(), and Render().
vtkRenderWindow* vtkMitkOpenGLVolumeTextureMapper3D::RenderWindow [protected] |
Definition at line 107 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by PrintSelf(), ReleaseGraphicsResources(), and vtkMitkOpenGLVolumeTextureMapper3D().
bool vtkMitkOpenGLVolumeTextureMapper3D::SupportsCompressedTexture [protected] |
Definition at line 109 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by Initialize(), ReleaseGraphicsResources(), and vtkMitkOpenGLVolumeTextureMapper3D().
Definition at line 98 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by ReleaseGraphicsResources(), RenderOneIndependentShadeFP(), RenderRGBAShadeFP(), and vtkMitkOpenGLVolumeTextureMapper3D().
Definition at line 99 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by ReleaseGraphicsResources(), RenderOneIndependentShadeFP(), RenderRGBAShadeFP(), and vtkMitkOpenGLVolumeTextureMapper3D().
Definition at line 100 of file vtkMitkOpenGLVolumeTextureMapper3D.h.
Referenced by ReleaseGraphicsResources(), and vtkMitkOpenGLVolumeTextureMapper3D().
1.7.2