56 #ifndef vtkFixedPointVolumeRayCastMapper_h 57 #define vtkFixedPointVolumeRayCastMapper_h 59 #include "vtkRenderingVolumeModule.h" 62 #define VTKKW_FP_SHIFT 15 63 #define VTKKW_FPMM_SHIFT 17 64 #define VTKKW_FP_MASK 0x7fff 65 #define VTKKW_FP_SCALE 32767.0 107 vtkSetMacro(SampleDistance,
float);
108 vtkGetMacro(SampleDistance,
float);
119 vtkSetMacro(InteractiveSampleDistance,
float);
120 vtkGetMacro(InteractiveSampleDistance,
float);
131 vtkSetClampMacro(ImageSampleDistance,
float, 0.1f, 100.0f);
132 vtkGetMacro(ImageSampleDistance,
float);
140 vtkSetClampMacro(MinimumImageSampleDistance,
float, 0.1f, 100.0f);
141 vtkGetMacro(MinimumImageSampleDistance,
float);
149 vtkSetClampMacro(MaximumImageSampleDistance,
float, 0.1f, 100.0f);
150 vtkGetMacro(MaximumImageSampleDistance,
float);
163 vtkSetClampMacro(AutoAdjustSampleDistances,
vtkTypeBool, 0, 1);
164 vtkGetMacro(AutoAdjustSampleDistances,
vtkTypeBool);
165 vtkBooleanMacro(AutoAdjustSampleDistances,
vtkTypeBool);
177 vtkSetClampMacro(LockSampleDistanceToInputSpacing,
vtkTypeBool, 0, 1);
178 vtkGetMacro(LockSampleDistanceToInputSpacing,
vtkTypeBool);
179 vtkBooleanMacro(LockSampleDistanceToInputSpacing,
vtkTypeBool);
188 void SetNumberOfThreads(
int num);
189 int GetNumberOfThreads();
197 vtkSetClampMacro(IntermixIntersectingGeometry,
vtkTypeBool, 0, 1);
198 vtkGetMacro(IntermixIntersectingGeometry,
vtkTypeBool);
199 vtkBooleanMacro(IntermixIntersectingGeometry,
vtkTypeBool);
210 float ComputeRequiredImageSampleDistance(
float desiredTime,
vtkRenderer* ren);
220 unsigned int ToFixedPointPosition(
float val);
221 void ToFixedPointPosition(
float in[3],
unsigned int out[3]);
222 unsigned int ToFixedPointDirection(
float dir);
223 void ToFixedPointDirection(
float in[3],
unsigned int out[3]);
224 void FixedPointIncrement(
unsigned int position[3],
unsigned int increment[3]);
225 void GetFloatTripleFromPointer(
float v[3],
float* ptr);
226 void GetUIntTripleFromPointer(
unsigned int v[3],
unsigned int* ptr);
227 void ShiftVectorDown(
unsigned int in[3],
unsigned int out[3]);
228 int CheckMinMaxVolumeFlag(
unsigned int pos[3],
int c);
229 int CheckMIPMinMaxVolumeFlag(
unsigned int pos[3],
int c,
unsigned short maxIdx,
int flip);
231 void LookupColorUC(
unsigned short* colorTable,
unsigned short* scalarOpacityTable,
232 unsigned short index,
unsigned char color[4]);
233 void LookupDependentColorUC(
unsigned short* colorTable,
unsigned short* scalarOpacityTable,
234 unsigned short index[4],
int components,
unsigned char color[4]);
235 void LookupAndCombineIndependentColorsUC(
unsigned short* colorTable[4],
236 unsigned short* scalarOpacityTable[4],
unsigned short index[4],
float weights[4],
237 int components,
unsigned char color[4]);
238 int CheckIfCropped(
unsigned int pos[3]);
246 vtkGetVectorMacro(TableShift,
float, 4);
247 vtkGetVectorMacro(TableScale,
float, 4);
248 vtkGetMacro(ShadingRequired,
int);
249 vtkGetMacro(GradientOpacityRequired,
int);
265 int x,
int y,
unsigned int pos[3],
unsigned int dir[3],
unsigned int* numSteps);
269 int ShouldUseNearestNeighborInterpolation(
vtkVolume* vol);
284 void RenderSubVolume();
289 double viewDirection[3],
double viewUp[3]);
299 return this->RetrieveRenderTime(ren, vol);
317 vtkSetMacro(FinalColorWindow,
float);
318 vtkGetMacro(FinalColorWindow,
float);
319 vtkSetMacro(FinalColorLevel,
float);
320 vtkGetMacro(FinalColorLevel,
float);
326 vtkGetMacro(FlipMIPComparison,
int);
360 void ComputeMatrices(
double volumeOrigin[3],
double volumeSpacing[3],
int volumeExtent[6],
363 int ComputeRowBounds(
vtkRenderer* ren,
int imageFlag,
int rowBoundsFlag,
int volumeExtent[6]);
409 int SavedColorChannels[4];
410 float SavedScalarOpacityDistance[4];
420 unsigned short ColorTable[4][32768 * 3];
421 unsigned short ScalarOpacityTable[4][32768];
422 unsigned short GradientOpacityTable[4][256];
427 float GradientMagnitudeScale[4];
428 float GradientMagnitudeShift[4];
443 unsigned short DiffuseShadingTable[4][65536 * 3];
444 unsigned short SpecularShadingTable[4][65536 * 3];
455 int ClipRayAgainstVolume(
456 float rayStart[3],
float rayEnd[3],
float rayDirection[3],
double bounds[6]);
461 void UpdateCroppingRegions();
465 int ClipRayAgainstClippingPlanes(
466 float rayStart[3],
float rayEnd[3],
int numClippingPlanes,
float* clippingPlanes);
468 unsigned int FixedPointCroppingRegionPlanes[6];
469 unsigned int CroppingRegionMask[27];
474 float GetZBufferValue(
int x,
int y);
483 float ViewToVoxelsArray[16];
484 float WorldToVoxelsArray[16];
485 float VoxelsToWorldArray[16];
487 double CroppingBounds[6];
492 double SavedSpacing[3];
496 int MinMaxVolumeSize[4];
502 void FillInMaxGradientMagnitudes(
int fullDim[3],
int smallDim[3]);
509 void ApplyFinalColorWindowLevel();
532 return ((dir < 0.0) ? (static_cast<unsigned int>(-dir *
VTKKW_FP_SCALE + 0.5))
533 : (0x80000000 + static_cast<unsigned int>(dir *
VTKKW_FP_SCALE + 0.5)));
537 float in[3],
unsigned int out[3])
539 out[0] = ((in[0] < 0.0) ? (
static_cast<unsigned int>(-in[0] *
VTKKW_FP_SCALE + 0.5))
540 : (0x80000000 + static_cast<unsigned int>(in[0] *
VTKKW_FP_SCALE + 0.5)));
541 out[1] = ((in[1] < 0.0) ? (
static_cast<unsigned int>(-in[1] *
VTKKW_FP_SCALE + 0.5))
542 : (0x80000000 + static_cast<unsigned int>(in[1] *
VTKKW_FP_SCALE + 0.5)));
543 out[2] = ((in[2] < 0.0) ? (
static_cast<unsigned int>(-in[2] *
VTKKW_FP_SCALE + 0.5))
544 : (0x80000000 + static_cast<unsigned int>(in[2] *
VTKKW_FP_SCALE + 0.5)));
548 unsigned int position[3],
unsigned int increment[3])
550 if (increment[0] & 0x80000000)
552 position[0] += (increment[0] & 0x7fffffff);
556 position[0] -= increment[0];
558 if (increment[1] & 0x80000000)
560 position[1] += (increment[1] & 0x7fffffff);
564 position[1] -= increment[1];
566 if (increment[2] & 0x80000000)
568 position[2] += (increment[2] & 0x7fffffff);
572 position[2] -= increment[2];
584 unsigned int v[3],
unsigned int* ptr)
592 unsigned int in[3],
unsigned int out[3])
602 (mmpos[2] * static_cast<vtkIdType>(this->MinMaxVolumeSize[0] * this->MinMaxVolumeSize[1]) +
603 mmpos[1] *
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) + mmpos[0]) +
606 return ((*(this->MinMaxVolume + 3 * offset + 2)) & 0x00ff);
610 unsigned int mmpos[3],
int c,
unsigned short maxIdx,
int flip)
613 (mmpos[2] * static_cast<vtkIdType>(this->MinMaxVolumeSize[0] * this->MinMaxVolumeSize[1]) +
614 mmpos[1] *
static_cast<vtkIdType>(this->MinMaxVolumeSize[0]) + mmpos[0]) +
617 if ((*(this->MinMaxVolume + 3 * offset + 2) & 0x00ff))
621 return (*(this->MinMaxVolume + 3 * offset) < maxIdx);
625 return (*(this->MinMaxVolume + 3 * offset + 1) > maxIdx);
635 unsigned short* scalarOpacityTable,
unsigned short index,
unsigned char color[4])
637 unsigned short alpha = scalarOpacityTable[
index];
638 color[0] =
static_cast<unsigned char>(
640 color[1] =
static_cast<unsigned char>(
641 (colorTable[3 * index + 1] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
642 color[2] =
static_cast<unsigned char>(
643 (colorTable[3 * index + 2] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
644 color[3] =
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
648 unsigned short* scalarOpacityTable,
unsigned short index[4],
int components,
649 unsigned char color[4])
651 unsigned short alpha;
655 alpha = scalarOpacityTable[index[1]];
656 color[0] =
static_cast<unsigned char>(
657 (colorTable[3 * index[0]] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
658 color[1] =
static_cast<unsigned char>(
659 (colorTable[3 * index[0] + 1] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
660 color[2] =
static_cast<unsigned char>(
661 (colorTable[3 * index[0] + 2] * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
662 color[3] =
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
665 alpha = scalarOpacityTable[index[3]];
666 color[0] =
static_cast<unsigned char>((index[0] * alpha + 0x7fff) >>
VTKKW_FP_SHIFT);
667 color[1] =
static_cast<unsigned char>((index[1] * alpha + 0x7fff) >>
VTKKW_FP_SHIFT);
668 color[2] =
static_cast<unsigned char>((index[2] * alpha + 0x7fff) >>
VTKKW_FP_SHIFT);
669 color[3] =
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
675 unsigned short* colorTable[4],
unsigned short* scalarOpacityTable[4],
unsigned short index[4],
676 float weights[4],
int components,
unsigned char color[4])
678 unsigned int tmp[4] = { 0, 0, 0, 0 };
680 for (
int i = 0; i < components; i++)
682 unsigned short alpha =
683 static_cast<unsigned short>(
static_cast<float>(scalarOpacityTable[i][index[i]]) * weights[i]);
684 tmp[0] +=
static_cast<unsigned char>(
685 ((colorTable[i][3 * index[i]]) * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
686 tmp[1] +=
static_cast<unsigned char>(
687 ((colorTable[i][3 * index[i] + 1]) * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
688 tmp[2] +=
static_cast<unsigned char>(
689 ((colorTable[i][3 * index[i] + 2]) * alpha + 0x7fff) >> (2 *
VTKKW_FP_SHIFT - 8));
690 tmp[3] +=
static_cast<unsigned char>(alpha >> (
VTKKW_FP_SHIFT - 8));
693 color[0] =
static_cast<unsigned char>((tmp[0] > 255) ? (255) : (tmp[0]));
694 color[1] =
static_cast<unsigned char>((tmp[1] > 255) ? (255) : (tmp[1]));
695 color[2] =
static_cast<unsigned char>((tmp[2] > 255) ? (255) : (tmp[2]));
696 color[3] =
static_cast<unsigned char>((tmp[3] > 255) ? (255) : (tmp[3]));
703 if (pos[2] < this->FixedPointCroppingRegionPlanes[4])
707 else if (pos[2] > this->FixedPointCroppingRegionPlanes[5])
716 if (pos[1] >= this->FixedPointCroppingRegionPlanes[2])
718 if (pos[1] > this->FixedPointCroppingRegionPlanes[3])
728 if (pos[0] >= this->FixedPointCroppingRegionPlanes[0])
730 if (pos[0] > this->FixedPointCroppingRegionPlanes[1])
740 return !(
static_cast<unsigned int>(this->
CroppingRegionFlags) & 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