62 #ifndef vtkFixedPointVolumeRayCastMapper_h 63 #define vtkFixedPointVolumeRayCastMapper_h 65 #include "vtkRenderingVolumeModule.h" 68 #define VTKKW_FP_SHIFT 15 69 #define VTKKW_FPMM_SHIFT 17 70 #define VTKKW_FP_MASK 0x7fff 71 #define VTKKW_FP_SCALE 32767.0 113 vtkSetMacro( SampleDistance,
float );
114 vtkGetMacro( SampleDistance,
float );
125 vtkSetMacro( InteractiveSampleDistance,
float );
126 vtkGetMacro( InteractiveSampleDistance,
float );
137 vtkSetClampMacro( ImageSampleDistance,
float, 0.1f, 100.0f );
138 vtkGetMacro( ImageSampleDistance,
float );
146 vtkSetClampMacro( MinimumImageSampleDistance,
float, 0.1f, 100.0f );
147 vtkGetMacro( MinimumImageSampleDistance,
float );
155 vtkSetClampMacro( MaximumImageSampleDistance,
float, 0.1f, 100.0f );
156 vtkGetMacro( MaximumImageSampleDistance,
float );
169 vtkSetClampMacro( AutoAdjustSampleDistances,
vtkTypeBool, 0, 1 );
170 vtkGetMacro( AutoAdjustSampleDistances,
vtkTypeBool );
171 vtkBooleanMacro( AutoAdjustSampleDistances,
vtkTypeBool );
183 vtkSetClampMacro( LockSampleDistanceToInputSpacing,
vtkTypeBool, 0, 1 );
184 vtkGetMacro( LockSampleDistanceToInputSpacing,
vtkTypeBool );
185 vtkBooleanMacro( LockSampleDistanceToInputSpacing,
vtkTypeBool );
194 void SetNumberOfThreads(
int num );
195 int GetNumberOfThreads();
203 vtkSetClampMacro( IntermixIntersectingGeometry,
vtkTypeBool, 0, 1 );
204 vtkGetMacro( IntermixIntersectingGeometry,
vtkTypeBool );
205 vtkBooleanMacro( IntermixIntersectingGeometry,
vtkTypeBool );
216 float ComputeRequiredImageSampleDistance(
float desiredTime,
218 float ComputeRequiredImageSampleDistance(
float desiredTime,
229 unsigned int ToFixedPointPosition(
float val );
230 void ToFixedPointPosition(
float in[3],
unsigned int out[3] );
231 unsigned int ToFixedPointDirection(
float dir );
232 void ToFixedPointDirection(
float in[3],
unsigned int out[3] );
233 void FixedPointIncrement(
unsigned int position[3],
unsigned int increment[3] );
234 void GetFloatTripleFromPointer(
float v[3],
float *ptr );
235 void GetUIntTripleFromPointer(
unsigned int v[3],
unsigned int *ptr );
236 void ShiftVectorDown(
unsigned int in[3],
unsigned int out[3] );
237 int CheckMinMaxVolumeFlag(
unsigned int pos[3],
int c );
238 int CheckMIPMinMaxVolumeFlag(
unsigned int pos[3],
int c,
unsigned short maxIdx,
int flip );
240 void LookupColorUC(
unsigned short *colorTable,
241 unsigned short *scalarOpacityTable,
242 unsigned short index,
243 unsigned char color[4] );
244 void LookupDependentColorUC(
unsigned short *colorTable,
245 unsigned short *scalarOpacityTable,
246 unsigned short index[4],
248 unsigned char color[4] );
249 void LookupAndCombineIndependentColorsUC(
250 unsigned short *colorTable[4],
251 unsigned short *scalarOpacityTable[4],
252 unsigned short index[4],
255 unsigned char color[4] );
256 int CheckIfCropped(
unsigned int pos[3] );
264 vtkGetVectorMacro( TableShift,
float, 4 );
265 vtkGetVectorMacro( TableScale,
float, 4 );
266 vtkGetMacro( ShadingRequired,
int );
267 vtkGetMacro( GradientOpacityRequired,
int );
283 void ComputeRayInfo(
int x,
int y,
286 unsigned int *numSteps );
288 void InitializeRayInfo(
vtkVolume *vol );
290 int ShouldUseNearestNeighborInterpolation(
vtkVolume *vol );
303 double *,
double *,
int * );
306 void RenderSubVolume();
310 void CreateCanonicalView(
vtkVolume *volume,
313 double viewDirection[3],
324 {
return this->RetrieveRenderTime( ren, vol ); }
326 {
return this->RetrieveRenderTime( ren ); }
343 vtkSetMacro( FinalColorWindow,
float );
344 vtkGetMacro( FinalColorWindow,
float );
345 vtkSetMacro( FinalColorLevel,
float );
346 vtkGetMacro( FinalColorLevel,
float );
353 vtkGetMacro( FlipMIPComparison,
int );
387 void ComputeMatrices(
double volumeOrigin[3],
388 double volumeSpacing[3],
394 int imageFlag,
int rowBoundsFlag,
395 int volumeExtent[6]);
441 int SavedColorChannels[4];
442 float SavedScalarOpacityDistance[4];
453 unsigned short ColorTable[4][32768*3];
454 unsigned short ScalarOpacityTable[4][32768];
455 unsigned short GradientOpacityTable[4][256];
460 float GradientMagnitudeScale[4];
461 float GradientMagnitudeShift[4];
476 unsigned short DiffuseShadingTable [4][65536*3];
477 unsigned short SpecularShadingTable[4][65536*3];
488 int ClipRayAgainstVolume(
float rayStart[3],
490 float rayDirection[3],
497 void UpdateCroppingRegions();
501 int ClipRayAgainstClippingPlanes(
float rayStart[3],
503 int numClippingPlanes,
504 float *clippingPlanes );
506 unsigned int FixedPointCroppingRegionPlanes[6];
507 unsigned int CroppingRegionMask[27];
512 float GetZBufferValue(
int x,
int y );
521 float ViewToVoxelsArray[16];
522 float WorldToVoxelsArray[16];
523 float VoxelsToWorldArray[16];
525 double CroppingBounds[6];
530 double SavedSpacing[3];
535 int MinMaxVolumeSize[4];
540 void UpdateMinMaxVolume(
vtkVolume *vol );
541 void FillInMaxGradientMagnitudes(
int fullDim[3],
549 void ApplyFinalColorWindowLevel();
575 (0x80000000+static_cast<unsigned int>(dir*
VTKKW_FP_SCALE + 0.5)));
580 out[0] = ((in[0]<0.0)?
584 out[1] = ((in[1]<0.0)?
588 out[2] = ((in[2]<0.0)?
596 if ( increment[0]&0x80000000 )
598 position[0] += (increment[0]&0x7fffffff);
602 position[0] -= increment[0];
604 if ( increment[1]&0x80000000 )
606 position[1] += (increment[1]&0x7fffffff);
610 position[1] -= increment[1];
612 if ( increment[2]&0x80000000 )
614 position[2] += (increment[2]&0x7fffffff);
618 position[2] -= increment[2];
638 unsigned int out[3] )
648 static_cast<vtkIdType>(this->MinMaxVolumeSize[3]) *
649 ( mmpos[2]*static_cast<vtkIdType>(
650 this->MinMaxVolumeSize[0]*this->MinMaxVolumeSize[1]) +
651 mmpos[1]*
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) +
654 return ((*(this->MinMaxVolume + 3*offset + 2))&0x00ff);
658 unsigned short maxIdx,
int flip )
661 static_cast<vtkIdType>(this->MinMaxVolumeSize[3]) *
662 ( mmpos[2]*static_cast<vtkIdType>(
663 this->MinMaxVolumeSize[0]*this->MinMaxVolumeSize[1]) +
664 mmpos[1]*
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) +
667 if ( (*(this->MinMaxVolume + 3*offset + 2)&0x00ff) )
671 return ( *(this->MinMaxVolume + 3*offset) < maxIdx );
675 return ( *(this->MinMaxVolume + 3*offset + 1) > maxIdx );
685 unsigned short *scalarOpacityTable,
686 unsigned short index,
687 unsigned char color[4] )
689 unsigned short alpha = scalarOpacityTable[
index];
690 color[0] =
static_cast<unsigned char> 692 color[1] =
static_cast<unsigned char> 694 color[2] =
static_cast<unsigned char> 696 color[3] =
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
700 unsigned short *scalarOpacityTable,
701 unsigned short index[4],
703 unsigned char color[4] )
705 unsigned short alpha;
706 switch ( components )
709 alpha = scalarOpacityTable[index[1]];
710 color[0] =
static_cast<unsigned char> 711 ((colorTable[3*index[0] ]*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
712 color[1] =
static_cast<unsigned char> 713 ((colorTable[3*index[0]+1]*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
714 color[2] =
static_cast<unsigned char> 715 ((colorTable[3*index[0]+2]*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
716 color[3] =
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
719 alpha = scalarOpacityTable[index[3]];
720 color[0] =
static_cast<unsigned char>((index[0]*alpha + 0x7fff)>>
VTKKW_FP_SHIFT );
721 color[1] =
static_cast<unsigned char>((index[1]*alpha + 0x7fff)>>
VTKKW_FP_SHIFT );
722 color[2] =
static_cast<unsigned char>((index[2]*alpha + 0x7fff)>>
VTKKW_FP_SHIFT );
723 color[3] =
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
730 unsigned short *scalarOpacityTable[4],
731 unsigned short index[4],
734 unsigned char color[4] )
736 unsigned int tmp[4] = {0,0,0,0};
738 for (
int i = 0; i < components; i++ )
740 unsigned short alpha =
static_cast<unsigned short>(
static_cast<float>(scalarOpacityTable[i][index[i]])*weights[i]);
741 tmp[0] +=
static_cast<unsigned char>(((colorTable[i][3*index[i] ])*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
742 tmp[1] +=
static_cast<unsigned char>(((colorTable[i][3*index[i]+1])*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
743 tmp[2] +=
static_cast<unsigned char>(((colorTable[i][3*index[i]+2])*alpha + 0x7fff)>>(2*
VTKKW_FP_SHIFT - 8));
744 tmp[3] +=
static_cast<unsigned char>(alpha>>(
VTKKW_FP_SHIFT - 8));
747 color[0] =
static_cast<unsigned char>((tmp[0]>255)?(255):(tmp[0]));
748 color[1] =
static_cast<unsigned char>((tmp[1]>255)?(255):(tmp[1]));
749 color[2] =
static_cast<unsigned char>((tmp[2]>255)?(255):(tmp[2]));
750 color[3] =
static_cast<unsigned char>((tmp[3]>255)?(255):(tmp[3]));
758 if ( pos[2] < this->FixedPointCroppingRegionPlanes[4] )
762 else if ( pos[2] > this->FixedPointCroppingRegionPlanes[5] )
771 if ( pos[1] >= this->FixedPointCroppingRegionPlanes[2] )
773 if ( pos[1] > this->FixedPointCroppingRegionPlanes[3] )
783 if ( pos[0] >= this->FixedPointCroppingRegionPlanes[0] )
785 if ( pos[0] > this->FixedPointCroppingRegionPlanes[1] )
796 &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.
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
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
void Render(vtkRenderer *ren, vtkVolume *vol) override=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
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
vtkTypeBool IntermixIntersectingGeometry
int CheckIfCropped(unsigned int pos[3])
vtkTypeBool LockSampleDistanceToInputSpacing
vtkFixedPointVolumeRayCastCompositeGOHelper * CompositeGOHelper
vtkTransform * VoxelsToViewTransform
vtkFixedPointRayCastImage * RayCastImage
unsigned short * GetColorTable(int c)
vtkMatrix4x4 * VolumeMatrix
vtkDataArray * PreviousScalars
a simple class to control print indentation
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
int CheckMIPMinMaxVolumeFlag(unsigned int pos[3], int c, unsigned short maxIdx, int flip)
float * TransformedClippingPlanes
A helper that generates composite images for the volume ray cast mapper.
vtkImageData * SavedParametersInput
vtkTransform * PerspectiveTransform
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
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)
unsigned short * GetGradientOpacityTable(int c)
vtkFixedPointVolumeRayCastCompositeGOShadeHelper * CompositeGOShadeHelper
float GetEstimatedRenderTime(vtkRenderer *ren)
int NumberOfGradientSlices
static vtkAlgorithm * New()
vtkRayCastImageDisplayHelper * ImageDisplayHelper
int NumTransformedClippingPlanes
vtkFiniteDifferenceGradientEstimator * GradientEstimator
unsigned int ToFixedPointPosition(float val)
vtkImageData * MinMaxVolumeCache
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMatrix4x4 * VoxelsToViewMatrix
float OldImageSampleDistance
void GetFloatTripleFromPointer(float v[3], float *ptr)
vtkTypeBool AutoAdjustSampleDistances
helper class for a ray cast image