Commit 1e7c81a9 authored by Lisa Avila's avatar Lisa Avila

BUG: fixed error in RGBA calculations - inconsist use of shift / scale which...

BUG: fixed error in RGBA calculations - inconsist use of shift / scale which needs to be used ONLY on 4th component
parent 74acff5b
......@@ -29,7 +29,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOHelper, "1.6");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOHelper, "1.7");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeGOHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeGOHelper with default values
......@@ -225,7 +225,7 @@ void vtkFixedPointCompositeGOHelperGenerateImageFourDependentNN( T *data,
val[0] = *(dptr );
val[1] = *(dptr+1);
val[2] = *(dptr+2);
val[3] = *(dptr+3);
val[3] = static_cast<unsigned short>(((*(dptr+3)) + shift[3])*scale[3]);
unsigned char mag = *magPtr;
......@@ -235,9 +235,9 @@ void vtkFixedPointCompositeGOHelperGenerateImageFourDependentNN( T *data,
continue;
}
tmp[0] = (val[0]*tmp[3]+0x7f)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7f)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7f)>>(8);
tmp[0] = (val[0]*tmp[3]+0x7fff)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7fff)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7fff)>>(8);
VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( color, tmp, remainingOpacity );
}
......@@ -610,13 +610,13 @@ void vtkFixedPointCompositeGOHelperGenerateImageFourDependentTrilin( T *data,
oldSPos[2] = spos[2];
dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 0, scale[0], shift[0] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 0 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 1, scale[1], shift[1] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 1 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 2, scale[2], shift[2] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 2 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 3, scale[3], shift[3] );
......@@ -648,9 +648,9 @@ void vtkFixedPointCompositeGOHelperGenerateImageFourDependentTrilin( T *data,
continue;
}
tmp[0] = (val[0]*tmp[3]+0x7f)>>8;
tmp[1] = (val[1]*tmp[3]+0x7f)>>8;
tmp[2] = (val[2]*tmp[3]+0x7f)>>8;
tmp[0] = (val[0]*tmp[3]+0x7fff)>>8;
tmp[1] = (val[1]*tmp[3]+0x7fff)>>8;
tmp[2] = (val[2]*tmp[3]+0x7fff)>>8;
VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( color, tmp, remainingOpacity );
}
......
......@@ -29,7 +29,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOShadeHelper, "1.6");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeGOShadeHelper, "1.7");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeGOShadeHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeGOShadeHelper with default values
......@@ -233,7 +233,8 @@ void vtkFixedPointCompositeGOShadeHelperGenerateImageFourDependentNN( T *data,
VTKKWRCHelper_CroppingCheckNN( pos );
unsigned short val[4];
val[3] = *(dptr+3);
val[3] = static_cast<unsigned short>(((*(dptr+3)) + shift[3])*scale[3]);
unsigned char mag = *magPtr;
tmp[3] = (scalarOpacityTable[0][val[3]] * gradientOpacityTable[0][mag] + 0x3fff)>>(VTKKW_FP_SHIFT);
......@@ -247,9 +248,9 @@ void vtkFixedPointCompositeGOShadeHelperGenerateImageFourDependentNN( T *data,
val[2] = *(dptr+2);
unsigned short normal = *dirPtr;
tmp[0] = (val[0]*tmp[3]+0x7f)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7f)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7f)>>(8);
tmp[0] = (val[0]*tmp[3]+0x7fff)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7fff)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7fff)>>(8);
VTKKWRCHelper_LookupShading( diffuseShadingTable[0], specularShadingTable[0], normal, tmp );
......@@ -670,13 +671,13 @@ void vtkFixedPointCompositeGOShadeHelperGenerateImageFourDependentTrilin( T *dat
oldSPos[2] = spos[2];
dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 0, scale[0], shift[0] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 0 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 1, scale[1], shift[1] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 1 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 2, scale[2], shift[2] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 2 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 3, scale[3], shift[3] );
......@@ -717,9 +718,9 @@ void vtkFixedPointCompositeGOShadeHelperGenerateImageFourDependentTrilin( T *dat
needToSampleDirection = 0;
}
tmp[0] = (val[0]*tmp[3]+0x7f)>>8;
tmp[1] = (val[1]*tmp[3]+0x7f)>>8;
tmp[2] = (val[2]*tmp[3]+0x7f)>>8;
tmp[0] = (val[0]*tmp[3]+0x7fff)>>8;
tmp[1] = (val[1]*tmp[3]+0x7fff)>>8;
tmp[2] = (val[2]*tmp[3]+0x7fff)>>8;
VTKKWRCHelper_InterpolateShading( diffuseShadingTable[0], specularShadingTable[0], tmp );
VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( color, tmp, remainingOpacity );
......
......@@ -29,7 +29,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeHelper, "1.6");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeHelper, "1.7");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeHelper with default values
......@@ -216,8 +216,8 @@ void vtkFixedPointCompositeHelperGenerateImageFourDependentNN( T *data,
VTKKWRCHelper_CroppingCheckNN( pos );
unsigned short val[4];
val[3] = *(dptr+3);
val[3] = static_cast<unsigned short>(((*(dptr+3)) + shift[3])*scale[3]);
tmp[3] = scalarOpacityTable[0][val[3]];
if ( !tmp[3] )
{
......@@ -228,9 +228,9 @@ void vtkFixedPointCompositeHelperGenerateImageFourDependentNN( T *data,
val[1] = *(dptr+1);
val[2] = *(dptr+2);
tmp[0] = (val[0]*tmp[3]+0x7f)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7f)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7f)>>(8);
tmp[0] = (val[0]*tmp[3]+0x7fff)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7fff)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7fff)>>(8);
VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( color, tmp, remainingOpacity );
}
......@@ -520,13 +520,13 @@ void vtkFixedPointCompositeHelperGenerateImageFourDependentTrilin( T *data,
oldSPos[2] = spos[2];
dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 0, scale[0], shift[0] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 0 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 1, scale[1], shift[1] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 1 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 2, scale[2], shift[2] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 2 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 3, scale[3], shift[3] );
......@@ -542,9 +542,9 @@ void vtkFixedPointCompositeHelperGenerateImageFourDependentTrilin( T *data,
continue;
}
tmp[0] = (val[0]*tmp[3]+0x7f)>>8;
tmp[1] = (val[1]*tmp[3]+0x7f)>>8;
tmp[2] = (val[2]*tmp[3]+0x7f)>>8;
tmp[0] = (val[0]*tmp[3]+0x7fff)>>8;
tmp[1] = (val[1]*tmp[3]+0x7fff)>>8;
tmp[2] = (val[2]*tmp[3]+0x7fff)>>8;
VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( color, tmp, remainingOpacity );
}
......
......@@ -29,7 +29,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeShadeHelper, "1.6");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastCompositeShadeHelper, "1.7");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastCompositeShadeHelper);
// Construct a new vtkFixedPointVolumeRayCastCompositeShadeHelper with default values
......@@ -220,14 +220,14 @@ void vtkFixedPointCompositeShadeHelperGenerateImageFourDependentNN( T *data,
val[0] = *(dptr );
val[1] = *(dptr+1);
val[2] = *(dptr+2);
val[3] = *(dptr+3);
val[3] = static_cast<unsigned short>(((*(dptr+3)) + shift[3])*scale[3]);
tmp[3] = scalarOpacityTable[0][val[3]];
if ( tmp[3] )
{
tmp[0] = (val[0]*tmp[3]+0x7f)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7f)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7f)>>(8);
tmp[0] = (val[0]*tmp[3]+0x7fff)>>(8);
tmp[1] = (val[1]*tmp[3]+0x7fff)>>(8);
tmp[2] = (val[2]*tmp[3]+0x7fff)>>(8);
unsigned short normal = *dirPtr;
VTKKWRCHelper_LookupShading( diffuseShadingTable[0], specularShadingTable[0], normal, tmp );
......@@ -564,13 +564,13 @@ void vtkFixedPointCompositeShadeHelperGenerateImageFourDependentTrilin( T *data,
oldSPos[2] = spos[2];
dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 0, scale[0], shift[0] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 0 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 1, scale[1], shift[1] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 1 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 2, scale[2], shift[2] );
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, 2 );
dptr++;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 3, scale[3], shift[3] );
......@@ -595,9 +595,9 @@ void vtkFixedPointCompositeShadeHelperGenerateImageFourDependentTrilin( T *data,
needToSampleDirection = 0;
}
tmp[0] = (val[0]*tmp[3]+0x7f)>>8;
tmp[1] = (val[1]*tmp[3]+0x7f)>>8;
tmp[2] = (val[2]*tmp[3]+0x7f)>>8;
tmp[0] = (val[0]*tmp[3]+0x7fff)>>8;
tmp[1] = (val[1]*tmp[3]+0x7fff)>>8;
tmp[2] = (val[2]*tmp[3]+0x7fff)>>8;
VTKKWRCHelper_InterpolateShading( diffuseShadingTable[0], specularShadingTable[0], tmp );
VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( color, tmp, remainingOpacity );
......
......@@ -83,6 +83,18 @@
H[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Hinc) + SHIFT))
//ETX
//BTX
#define VTKKWRCHelper_GetCellComponentRawScalarValues( DATA, CIDX ) \
A[CIDX] = static_cast<unsigned int >((*(DATA ))); \
B[CIDX] = static_cast<unsigned int >((*(DATA+Binc))); \
C[CIDX] = static_cast<unsigned int >((*(DATA+Cinc))); \
D[CIDX] = static_cast<unsigned int >((*(DATA+Dinc))); \
E[CIDX] = static_cast<unsigned int >((*(DATA+Einc))); \
F[CIDX] = static_cast<unsigned int >((*(DATA+Finc))); \
G[CIDX] = static_cast<unsigned int >((*(DATA+Ginc))); \
H[CIDX] = static_cast<unsigned int >((*(DATA+Hinc)))
//ETX
//BTX
#define VTKKWRCHelper_GetCellComponentMagnitudeValues( ABCD, EFGH, CIDX ) \
mA[CIDX] = static_cast<unsigned int >(*(ABCD )); \
......@@ -373,9 +385,9 @@
break; \
case 4: \
_alpha = SCALAROPACITYTABLE[IDX[3]]; \
COLOR[0] = static_cast<unsigned short>((IDX[0]*_alpha + 0x7f)>>8 ); \
COLOR[1] = static_cast<unsigned short>((IDX[1]*_alpha + 0x7f)>>8 ); \
COLOR[2] = static_cast<unsigned short>((IDX[2]*_alpha + 0x7f)>>8 ); \
COLOR[0] = static_cast<unsigned short>((IDX[0]*_alpha + 0x7fff)>>8 ); \
COLOR[1] = static_cast<unsigned short>((IDX[1]*_alpha + 0x7fff)>>8 ); \
COLOR[2] = static_cast<unsigned short>((IDX[2]*_alpha + 0x7fff)>>8 ); \
COLOR[3] = _alpha; \
break; \
} \
......
......@@ -26,7 +26,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastMIPHelper, "1.9");
vtkCxxRevisionMacro(vtkFixedPointVolumeRayCastMIPHelper, "1.10");
vtkStandardNewMacro(vtkFixedPointVolumeRayCastMIPHelper);
// Construct a new vtkFixedPointVolumeRayCastMIPHelper with default values
......@@ -175,10 +175,22 @@ void vtkFixedPointMIPHelperGenerateImageDependentNN( T *data,
if ( maxValueDefined )
{
unsigned short maxIdx[4];
unsigned short maxIdx[4]={0,0,0,0};
if ( components == 2 )
{
maxIdx[0] = (unsigned short)((maxValue[0] + shift[0])*scale[0]);
maxIdx[1] = (unsigned short)((maxValue[1] + shift[1])*scale[1]);
}
else
{
maxIdx[0] = (unsigned short)(maxValue[0]);
maxIdx[1] = (unsigned short)(maxValue[1]);
maxIdx[2] = (unsigned short)(maxValue[2]);
maxIdx[3] = (unsigned short)((maxValue[3] + shift[3])*scale[3]);
}
for ( c = 0; c < components; c++ )
{
maxIdx[c] = (unsigned short)((maxValue[c] + shift[c])*scale[c]);
}
VTKKWRCHelper_LookupDependentColorUS( colorTable[0], scalarOpacityTable[0],
maxIdx, components, imagePtr );
......@@ -475,11 +487,25 @@ void vtkFixedPointMIPHelperGenerateImageDependentTrilin( T *dataPtr,
oldSPos[1] = spos[1];
oldSPos[2] = spos[2];
for ( c= 0; c < components; c++ )
if ( components == 2 )
{
for ( c= 0; c < components; c++ )
{
dptr = dataPtr + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2] + c;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, c, scale[c], shift[c] );
}
}
else
{
for ( c= 0; c < 3; c++ )
{
dptr = dataPtr + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2] + c;
VTKKWRCHelper_GetCellComponentRawScalarValues( dptr, c );
}
dptr = dataPtr + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2] + c;
VTKKWRCHelper_GetCellComponentScalarValues( dptr, c, scale[c], shift[c] );
VTKKWRCHelper_GetCellComponentScalarValues( dptr, 3, scale[3], shift[3] );
}
}
VTKKWRCHelper_ComputeWeights(pos);
......
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