67 #ifndef vtkFixedPointVolumeRayCastMapper_h
68 #define vtkFixedPointVolumeRayCastMapper_h
70 #include "vtkRenderingVolumeModule.h"
73 #define VTKKW_FP_SHIFT 15
74 #define VTKKW_FPMM_SHIFT 17
75 #define VTKKW_FP_MASK 0x7fff
76 #define VTKKW_FP_SCALE 32767.0
119 vtkGetMacro( SampleDistance,
float );
131 vtkGetMacro( InteractiveSampleDistance,
float );
142 vtkSetClampMacro( ImageSampleDistance,
float, 0.1f, 100.0f );
143 vtkGetMacro( ImageSampleDistance,
float );
151 vtkSetClampMacro( MinimumImageSampleDistance,
float, 0.1f, 100.0f );
152 vtkGetMacro( MinimumImageSampleDistance,
float );
160 vtkSetClampMacro( MaximumImageSampleDistance,
float, 0.1f, 100.0f );
161 vtkGetMacro( MaximumImageSampleDistance,
float );
174 vtkSetClampMacro( AutoAdjustSampleDistances,
int, 0, 1 );
175 vtkGetMacro( AutoAdjustSampleDistances,
int );
188 vtkSetClampMacro( LockSampleDistanceToInputSpacing,
int, 0, 1 );
189 vtkGetMacro( LockSampleDistanceToInputSpacing,
int );
199 void SetNumberOfThreads(
int num );
200 int GetNumberOfThreads();
208 vtkSetClampMacro( IntermixIntersectingGeometry,
int, 0, 1 );
209 vtkGetMacro( IntermixIntersectingGeometry,
int );
221 float ComputeRequiredImageSampleDistance(
float desiredTime,
223 float ComputeRequiredImageSampleDistance(
float desiredTime,
234 unsigned int ToFixedPointPosition(
float val );
235 void ToFixedPointPosition(
float in[3],
unsigned int out[3] );
236 unsigned int ToFixedPointDirection(
float dir );
237 void ToFixedPointDirection(
float in[3],
unsigned int out[3] );
238 void FixedPointIncrement(
unsigned int position[3],
unsigned int increment[3] );
239 void GetFloatTripleFromPointer(
float v[3],
float *ptr );
240 void GetUIntTripleFromPointer(
unsigned int v[3],
unsigned int *ptr );
241 void ShiftVectorDown(
unsigned int in[3],
unsigned int out[3] );
242 int CheckMinMaxVolumeFlag(
unsigned int pos[3],
int c );
243 int CheckMIPMinMaxVolumeFlag(
unsigned int pos[3],
int c,
unsigned short maxIdx,
int flip );
245 void LookupColorUC(
unsigned short *colorTable,
246 unsigned short *scalarOpacityTable,
247 unsigned short index,
248 unsigned char color[4] );
249 void LookupDependentColorUC(
unsigned short *colorTable,
250 unsigned short *scalarOpacityTable,
251 unsigned short index[4],
253 unsigned char color[4] );
254 void LookupAndCombineIndependentColorsUC(
255 unsigned short *colorTable[4],
256 unsigned short *scalarOpacityTable[4],
257 unsigned short index[4],
260 unsigned char color[4] );
261 int CheckIfCropped(
unsigned int pos[3] );
269 vtkGetVectorMacro( TableShift,
float, 4 );
270 vtkGetVectorMacro( TableScale,
float, 4 );
271 vtkGetMacro( ShadingRequired,
int );
272 vtkGetMacro( GradientOpacityRequired,
int );
288 void ComputeRayInfo(
int x,
int y,
291 unsigned int *numSteps );
293 void InitializeRayInfo(
vtkVolume *vol );
295 int ShouldUseNearestNeighborInterpolation(
vtkVolume *vol );
308 double *,
double *,
int * );
311 void RenderSubVolume();
315 void CreateCanonicalView(
vtkVolume *volume,
318 double viewDirection[3],
329 {
return this->RetrieveRenderTime( ren, vol ); }
331 {
return this->RetrieveRenderTime( ren ); }
349 vtkGetMacro( FinalColorWindow,
float );
351 vtkGetMacro( FinalColorLevel,
float );
358 vtkGetMacro( FlipMIPComparison,
int );
392 void ComputeMatrices(
double volumeOrigin[3],
393 double volumeSpacing[3],
399 int imageFlag,
int rowBoundsFlag,
400 int volumeExtent[6]);
446 int SavedColorChannels[4];
447 float SavedScalarOpacityDistance[4];
458 unsigned short ColorTable[4][32768*3];
459 unsigned short ScalarOpacityTable[4][32768];
460 unsigned short GradientOpacityTable[4][256];
465 float GradientMagnitudeScale[4];
466 float GradientMagnitudeShift[4];
481 unsigned short DiffuseShadingTable [4][65536*3];
482 unsigned short SpecularShadingTable[4][65536*3];
493 int ClipRayAgainstVolume(
float rayStart[3],
495 float rayDirection[3],
502 void UpdateCroppingRegions();
506 int ClipRayAgainstClippingPlanes(
float rayStart[3],
508 int numClippingPlanes,
509 float *clippingPlanes );
511 unsigned int FixedPointCroppingRegionPlanes[6];
512 unsigned int CroppingRegionMask[27];
517 float GetZBufferValue(
int x,
int y );
526 float ViewToVoxelsArray[16];
527 float WorldToVoxelsArray[16];
528 float VoxelsToWorldArray[16];
530 double CroppingBounds[6];
535 double SavedSpacing[3];
540 int MinMaxVolumeSize[4];
545 void UpdateMinMaxVolume(
vtkVolume *vol );
546 void FillInMaxGradientMagnitudes(
int fullDim[3],
554 void ApplyFinalColorWindowLevel();
580 (0x80000000+static_cast<unsigned int>(dir*
VTKKW_FP_SCALE + 0.5)));
585 out[0] = ((in[0]<0.0)?
589 out[1] = ((in[1]<0.0)?
593 out[2] = ((in[2]<0.0)?
601 if ( increment[0]&0x80000000 )
603 position[0] += (increment[0]&0x7fffffff);
607 position[0] -= increment[0];
609 if ( increment[1]&0x80000000 )
611 position[1] += (increment[1]&0x7fffffff);
615 position[1] -= increment[1];
617 if ( increment[2]&0x80000000 )
619 position[2] += (increment[2]&0x7fffffff);
623 position[2] -= increment[2];
643 unsigned int out[3] )
653 static_cast<vtkIdType>(this->MinMaxVolumeSize[3]) *
654 ( mmpos[2]*static_cast<vtkIdType>(
655 this->MinMaxVolumeSize[0]*this->MinMaxVolumeSize[1]) +
656 mmpos[1]*
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) +
659 return ((*(this->MinMaxVolume + 3*offset + 2))&0x00ff);
663 unsigned short maxIdx,
int flip )
666 static_cast<vtkIdType>(this->MinMaxVolumeSize[3]) *
667 ( mmpos[2]*static_cast<vtkIdType>(
668 this->MinMaxVolumeSize[0]*this->MinMaxVolumeSize[1]) +
669 mmpos[1]*
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) +
672 if ( (*(this->MinMaxVolume + 3*offset + 2)&0x00ff) )
676 return ( *(this->MinMaxVolume + 3*offset) < maxIdx );
680 return ( *(this->MinMaxVolume + 3*offset + 1) > maxIdx );
690 unsigned short *scalarOpacityTable,
691 unsigned short index,
692 unsigned char color[4] )
694 unsigned short alpha = scalarOpacityTable[
index];
695 color[0] =
static_cast<unsigned char>
697 color[1] =
static_cast<unsigned char>
699 color[2] =
static_cast<unsigned char>
701 color[3] =
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
705 unsigned short *scalarOpacityTable,
706 unsigned short index[4],
708 unsigned char color[4] )
710 unsigned short alpha;
711 switch ( components )
714 alpha = scalarOpacityTable[index[1]];
715 color[0] =
static_cast<unsigned char>
716 ((colorTable[3*index[0] ]*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
717 color[1] =
static_cast<unsigned char>
718 ((colorTable[3*index[0]+1]*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
719 color[2] =
static_cast<unsigned char>
720 ((colorTable[3*index[0]+2]*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
721 color[3] =
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
724 alpha = scalarOpacityTable[index[3]];
725 color[0] =
static_cast<unsigned char>((index[0]*alpha + 0x7fff)>>
VTKKW_FP_SHIFT );
726 color[1] =
static_cast<unsigned char>((index[1]*alpha + 0x7fff)>>
VTKKW_FP_SHIFT );
727 color[2] =
static_cast<unsigned char>((index[2]*alpha + 0x7fff)>>
VTKKW_FP_SHIFT );
728 color[3] =
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
735 unsigned short *scalarOpacityTable[4],
736 unsigned short index[4],
739 unsigned char color[4] )
741 unsigned int tmp[4] = {0,0,0,0};
743 for (
int i = 0; i < components; i++ )
745 unsigned short alpha =
static_cast<unsigned short>(
static_cast<float>(scalarOpacityTable[i][index[i]])*weights[i]);
746 tmp[0] +=
static_cast<unsigned char>(((colorTable[i][3*index[i] ])*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
747 tmp[1] +=
static_cast<unsigned char>(((colorTable[i][3*index[i]+1])*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
748 tmp[2] +=
static_cast<unsigned char>(((colorTable[i][3*index[i]+2])*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
749 tmp[3] +=
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
752 color[0] =
static_cast<unsigned char>((tmp[0]>255)?(255):(tmp[0]));
753 color[1] =
static_cast<unsigned char>((tmp[1]>255)?(255):(tmp[1]));
754 color[2] =
static_cast<unsigned char>((tmp[2]>255)?(255):(tmp[2]));
755 color[3] =
static_cast<unsigned char>((tmp[3]>255)?(255):(tmp[3]));
763 if ( pos[2] < this->FixedPointCroppingRegionPlanes[4] )
767 else if ( pos[2] > this->FixedPointCroppingRegionPlanes[5] )
776 if ( pos[1] >= this->FixedPointCroppingRegionPlanes[2] )
778 if ( pos[1] > this->FixedPointCroppingRegionPlanes[3] )
788 if ( pos[0] >= this->FixedPointCroppingRegionPlanes[0] )
790 if ( pos[0] > this->FixedPointCroppingRegionPlanes[1] )
801 &this->CroppingRegionMask[idx]);
unsigned short * GetDiffuseShadingTable(int c)
unsigned short ** GetGradientNormal()
vtkTransform * VoxelsTransform
vtkDataArray * CurrentScalars
int CroppingRegionFlags
Cropping variables, and a method for converting the world coordinate cropping region planes to voxel ...
float MinimumImageSampleDistance
void ShiftVectorDown(unsigned int in[3], unsigned int out[3])
vtkFixedPointVolumeRayCastMIPHelper * MIPHelper
vtkTimeStamp SavedGradientsMTime
represents a volume (data & properties) in a rendered scene
vtkFixedPointVolumeRayCastCompositeShadeHelper * CompositeShadeHelper
vtkVolumeRayCastSpaceLeapingImageFilter * SpaceLeapFilter
unsigned char ** GradientMagnitude
Abstract class for a volume mapper.
vtkMatrix4x4 * VoxelsToWorldMatrix
encode a direction into a one or two byte value
represent and manipulate 4x4 transformation matrices
A helper that generates composite images for the volume ray cast mapper.
void FixedPointIncrement(unsigned int position[3], unsigned int increment[3])
Use finite differences to estimate gradient.
Defines a 1D piecewise function.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkVolume ** RenderVolumeTable
VTK_THREAD_RETURN_TYPE vtkFPVRCMSwitchOnDataType(void *arg)
A class for performing multithreaded execution.
record modification and/or execution time
maintain a list of planes
vtkMatrix4x4 * PerspectiveMatrix
unsigned char ** GetGradientMagnitude()
VTK_THREAD_RETURN_TYPE FixedPointVolumeRayCastMapper_CastRays(void *arg)
abstract specification for renderers
void GetUIntTripleFromPointer(unsigned int v[3], unsigned int *ptr)
unsigned short * MinMaxVolume
int IntermixIntersectingGeometry
unsigned short * ContiguousGradientNormal
vtkMatrix4x4 * ViewToVoxelsMatrix
unsigned short ** GradientNormal
A helper that generates MIP images for the volume ray cast mapper.
vtkDirectionEncoder * DirectionEncoder
vtkImageData * SavedGradientsInput
helper class that draws the image to the screen
float MinimumViewDistance
float InteractiveSampleDistance
float ImageSampleDistance
vtkEncodedGradientShader * GradientShader
unsigned short * GetScalarOpacityTable(int c)
vtkMatrix4x4 * ViewToWorldMatrix
Builds the space leaping data structure.
Timer support and logging.
window superclass for vtkRenderWindow
int AutoAdjustSampleDistances
int CheckIfCropped(unsigned int pos[3])
vtkFixedPointVolumeRayCastCompositeGOHelper * CompositeGOHelper
vtkTransform * VoxelsToViewTransform
vtkFixedPointRayCastImage * RayCastImage
unsigned short * GetColorTable(int c)
vtkMatrix4x4 * VolumeMatrix
vtkDataArray * PreviousScalars
a simple class to control print indentation
int LockSampleDistanceToInputSpacing
vtkImageData * SavedMinMaxInput
float GetEstimatedRenderTime(vtkRenderer *ren, vtkVolume *vol)
Get an estimate of the rendering time for a given volume / renderer.
vtkRenderer ** RenderRendererTable
topologically and geometrically regular array of data
void LookupDependentColorUC(unsigned short *colorTable, unsigned short *scalarOpacityTable, unsigned short index[4], int components, unsigned char color[4])
abstract superclass for arrays of numeric data
float SavedSampleDistance
vtkMatrix4x4 * WorldToVoxelsMatrix
Compute shading tables for encoded normals.
int GradientOpacityRequired
vtkMultiThreader * Threader
virtual void Render(vtkRenderer *ren, vtkVolume *vol)=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
int CheckMIPMinMaxVolumeFlag(unsigned int pos[3], int c, unsigned short maxIdx, int flip)
float * TransformedClippingPlanes
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkWeakPointer< vtkRenderWindow > RenderWindow
A helper that generates composite images for the volume ray cast mapper.
vtkImageData * SavedParametersInput
vtkTransform * PerspectiveTransform
unsigned int ToFixedPointDirection(float dir)
A helper that generates composite images for the volume ray cast mapper.
A fixed point mapper for volumes.
Defines a transfer function for mapping a property to an RGB color value.
create a window for renderers to draw into
vtkFixedPointVolumeRayCastCompositeHelper * CompositeHelper
A helper that generates composite images for the volume ray cast mapper.
vtkRenderWindow * RenderWindow
#define VTK_THREAD_RETURN_TYPE
unsigned char * ContiguousGradientMagnitude
float MaximumImageSampleDistance
void LookupAndCombineIndependentColorsUC(unsigned short *colorTable[4], unsigned short *scalarOpacityTable[4], unsigned short index[4], float weights[4], int components, unsigned char color[4])
int CheckMinMaxVolumeFlag(unsigned int pos[3], int c)
vtkTimeStamp SavedParametersMTime
void LookupColorUC(unsigned short *colorTable, unsigned short *scalarOpacityTable, unsigned short index, unsigned char color[4])
unsigned short * GetSpecularShadingTable(int c)
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
unsigned short * GetGradientOpacityTable(int c)
vtkFixedPointVolumeRayCastCompositeGOShadeHelper * CompositeGOShadeHelper
float GetEstimatedRenderTime(vtkRenderer *ren)
int NumberOfGradientSlices
static vtkAlgorithm * New()
vtkRayCastImageDisplayHelper * ImageDisplayHelper
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int NumTransformedClippingPlanes
vtkFiniteDifferenceGradientEstimator * GradientEstimator
unsigned int ToFixedPointPosition(float val)
vtkImageData * MinMaxVolumeCache
vtkMatrix4x4 * VoxelsToViewMatrix
float OldImageSampleDistance
void GetFloatTripleFromPointer(float v[3], float *ptr)
helper class for a ray cast image