65 #ifndef vtkFixedPointVolumeRayCastMapper_h
66 #define vtkFixedPointVolumeRayCastMapper_h
68 #include "vtkRenderingVolumeModule.h"
69 #include "vtkThreads.h"
72 #define VTKKW_FP_SHIFT 15
73 #define VTKKW_FPMM_SHIFT 17
74 #define VTKKW_FP_MASK 0x7fff
75 #define VTKKW_FP_SCALE 32767.0
117 vtkSetMacro(SampleDistance,
float);
118 vtkGetMacro(SampleDistance,
float);
129 vtkSetMacro(InteractiveSampleDistance,
float);
130 vtkGetMacro(InteractiveSampleDistance,
float);
141 vtkSetClampMacro(ImageSampleDistance,
float, 0.1f, 100.0f);
142 vtkGetMacro(ImageSampleDistance,
float);
150 vtkSetClampMacro(MinimumImageSampleDistance,
float, 0.1f, 100.0f);
151 vtkGetMacro(MinimumImageSampleDistance,
float);
159 vtkSetClampMacro(MaximumImageSampleDistance,
float, 0.1f, 100.0f);
160 vtkGetMacro(MaximumImageSampleDistance,
float);
173 vtkSetClampMacro(AutoAdjustSampleDistances,
vtkTypeBool, 0, 1);
174 vtkGetMacro(AutoAdjustSampleDistances,
vtkTypeBool);
175 vtkBooleanMacro(AutoAdjustSampleDistances,
vtkTypeBool);
187 vtkSetClampMacro(LockSampleDistanceToInputSpacing,
vtkTypeBool, 0, 1);
188 vtkGetMacro(LockSampleDistanceToInputSpacing,
vtkTypeBool);
189 vtkBooleanMacro(LockSampleDistanceToInputSpacing,
vtkTypeBool);
198 void SetNumberOfThreads(
int num);
199 int GetNumberOfThreads();
207 vtkSetClampMacro(IntermixIntersectingGeometry,
vtkTypeBool, 0, 1);
208 vtkGetMacro(IntermixIntersectingGeometry,
vtkTypeBool);
209 vtkBooleanMacro(IntermixIntersectingGeometry,
vtkTypeBool);
220 float ComputeRequiredImageSampleDistance(
float desiredTime,
vtkRenderer* ren);
230 unsigned int ToFixedPointPosition(
float val);
231 void ToFixedPointPosition(
float in[3],
unsigned int out[3]);
232 unsigned int ToFixedPointDirection(
float dir);
233 void ToFixedPointDirection(
float in[3],
unsigned int out[3]);
234 void FixedPointIncrement(
unsigned int position[3],
unsigned int increment[3]);
235 void GetFloatTripleFromPointer(
float v[3],
float* ptr);
236 void GetUIntTripleFromPointer(
unsigned int v[3],
unsigned int* ptr);
237 void ShiftVectorDown(
unsigned int in[3],
unsigned int out[3]);
238 int CheckMinMaxVolumeFlag(
unsigned int pos[3],
int c);
239 int CheckMIPMinMaxVolumeFlag(
unsigned int pos[3],
int c,
unsigned short maxIdx,
int flip);
241 void LookupColorUC(
unsigned short* colorTable,
unsigned short* scalarOpacityTable,
242 unsigned short index,
unsigned char color[4]);
243 void LookupDependentColorUC(
unsigned short* colorTable,
unsigned short* scalarOpacityTable,
244 unsigned short index[4],
int components,
unsigned char color[4]);
245 void LookupAndCombineIndependentColorsUC(
unsigned short* colorTable[4],
246 unsigned short* scalarOpacityTable[4],
unsigned short index[4],
float weights[4],
247 int components,
unsigned char color[4]);
248 int CheckIfCropped(
unsigned int pos[3]);
256 vtkGetVectorMacro(TableShift,
float, 4);
257 vtkGetVectorMacro(TableScale,
float, 4);
258 vtkGetMacro(ShadingRequired,
int);
259 vtkGetMacro(GradientOpacityRequired,
int);
275 int x,
int y,
unsigned int pos[3],
unsigned int dir[3],
unsigned int* numSteps);
279 int ShouldUseNearestNeighborInterpolation(
vtkVolume* vol);
294 void RenderSubVolume();
299 double viewDirection[3],
double viewUp[3]);
309 return this->RetrieveRenderTime(ren, vol);
327 vtkSetMacro(FinalColorWindow,
float);
328 vtkGetMacro(FinalColorWindow,
float);
329 vtkSetMacro(FinalColorLevel,
float);
330 vtkGetMacro(FinalColorLevel,
float);
336 vtkGetMacro(FlipMIPComparison,
int);
370 void ComputeMatrices(
double inputOrigin[3],
double inputSpacing[3],
int inputExtent[6],
373 int ComputeRowBounds(
vtkRenderer* ren,
int imageFlag,
int rowBoundsFlag,
int inputExtent[6]);
419 int SavedColorChannels[4];
420 float SavedScalarOpacityDistance[4];
430 unsigned short ColorTable[4][32768 * 3];
431 unsigned short ScalarOpacityTable[4][32768];
432 unsigned short GradientOpacityTable[4][256];
437 float GradientMagnitudeScale[4];
438 float GradientMagnitudeShift[4];
453 unsigned short DiffuseShadingTable[4][65536 * 3];
454 unsigned short SpecularShadingTable[4][65536 * 3];
465 int ClipRayAgainstVolume(
466 double rayStart[3],
double rayEnd[3],
float rayDirection[3],
double bounds[6]);
471 void UpdateCroppingRegions();
475 int ClipRayAgainstClippingPlanes(
476 double rayStart[3],
double rayEnd[3],
int numClippingPlanes,
float* clippingPlanes);
478 unsigned int FixedPointCroppingRegionPlanes[6];
479 unsigned int CroppingRegionMask[27];
484 float GetZBufferValue(
int x,
int y);
493 float ViewToVoxelsArray[16];
494 float WorldToVoxelsArray[16];
495 float VoxelsToWorldArray[16];
497 double CroppingBounds[6];
502 double SavedSpacing[3];
506 int MinMaxVolumeSize[4];
512 void FillInMaxGradientMagnitudes(
int fullDim[3],
int smallDim[3]);
519 void ApplyFinalColorWindowLevel();
542 return ((dir < 0.0) ? (static_cast<unsigned int>(-dir *
VTKKW_FP_SCALE + 0.5))
543 : (0x80000000 + static_cast<unsigned int>(dir *
VTKKW_FP_SCALE + 0.5)));
547 float in[3],
unsigned int out[3])
549 out[0] = ((in[0] < 0.0) ? (
static_cast<unsigned int>(-in[0] *
VTKKW_FP_SCALE + 0.5))
550 : (0x80000000 + static_cast<unsigned int>(in[0] *
VTKKW_FP_SCALE + 0.5)));
551 out[1] = ((in[1] < 0.0) ? (
static_cast<unsigned int>(-in[1] *
VTKKW_FP_SCALE + 0.5))
552 : (0x80000000 + static_cast<unsigned int>(in[1] *
VTKKW_FP_SCALE + 0.5)));
553 out[2] = ((in[2] < 0.0) ? (
static_cast<unsigned int>(-in[2] *
VTKKW_FP_SCALE + 0.5))
554 : (0x80000000 + static_cast<unsigned int>(in[2] *
VTKKW_FP_SCALE + 0.5)));
558 unsigned int position[3],
unsigned int increment[3])
560 if (increment[0] & 0x80000000)
562 position[0] += (increment[0] & 0x7fffffff);
566 position[0] -= increment[0];
568 if (increment[1] & 0x80000000)
570 position[1] += (increment[1] & 0x7fffffff);
574 position[1] -= increment[1];
576 if (increment[2] & 0x80000000)
578 position[2] += (increment[2] & 0x7fffffff);
582 position[2] -= increment[2];
594 unsigned int v[3],
unsigned int* ptr)
602 unsigned int in[3],
unsigned int out[3])
613 mmpos[1] *
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) + mmpos[0]) +
616 return ((*(this->
MinMaxVolume + 3 * offset + 2)) & 0x00ff);
620 unsigned int mmpos[3],
int c,
unsigned short maxIdx,
int flip)
624 mmpos[1] *
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) + mmpos[0]) +
635 return (*(this->
MinMaxVolume + 3 * offset + 1) > maxIdx);
645 unsigned short* scalarOpacityTable,
unsigned short index,
unsigned char color[4])
647 unsigned short alpha = scalarOpacityTable[
index];
648 color[0] =
static_cast<unsigned char>(
650 color[1] =
static_cast<unsigned char>(
651 (colorTable[3 * index + 1] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
652 color[2] =
static_cast<unsigned char>(
653 (colorTable[3 * index + 2] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
654 color[3] =
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
658 unsigned short* scalarOpacityTable,
unsigned short index[4],
int components,
659 unsigned char color[4])
661 unsigned short alpha;
665 alpha = scalarOpacityTable[index[1]];
666 color[0] =
static_cast<unsigned char>(
667 (colorTable[3 * index[0]] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
668 color[1] =
static_cast<unsigned char>(
669 (colorTable[3 * index[0] + 1] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
670 color[2] =
static_cast<unsigned char>(
671 (colorTable[3 * index[0] + 2] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
672 color[3] =
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
675 alpha = scalarOpacityTable[index[3]];
676 color[0] =
static_cast<unsigned char>((index[0] * alpha + 0x7fff) >>
VTKKW_FP_SHIFT);
677 color[1] =
static_cast<unsigned char>((index[1] * alpha + 0x7fff) >>
VTKKW_FP_SHIFT);
678 color[2] =
static_cast<unsigned char>((index[2] * alpha + 0x7fff) >>
VTKKW_FP_SHIFT);
679 color[3] =
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
685 unsigned short* colorTable[4],
unsigned short* scalarOpacityTable[4],
unsigned short index[4],
686 float weights[4],
int components,
unsigned char color[4])
688 unsigned int tmp[4] = { 0, 0, 0, 0 };
690 for (
int i = 0; i < components; i++)
692 unsigned short alpha =
693 static_cast<unsigned short>(
static_cast<float>(scalarOpacityTable[i][index[i]]) * weights[i]);
694 tmp[0] +=
static_cast<unsigned char>(
695 ((colorTable[i][3 * index[i]]) * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
696 tmp[1] +=
static_cast<unsigned char>(
697 ((colorTable[i][3 * index[i] + 1]) * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
698 tmp[2] +=
static_cast<unsigned char>(
699 ((colorTable[i][3 * index[i] + 2]) * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
700 tmp[3] +=
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
703 color[0] =
static_cast<unsigned char>((tmp[0] > 255) ? (255) : (tmp[0]));
704 color[1] =
static_cast<unsigned char>((tmp[1] > 255) ? (255) : (tmp[1]));
705 color[2] =
static_cast<unsigned char>((tmp[2] > 255) ? (255) : (tmp[2]));
706 color[3] =
static_cast<unsigned char>((tmp[3] > 255) ? (255) : (tmp[3]));
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.
unsigned int CroppingRegionMask[27]
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
unsigned int FixedPointCroppingRegionPlanes[6]
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