Commit a0f42de9 authored by Lisa Avila's avatar Lisa Avila

BUG: Fixed problem with fixed point ray cast mapper caused by bad addressing...

BUG: Fixed problem with fixed point ray cast mapper caused by bad addressing into MinMaxVolume. Also, checking in changes to move the ray cast image out into its own class as part of the changes necessary for the AMR mapper
parent 353789dd
......@@ -26,6 +26,7 @@ vtkDirectionEncoder.cxx
vtkEncodedGradientEstimator.cxx
vtkEncodedGradientShader.cxx
vtkFiniteDifferenceGradientEstimator.cxx
vtkFixedPointRayCastImage.cxx
vtkFixedPointVolumeRayCastCompositeGOHelper.cxx
vtkFixedPointVolumeRayCastCompositeGOShadeHelper.cxx
vtkFixedPointVolumeRayCastCompositeHelper.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkFixedPointRayCastImage.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkFixedPointRayCastImage.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkFixedPointRayCastImage, "1.1");
vtkStandardNewMacro(vtkFixedPointRayCastImage);
// Construct a new vtkFixedPointRayCastImage with default values
vtkFixedPointRayCastImage::vtkFixedPointRayCastImage()
{
this->ImageViewportSize[0] = 0;
this->ImageViewportSize[1] = 0;
this->ImageMemorySize[0] = 0;
this->ImageMemorySize[1] = 0;
this->ImageInUseSize[0] = 0;
this->ImageInUseSize[1] = 0;
this->ImageOrigin[0] = 0;
this->ImageOrigin[1] = 0;
this->Image = NULL;
}
// Destruct a vtkFixedPointRayCastImage - clean up any memory used
vtkFixedPointRayCastImage::~vtkFixedPointRayCastImage()
{
delete [] this->Image;
}
// Allocate memory
void vtkFixedPointRayCastImage::AllocateImage()
{
delete [] this->Image;
this->Image = NULL;
if ( this->ImageMemorySize[0]*this->ImageMemorySize[1] > 0 )
{
this->Image = new unsigned short [ ( 4 *
this->ImageMemorySize[0] *
this->ImageMemorySize[1] )];
}
}
// Clear image to 0
void vtkFixedPointRayCastImage::ClearImage()
{
unsigned short *ucptr = this->Image;
for ( int i = 0; i < this->ImageMemorySize[0]*this->ImageMemorySize[1]; i++ )
{
*(ucptr++) = 0;
*(ucptr++) = 0;
*(ucptr++) = 0;
*(ucptr++) = 0;
}
}
void vtkFixedPointRayCastImage::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Image Viewport Size: "
<< this->ImageViewportSize[0] << " "
<< this->ImageViewportSize[1] << endl;
os << indent << "Image Memory Size: "
<< this->ImageMemorySize[0] << " "
<< this->ImageMemorySize[1] << endl;
os << indent << "Image In Use Size: "
<< this->ImageInUseSize[0] << " "
<< this->ImageInUseSize[1] << endl;
os << indent << "Image Origin: "
<< this->ImageOrigin[0] << " "
<< this->ImageOrigin[1] << endl;
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkFixedPointRayCastImage.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkFixedPointRayCastImage - helper class for a ray cast image
// .SECTION Description
// This is a helper class for storing the ray cast image including the
// underlying data and the size of the image. This class is not intended
// to be used directly - just as an internal class in the
// vtkFixedPointVolumeRayCastMapper so that multiple mappers can share
// the same image. Perhaps this class could be generalized
// in the future to be used for other ray cast methods other than the
// fixed point method.
// .SECTION see also
// vtkFixedPointVolumeRayCastMapper
#ifndef __vtkFixedPointRayCastImage_h
#define __vtkFixedPointRayCastImage_h
#include "vtkObject.h"
class VTK_VOLUMERENDERING_EXPORT vtkFixedPointRayCastImage : public vtkObject
{
public:
static vtkFixedPointRayCastImage *New();
vtkTypeRevisionMacro(vtkFixedPointRayCastImage,vtkObject);
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get the internal storage for the image. It is a pointer to
// unsigned short with four components (RGBA) per pixel. This
// memory is allocated when the AllocateImage method is called.
unsigned short *GetImage() {return this->Image;}
// Description:
// Set / Get the ImageViewportSize. This is the size of the
// whole viewport in pixels.
vtkSetVector2Macro( ImageViewportSize, int );
vtkGetVectorMacro( ImageViewportSize, int, 2 );
// Description:
// Set / Get the ImageMemorySize. This is the size in pixels
// of the Image ivar. This will be a power of two in order
// to ensure that the texture can be rendered by graphics
// hardware that requires power of two textures.
vtkSetVector2Macro( ImageMemorySize, int );
vtkGetVectorMacro( ImageMemorySize, int, 2 );
// Description:
// Set / Get the size of the image we are actually using. As
// long as the memory size is big enough, but not too big,
// we won't bother deleting and re-allocated, we'll just
// continue to use the memory size we have. This size will
// always be equal to or less than the ImageMemorySize.
vtkSetVector2Macro( ImageInUseSize, int );
vtkGetVectorMacro( ImageInUseSize, int, 2 );
// Description:
// Set / Get the origin of the image. This is the starting
// pixel within the whole viewport that our Image starts on.
// That is, we could be generating just a subregion of the
// whole viewport due to the fact that our volume occupies
// only a portion of the viewport. The Image pixels will
// start from this location.
vtkSetVector2Macro( ImageOrigin, int );
vtkGetVectorMacro( ImageOrigin, int, 2 );
// Description:
// Call this method once the ImageMemorySize has been set
// the allocate the image. If an image already exists,
// it will be deleted first.
void AllocateImage();
// Description:
// Clear the image to (0,0,0,0) for each pixel.
void ClearImage();
protected:
vtkFixedPointRayCastImage();
~vtkFixedPointRayCastImage();
// This is how big the image would be if it covered the entire viewport
int ImageViewportSize[2];
// This is how big the allocated memory for image is. This may be bigger
// or smaller than ImageFullSize - it will be bigger if necessary to
// ensure a power of 2, it will be smaller if the volume only covers a
// small region of the viewport
int ImageMemorySize[2];
// This is the size of subregion in ImageSize image that we are using for
// the current image. Since ImageSize is a power of 2, there is likely
// wasted space in it. This number will be used for things such as clearing
// the image if necessary.
int ImageInUseSize[2];
// This is the location in ImageFullSize image where our ImageSize image
// is located.
int ImageOrigin[2];
// This is the allocated image
unsigned short *Image;
private:
vtkFixedPointRayCastImage(const vtkFixedPointRayCastImage&); // Not implemented.
void operator=(const vtkFixedPointRayCastImage&); // Not implemented.
};
#endif
......@@ -24,10 +24,11 @@
#include "vtkRenderWindow.h"
#include "vtkVolume.h"
#include "vtkVolumeProperty.h"
#include "vtkFixedPointRayCastImage.h"
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOHelper, "1.3");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOHelper, "1.4");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeGOHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeGOHelper with default values
......
......@@ -24,10 +24,11 @@
#include "vtkRenderWindow.h"
#include "vtkVolume.h"
#include "vtkVolumeProperty.h"
#include "vtkFixedPointRayCastImage.h"
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOShadeHelper, "1.3");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOShadeHelper, "1.4");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeGOShadeHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeGOShadeHelper with default values
......
......@@ -24,10 +24,11 @@
#include "vtkRenderWindow.h"
#include "vtkVolume.h"
#include "vtkVolumeProperty.h"
#include "vtkFixedPointRayCastImage.h"
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeHelper, "1.3");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeHelper, "1.4");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeHelper with default values
......
......@@ -24,10 +24,11 @@
#include "vtkRenderWindow.h"
#include "vtkVolume.h"
#include "vtkVolumeProperty.h"
#include "vtkFixedPointRayCastImage.h"
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeShadeHelper, "1.3");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeShadeHelper, "1.4");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeShadeHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeShadeHelper with default values
......
......@@ -747,16 +747,16 @@
float shift[4]; \
float scale[4]; \
\
mapper->GetImageInUseSize(imageInUseSize); \
mapper->GetImageMemorySize(imageMemorySize); \
mapper->GetImageViewportSize(imageViewportSize); \
mapper->GetImageOrigin(imageOrigin); \
mapper->GetRayCastImage()->GetImageInUseSize(imageInUseSize); \
mapper->GetRayCastImage()->GetImageMemorySize(imageMemorySize); \
mapper->GetRayCastImage()->GetImageViewportSize(imageViewportSize); \
mapper->GetRayCastImage()->GetImageOrigin(imageOrigin); \
mapper->GetInput()->GetDimensions(dim); \
mapper->GetTableShift( shift ); \
mapper->GetTableScale( scale ); \
\
int *rowBounds = mapper->GetRowBounds(); \
unsigned short *image = mapper->GetImage(); \
unsigned short *image = mapper->GetRayCastImage()->GetImage(); \
vtkRenderWindow *renWin = mapper->GetRenderWindow(); \
int components = mapper->GetInput()->GetNumberOfScalarComponents(); \
int cropping = (mapper->GetCropping() && \
......
......@@ -21,10 +21,11 @@
#include "vtkRenderWindow.h"
#include "vtkVolume.h"
#include "vtkVolumeProperty.h"
#include "vtkFixedPointRayCastImage.h"
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastMIPHelper, "1.4");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastMIPHelper, "1.5");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastMIPHelper);
// Construct a new vtkFixedPointVolumeRayCastMIPHelper with default values
......
......@@ -79,6 +79,7 @@ class vtkDirectionEncoder;
class vtkEncodedGradientShader;
class vtkFiniteDifferenceGradientEstimator;
class vtkRayCastImageDisplayHelper;
class vtkFixedPointRayCastImage;
// Forward declaration needed for use by friend declaration below.
VTK_THREAD_RETURN_TYPE FixedPointVolumeRayCastMapper_CastRays( void *arg );
......@@ -191,10 +192,6 @@ public:
//ETX
vtkGetVectorMacro( ImageInUseSize, int, 2 );
vtkGetVectorMacro( ImageMemorySize, int, 2 );
vtkGetVectorMacro( ImageViewportSize, int, 2 );
vtkGetVectorMacro( ImageOrigin, int, 2 );
vtkGetObjectMacro( RenderWindow, vtkRenderWindow );
vtkGetObjectMacro( MIPHelper, vtkFixedPointVolumeRayCastMIPHelper );
vtkGetObjectMacro( CompositeHelper, vtkFixedPointVolumeRayCastCompositeHelper );
......@@ -207,7 +204,6 @@ public:
vtkGetMacro( GradientOpacityRequired, int );
int *GetRowBounds() {return this->RowBounds;}
unsigned short *GetImage() {return this->Image;}
unsigned short *GetColorTable(int c) {return this->ColorTable[c];}
unsigned short *GetScalarOpacityTable(int c) {return this->ScalarOpacityTable[c];}
unsigned short *GetGradientOpacityTable(int c) {return this->GradientOpacityTable[c];}
......@@ -226,6 +222,14 @@ public:
int ShouldUseNearestNeighborInterpolation( vtkVolume *vol );
// Description:
// Set / Get the underlying image object. One will be automatically
// created - only need to set it when using from an AMR mapper which
// renders multiple times into the same image.
void SetRayCastImage( vtkFixedPointRayCastImage * );
vtkGetObjectMacro( RayCastImage, vtkFixedPointRayCastImage );
protected:
vtkFixedPointVolumeRayCastMapper();
~vtkFixedPointVolumeRayCastMapper();
......@@ -266,28 +270,9 @@ protected:
vtkTransform *PerspectiveTransform;
vtkTransform *VoxelsTransform;
vtkTransform *VoxelsToViewTransform;
// This is how big the image would be if it covered the entire viewport
int ImageViewportSize[2];
// This is how big the allocated memory for image is. This may be bigger
// or smaller than ImageFullSize - it will be bigger if necessary to
// ensure a power of 2, it will be smaller if the volume only covers a
// small region of the viewport
int ImageMemorySize[2];
// This is the size of subregion in ImageSize image that we are using for
// the current image. Since ImageSize is a power of 2, there is likely
// wasted space in it. This number will be used for things such as clearing
// the image if necessary.
int ImageInUseSize[2];
// This is the location in ImageFullSize image where our ImageSize image
// is located.
int ImageOrigin[2];
// This is the allocated image
unsigned short *Image;
// This object encapsulated the image and all related information
vtkFixedPointRayCastImage *RayCastImage;
int *RowBounds;
int *OldRowBounds;
......
......@@ -28,6 +28,7 @@
class vtkVolume;
class vtkRenderer;
class vtkFixedPointRayCastImage;
class VTK_VOLUMERENDERING_EXPORT vtkMesaRayCastImageDisplayHelper : public vtkRayCastImageDisplayHelper
{
......@@ -52,6 +53,10 @@ public:
float requestedDepth,
unsigned short *image );
void RenderTexture( vtkVolume *vol, vtkRenderer *ren,
vtkFixedPointRayCastImage *image,
float requestedDepth );
protected:
vtkMesaRayCastImageDisplayHelper();
~vtkMesaRayCastImageDisplayHelper();
......
......@@ -20,6 +20,7 @@
#include "vtkRenderer.h"
#include "vtkTransform.h"
#include "vtkCamera.h"
#include "vtkFixedPointRayCastImage.h"
#ifndef VTK_IMPLEMENT_MESA_CXX
# include "vtkOpenGL.h"
......@@ -28,7 +29,7 @@
#include <math.h>
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLRayCastImageDisplayHelper, "1.3");
vtkCxxRevisionMacro(vtkOpenGLRayCastImageDisplayHelper, "1.4");
vtkStandardNewMacro(vtkOpenGLRayCastImageDisplayHelper);
#endif
......@@ -52,6 +53,16 @@ vtkOpenGLRayCastImageDisplayHelper::~vtkOpenGLRayCastImageDisplayHelper()
// imageOrigin is the starting pixel of the imageInUseSize image on the
// the imageViewportSize viewport
//
void vtkOpenGLRayCastImageDisplayHelper::RenderTexture( vtkVolume *vol,
vtkRenderer *ren,
vtkFixedPointRayCastImage *image,
float requestedDepth )
{
this->RenderTextureInternal( vol, ren, image->GetImageMemorySize(), image->GetImageViewportSize(),
image->GetImageInUseSize(), image->GetImageOrigin(),
requestedDepth, VTK_UNSIGNED_SHORT, image->GetImage() );
}
void vtkOpenGLRayCastImageDisplayHelper::RenderTexture( vtkVolume *vol,
vtkRenderer *ren,
int imageMemorySize[2],
......
......@@ -28,6 +28,7 @@
class vtkVolume;
class vtkRenderer;
class vtkFixedPointRayCastImage;
class VTK_VOLUMERENDERING_EXPORT vtkOpenGLRayCastImageDisplayHelper : public vtkRayCastImageDisplayHelper
{
......@@ -52,6 +53,10 @@ public:
float requestedDepth,
unsigned short *image );
void RenderTexture( vtkVolume *vol, vtkRenderer *ren,
vtkFixedPointRayCastImage *image,
float requestedDepth );
protected:
vtkOpenGLRayCastImageDisplayHelper();
~vtkOpenGLRayCastImageDisplayHelper();
......
......@@ -29,6 +29,7 @@
class vtkVolume;
class vtkRenderer;
class vtkFixedPointRayCastImage;
class VTK_VOLUMERENDERING_EXPORT vtkRayCastImageDisplayHelper : public vtkObject
{
......@@ -52,7 +53,11 @@ public:
int imageOrigin[2],
float requestedDepth,
unsigned short *image ) = 0;
virtual void RenderTexture( vtkVolume *vol, vtkRenderer *ren,
vtkFixedPointRayCastImage *image,
float requestedDepth ) = 0;
vtkSetClampMacro( PreMultipliedColors, int, 0, 1 );
vtkGetMacro( PreMultipliedColors, int );
vtkBooleanMacro( PreMultipliedColors, int );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment