vtkSlicerFixedPointVolumeRayCastHelper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSlicerFixedPointVolumeRayCastHelper.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 // .NAME vtkSlicerFixedPointVolumeRayCastHelper - An abstract helper that generates images for the volume ray cast mapper
00016 // .SECTION Description
00017 // This is the abstract superclass of all helper classes for the 
00018 // vtkSlicerFixedPointVolumeRayCastMapper. This class should not be used directly.
00019 //
00020 // .SECTION see also
00021 // vtkSlicerFixedPointVolumeRayCastMapper
00022 
00023 #ifndef __vtkSlicerFixedPointVolumeRayCastHelper_h
00024 #define __vtkSlicerFixedPointVolumeRayCastHelper_h
00025 
00026 //BTX
00027 #define VTKKWRCHelper_GetCellScalarValues( DATA, SCALE, SHIFT ) \
00028   A = static_cast<unsigned int >(SCALE*(*(DATA     ) + SHIFT)); \
00029   B = static_cast<unsigned int >(SCALE*(*(DATA+Binc) + SHIFT)); \
00030   C = static_cast<unsigned int >(SCALE*(*(DATA+Cinc) + SHIFT)); \
00031   D = static_cast<unsigned int >(SCALE*(*(DATA+Dinc) + SHIFT)); \
00032   E = static_cast<unsigned int >(SCALE*(*(DATA+Einc) + SHIFT)); \
00033   F = static_cast<unsigned int >(SCALE*(*(DATA+Finc) + SHIFT)); \
00034   G = static_cast<unsigned int >(SCALE*(*(DATA+Ginc) + SHIFT)); \
00035   H = static_cast<unsigned int >(SCALE*(*(DATA+Hinc) + SHIFT))
00036 //ETX
00037 
00038 //BTX
00039 #define VTKKWRCHelper_GetCellScalarValuesSimple( DATA )  \
00040   A = static_cast<unsigned int >(*(DATA     ));          \
00041   B = static_cast<unsigned int >(*(DATA+Binc));          \
00042   C = static_cast<unsigned int >(*(DATA+Cinc));          \
00043   D = static_cast<unsigned int >(*(DATA+Dinc));          \
00044   E = static_cast<unsigned int >(*(DATA+Einc));          \
00045   F = static_cast<unsigned int >(*(DATA+Finc));          \
00046   G = static_cast<unsigned int >(*(DATA+Ginc));          \
00047   H = static_cast<unsigned int >(*(DATA+Hinc))
00048 //ETX
00049 
00050 //BTX
00051 #define VTKKWRCHelper_GetCellMagnitudeValues( ABCD, EFGH )       \
00052   mA = static_cast<unsigned int >(*(ABCD      ));                \
00053   mB = static_cast<unsigned int >(*(ABCD+mBFinc));               \
00054   mC = static_cast<unsigned int >(*(ABCD+mCGinc));               \
00055   mD = static_cast<unsigned int >(*(ABCD+mDHinc));               \
00056   mE = static_cast<unsigned int >(*(EFGH       ));               \
00057   mF = static_cast<unsigned int >(*(EFGH+mBFinc));               \
00058   mG = static_cast<unsigned int >(*(EFGH+mCGinc));               \
00059   mH = static_cast<unsigned int >(*(EFGH+mDHinc))
00060 //ETX
00061 
00062 //BTX
00063 #define VTKKWRCHelper_GetCellDirectionValues( ABCD, EFGH )      \
00064   normalA   = static_cast<unsigned int >(*(ABCD       ));       \
00065   normalB   = static_cast<unsigned int >(*(ABCD+dBFinc));       \
00066   normalC   = static_cast<unsigned int >(*(ABCD+dCGinc));       \
00067   normalD   = static_cast<unsigned int >(*(ABCD+dDHinc));       \
00068   normalE   = static_cast<unsigned int >(*(EFGH       ));       \
00069   normalF   = static_cast<unsigned int >(*(EFGH+dBFinc));       \
00070   normalG   = static_cast<unsigned int >(*(EFGH+dCGinc));       \
00071   normalH   = static_cast<unsigned int >(*(EFGH+dDHinc));
00072 //ETX
00073 
00074 //BTX
00075 #define VTKKWRCHelper_GetCellComponentScalarValues( DATA, CIDX, SCALE, SHIFT )    \
00076   A[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA     ) + SHIFT));             \
00077   B[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Binc) + SHIFT));             \
00078   C[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Cinc) + SHIFT));             \
00079   D[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Dinc) + SHIFT));             \
00080   E[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Einc) + SHIFT));             \
00081   F[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Finc) + SHIFT));             \
00082   G[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Ginc) + SHIFT));             \
00083   H[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Hinc) + SHIFT))
00084 //ETX
00085 
00086 //BTX
00087 #define VTKKWRCHelper_GetCellComponentMagnitudeValues( ABCD, EFGH, CIDX )      \
00088   mA[CIDX] = static_cast<unsigned int >(*(ABCD       ));                       \
00089   mB[CIDX] = static_cast<unsigned int >(*(ABCD+mBFinc));                       \
00090   mC[CIDX] = static_cast<unsigned int >(*(ABCD+mCGinc));                       \
00091   mD[CIDX] = static_cast<unsigned int >(*(ABCD+mDHinc));                       \
00092   mE[CIDX] = static_cast<unsigned int >(*(EFGH       ));                       \
00093   mF[CIDX] = static_cast<unsigned int >(*(EFGH+mBFinc));                       \
00094   mG[CIDX] = static_cast<unsigned int >(*(EFGH+mCGinc));                       \
00095   mH[CIDX] = static_cast<unsigned int >(*(EFGH+mDHinc))
00096 //ETX
00097 
00098 //BTX
00099 #define VTKKWRCHelper_GetCellComponentDirectionValues( ABCD, EFGH, CIDX )       \
00100   normalA[CIDX]   = static_cast<unsigned int >(*(ABCD       ));                 \
00101   normalB[CIDX]   = static_cast<unsigned int >(*(ABCD+dBFinc));                 \
00102   normalC[CIDX]   = static_cast<unsigned int >(*(ABCD+dCGinc));                 \
00103   normalD[CIDX]   = static_cast<unsigned int >(*(ABCD+dDHinc));                 \
00104   normalE[CIDX]   = static_cast<unsigned int >(*(EFGH       ));                 \
00105   normalF[CIDX]   = static_cast<unsigned int >(*(EFGH+dBFinc));                 \
00106   normalG[CIDX]   = static_cast<unsigned int >(*(EFGH+dCGinc));                 \
00107   normalH[CIDX]   = static_cast<unsigned int >(*(EFGH+dDHinc));
00108 //ETX
00109 
00110 
00111 //BTX
00112 #define VTKKWRCHelper_ComputeWeights( POS )                                             \
00113   w2X = (POS[0]&VTKKW_FP_MASK);                                                         \
00114   w2Y = (POS[1]&VTKKW_FP_MASK);                                                         \
00115   w2Z = (POS[2]&VTKKW_FP_MASK);                                                         \
00116                                                                                         \
00117   w1X = ((~w2X)&VTKKW_FP_MASK);                                                         \
00118   w1Y = ((~w2Y)&VTKKW_FP_MASK);                                                         \
00119   w1Z = ((~w2Z)&VTKKW_FP_MASK);                                                         \
00120                                                                                         \
00121   w1Xw1Y = (0x4000+(w1X*w1Y))>>VTKKW_FP_SHIFT;                                          \
00122   w2Xw1Y = (0x4000+(w2X*w1Y))>>VTKKW_FP_SHIFT;                                          \
00123   w1Xw2Y = (0x4000+(w1X*w2Y))>>VTKKW_FP_SHIFT;                                          \
00124   w2Xw2Y = (0x4000+(w2X*w2Y))>>VTKKW_FP_SHIFT;                                          \
00125 //ETX
00126 
00127 
00128 //BTX
00129 #define VTKKWRCHelper_InterpolateScalar( VAL )                                  \
00130   VAL =                                                                         \
00131     (0x7fff + ((A*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00132                (B*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00133                (C*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00134                (D*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00135                (E*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00136                (F*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00137                (G*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00138                (H*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;
00139 //ETX
00140 
00141 //BTX
00142 #define VTKKWRCHelper_InterpolateMagnitude( VAL )                                       \
00143   VAL =                                                                                 \
00144     (0x7fff + ((mA*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                           \
00145                (mB*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                           \
00146                (mC*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                           \
00147                (mD*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                           \
00148                (mE*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                           \
00149                (mF*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                           \
00150                (mG*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                           \
00151                (mH*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;
00152 //ETX
00153 
00154 //BTX  
00155 #define VTKKWRCHelper_InterpolateScalarComponent( VAL, CIDX, COMPONENTS )               \
00156   for ( CIDX = 0; CIDX < COMPONENTS; CIDX++ )                                           \
00157     {                                                                                   \
00158     VAL[CIDX] =                                                                         \
00159     (0x7fff + ((A[CIDX]*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00160                (B[CIDX]*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00161                (C[CIDX]*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00162                (D[CIDX]*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00163                (E[CIDX]*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00164                (F[CIDX]*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00165                (G[CIDX]*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00166                (H[CIDX]*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;   \
00167     }                                                                                   \
00168 //ETX 
00169       
00170 //BTX 
00171 #define VTKKWRCHelper_InterpolateMagnitudeComponent( VAL, CIDX, COMPONENTS )            \
00172   for ( CIDX = 0; CIDX < COMPONENTS; CIDX++ )                                           \
00173     {                                                                                   \
00174     VAL[CIDX] =                                                                         \
00175     (0x7fff + ((mA[CIDX]*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                     \
00176                (mB[CIDX]*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                     \
00177                (mC[CIDX]*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                     \
00178                (mD[CIDX]*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                     \
00179                (mE[CIDX]*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                     \
00180                (mF[CIDX]*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                     \
00181                (mG[CIDX]*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                     \
00182                (mH[CIDX]*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;  \
00183     }
00184 //ETX
00185 
00186 //BTX
00187 #define VTKKWRCHelper_InterpolateShading( DTABLE, STABLE, COLOR )                                       \
00188   unsigned int _tmpDColor[3];                                                                           \
00189   unsigned int _tmpSColor[3];                                                                           \
00190                                                                                                         \
00191   _tmpDColor[0] =                                                                                       \
00192     (0x7fff + ((DTABLE[3*normalA] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00193                (DTABLE[3*normalB] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00194                (DTABLE[3*normalC] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00195                (DTABLE[3*normalD] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00196                (DTABLE[3*normalE] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                          \
00197                (DTABLE[3*normalF] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                          \
00198                (DTABLE[3*normalG] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                          \
00199                (DTABLE[3*normalH] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;       \
00200                                                                                                         \
00201   _tmpDColor[1] =                                                                                       \
00202     (0x7fff + ((DTABLE[3*normalA+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00203                (DTABLE[3*normalB+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00204                (DTABLE[3*normalC+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00205                (DTABLE[3*normalD+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00206                (DTABLE[3*normalE+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00207                (DTABLE[3*normalF+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00208                (DTABLE[3*normalG+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00209                (DTABLE[3*normalH+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;     \
00210                                                                                                         \
00211   _tmpDColor[2] =                                                                                       \
00212     (0x7fff + ((DTABLE[3*normalA+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00213                (DTABLE[3*normalB+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00214                (DTABLE[3*normalC+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00215                (DTABLE[3*normalD+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00216                (DTABLE[3*normalE+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00217                (DTABLE[3*normalF+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00218                (DTABLE[3*normalG+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00219                (DTABLE[3*normalH+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;     \
00220                                                                                                         \
00221   _tmpSColor[0] =                                                                                       \
00222     (0x7fff + ((STABLE[3*normalA] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00223                (STABLE[3*normalB] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00224                (STABLE[3*normalC] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00225                (STABLE[3*normalD] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                          \
00226                (STABLE[3*normalE] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                          \
00227                (STABLE[3*normalF] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                          \
00228                (STABLE[3*normalG] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                          \
00229                (STABLE[3*normalH] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;       \
00230                                                                                                         \
00231   _tmpSColor[1] =                                                                                       \
00232     (0x7fff + ((STABLE[3*normalA+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00233                (STABLE[3*normalB+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00234                (STABLE[3*normalC+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00235                (STABLE[3*normalD+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00236                (STABLE[3*normalE+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00237                (STABLE[3*normalF+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00238                (STABLE[3*normalG+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00239                (STABLE[3*normalH+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;     \
00240                                                                                                         \
00241   _tmpSColor[2] =                                                                                       \
00242     (0x7fff + ((STABLE[3*normalA+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00243                (STABLE[3*normalB+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00244                (STABLE[3*normalC+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00245                (STABLE[3*normalD+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                        \
00246                (STABLE[3*normalE+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00247                (STABLE[3*normalF+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00248                (STABLE[3*normalG+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                        \
00249                (STABLE[3*normalH+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;     \
00250                                                                                                         \
00251                                                                                                         \
00252   COLOR[0] = static_cast<unsigned short>((_tmpDColor[0]*COLOR[0]+0x7fff)>>VTKKW_FP_SHIFT);              \
00253   COLOR[1] = static_cast<unsigned short>((_tmpDColor[1]*COLOR[1]+0x7fff)>>VTKKW_FP_SHIFT);              \
00254   COLOR[2] = static_cast<unsigned short>((_tmpDColor[2]*COLOR[2]+0x7fff)>>VTKKW_FP_SHIFT);              \
00255   COLOR[0] += (_tmpSColor[0]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;                                        \
00256   COLOR[1] += (_tmpSColor[1]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;                                        \
00257   COLOR[2] += (_tmpSColor[2]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;
00258 //ETX
00259 
00260 
00261 //BTX
00262 #define VTKKWRCHelper_InterpolateShadingComponent( DTABLE, STABLE, COLOR, CIDX )                                \
00263   unsigned int _tmpDColor[3];                                                                                   \
00264   unsigned int _tmpSColor[3];                                                                                   \
00265                                                                                                                 \
00266   _tmpDColor[0] =                                                                                               \
00267     (0x7fff + ((DTABLE[CIDX][3*normalA[CIDX]] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00268                (DTABLE[CIDX][3*normalB[CIDX]] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00269                (DTABLE[CIDX][3*normalC[CIDX]] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00270                (DTABLE[CIDX][3*normalD[CIDX]] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00271                (DTABLE[CIDX][3*normalE[CIDX]] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00272                (DTABLE[CIDX][3*normalF[CIDX]] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00273                (DTABLE[CIDX][3*normalG[CIDX]] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00274                (DTABLE[CIDX][3*normalH[CIDX]] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;   \
00275                                                                                                                 \
00276   _tmpDColor[1] =                                                                                               \
00277     (0x7fff + ((DTABLE[CIDX][3*normalA[CIDX]+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00278                (DTABLE[CIDX][3*normalB[CIDX]+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00279                (DTABLE[CIDX][3*normalC[CIDX]+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00280                (DTABLE[CIDX][3*normalD[CIDX]+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00281                (DTABLE[CIDX][3*normalE[CIDX]+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00282                (DTABLE[CIDX][3*normalF[CIDX]+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00283                (DTABLE[CIDX][3*normalG[CIDX]+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00284                (DTABLE[CIDX][3*normalH[CIDX]+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
00285                                                                                                                 \
00286   _tmpDColor[2] =                                                                                               \
00287     (0x7fff + ((DTABLE[CIDX][3*normalA[CIDX]+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00288                (DTABLE[CIDX][3*normalB[CIDX]+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00289                (DTABLE[CIDX][3*normalC[CIDX]+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00290                (DTABLE[CIDX][3*normalD[CIDX]+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00291                (DTABLE[CIDX][3*normalE[CIDX]+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00292                (DTABLE[CIDX][3*normalF[CIDX]+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00293                (DTABLE[CIDX][3*normalG[CIDX]+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00294                (DTABLE[CIDX][3*normalH[CIDX]+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
00295                                                                                                                 \
00296   _tmpSColor[0] =                                                                                               \
00297     (0x7fff + ((STABLE[CIDX][3*normalA[CIDX]] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00298                (STABLE[CIDX][3*normalB[CIDX]] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00299                (STABLE[CIDX][3*normalC[CIDX]] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00300                (STABLE[CIDX][3*normalD[CIDX]] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                      \
00301                (STABLE[CIDX][3*normalE[CIDX]] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00302                (STABLE[CIDX][3*normalF[CIDX]] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00303                (STABLE[CIDX][3*normalG[CIDX]] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                      \
00304                (STABLE[CIDX][3*normalH[CIDX]] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;   \
00305                                                                                                                 \
00306   _tmpSColor[1] =                                                                                               \
00307     (0x7fff + ((STABLE[CIDX][3*normalA[CIDX]+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00308                (STABLE[CIDX][3*normalB[CIDX]+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00309                (STABLE[CIDX][3*normalC[CIDX]+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00310                (STABLE[CIDX][3*normalD[CIDX]+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00311                (STABLE[CIDX][3*normalE[CIDX]+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00312                (STABLE[CIDX][3*normalF[CIDX]+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00313                (STABLE[CIDX][3*normalG[CIDX]+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00314                (STABLE[CIDX][3*normalH[CIDX]+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
00315                                                                                                                 \
00316   _tmpSColor[2] =                                                                                               \
00317     (0x7fff + ((STABLE[CIDX][3*normalA[CIDX]+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00318                (STABLE[CIDX][3*normalB[CIDX]+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00319                (STABLE[CIDX][3*normalC[CIDX]+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00320                (STABLE[CIDX][3*normalD[CIDX]+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) +                    \
00321                (STABLE[CIDX][3*normalE[CIDX]+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00322                (STABLE[CIDX][3*normalF[CIDX]+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00323                (STABLE[CIDX][3*normalG[CIDX]+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) +                    \
00324                (STABLE[CIDX][3*normalH[CIDX]+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
00325                                                                                                                 \
00326                                                                                                                 \
00327   COLOR[0] = static_cast<unsigned short>((_tmpDColor[0]*COLOR[0]+0x7fff)>>VTKKW_FP_SHIFT);                      \
00328   COLOR[1] = static_cast<unsigned short>((_tmpDColor[1]*COLOR[1]+0x7fff)>>VTKKW_FP_SHIFT);                      \
00329   COLOR[2] = static_cast<unsigned short>((_tmpDColor[2]*COLOR[2]+0x7fff)>>VTKKW_FP_SHIFT);                      \
00330   COLOR[0] += (_tmpSColor[0]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;                                                \
00331   COLOR[1] += (_tmpSColor[1]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;                                                \
00332   COLOR[2] += (_tmpSColor[2]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;
00333 //ETX
00334 
00335 //BTX
00336 #define VTKKWRCHelper_LookupColorUS( COLORTABLE, SCALAROPACITYTABLE, IDX, COLOR )       \
00337   COLOR[3] = SCALAROPACITYTABLE[IDX];                                                   \
00338   if ( !COLOR[3] ) {continue;}                                                          \
00339   COLOR[0] = static_cast<unsigned short>                                                \
00340     ((COLORTABLE[3*IDX  ]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                        \
00341   COLOR[1] = static_cast<unsigned short>                                                \
00342     ((COLORTABLE[3*IDX+1]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                        \
00343   COLOR[2] = static_cast<unsigned short>                                                \
00344     ((COLORTABLE[3*IDX+2]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));
00345 //ETX
00346 
00347 //BTX
00348 #define VTKKWRCHelper_LookupColorMax( COLORTABLE, SCALAROPACITYTABLE, IDX, COLOR )    \
00349   COLOR[3] = SCALAROPACITYTABLE[IDX];                                                 \
00350   COLOR[0] = static_cast<unsigned short>                                              \
00351     ((COLORTABLE[3*IDX  ]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                      \
00352   COLOR[1] = static_cast<unsigned short>                                              \
00353     ((COLORTABLE[3*IDX+1]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                      \
00354   COLOR[2] = static_cast<unsigned short>                                              \
00355     ((COLORTABLE[3*IDX+2]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                     
00356 //ETX
00357 
00358 //BTX
00359 #define VTKKWRCHelper_LookupDependentColorUS( COLORTABLE, SCALAROPACITYTABLE, IDX, CMPS, COLOR )        \
00360   {                                                                                                     \
00361   unsigned short _alpha;                                                                                \
00362   switch ( CMPS )                                                                                       \
00363     {                                                                                                   \
00364     case 2:                                                                                             \
00365       _alpha = SCALAROPACITYTABLE[IDX[1]];                                                              \
00366       COLOR[0] = static_cast<unsigned short>                                                            \
00367         ((COLORTABLE[3*IDX[0]  ]*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT));                                   \
00368       COLOR[1] = static_cast<unsigned short>                                                            \
00369         ((COLORTABLE[3*IDX[0]+1]*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT));                                   \
00370       COLOR[2] = static_cast<unsigned short>                                                            \
00371         ((COLORTABLE[3*IDX[0]+2]*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT));                                   \
00372       COLOR[3] = _alpha;                                                                                \
00373       break;                                                                                            \
00374     case 4:                                                                                             \
00375       _alpha = SCALAROPACITYTABLE[IDX[3]];                                                              \
00376       COLOR[0] = static_cast<unsigned short>((IDX[0]*_alpha + 0x7f)>>8 );                               \
00377       COLOR[1] = static_cast<unsigned short>((IDX[1]*_alpha + 0x7f)>>8 );                               \
00378       COLOR[2] = static_cast<unsigned short>((IDX[2]*_alpha + 0x7f)>>8 );                               \
00379       COLOR[3] = _alpha;                                                                                \
00380       break;                                                                                            \
00381     }                                                                                                   \
00382   }
00383 //ETX
00384 
00385 //BTX
00386 #define VTKKWRCHelper_LookupColorGOUS( CTABLE, SOTABLE, GOTABLE, IDX, IDX2, COLOR )     \
00387   COLOR[3] = (SOTABLE[IDX] * GOTABLE[IDX2] + 0x7fff)>>VTKKW_FP_SHIFT;                   \
00388   if ( !COLOR[3] ) {continue;}                                                          \
00389   COLOR[0] = static_cast<unsigned short>                                                \
00390     ((CTABLE[3*IDX  ]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                            \
00391   COLOR[1] = static_cast<unsigned short>                                                \
00392     ((CTABLE[3*IDX+1]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));                            \
00393   COLOR[2] = static_cast<unsigned short>                                                \
00394     ((CTABLE[3*IDX+2]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));
00395 //ETX
00396 
00397 //BTX
00398 #define VTKKWRCHelper_LookupShading( DTABLE, STABLE, NORMAL, COLOR )                            \
00399   COLOR[0] = static_cast<unsigned short>((DTABLE[3*NORMAL  ]*COLOR[0]+0x7fff)>>VTKKW_FP_SHIFT); \
00400   COLOR[1] = static_cast<unsigned short>((DTABLE[3*NORMAL+1]*COLOR[1]+0x7fff)>>VTKKW_FP_SHIFT); \
00401   COLOR[2] = static_cast<unsigned short>((DTABLE[3*NORMAL+2]*COLOR[2]+0x7fff)>>VTKKW_FP_SHIFT); \
00402   COLOR[0] += (STABLE[3*NORMAL  ]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;                           \
00403   COLOR[1] += (STABLE[3*NORMAL+1]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;                           \
00404   COLOR[2] += (STABLE[3*NORMAL+2]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;
00405 //ETX
00406 
00407 
00408 //BTX
00409 #define VTKKWRCHelper_LookupAndCombineIndependentColorsUS( COLORTABLE, SOTABLE,                                                 \
00410                                                            SCALAR, WEIGHTS,                                                     \
00411                                                            COMPONENTS, COLOR )                                                  \
00412   unsigned int _tmp[4] = {0,0,0,0};                                                                                             \
00413   unsigned short _alpha[4] = {0,0,0,0};                                                                                         \
00414   unsigned int _totalAlpha = 0;                                                                                                 \
00415                                                                                                                                 \
00416   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00417     {                                                                                                                           \
00418     _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]);                                      \
00419     _totalAlpha += _alpha[_idx];                                                                                                \
00420     }}                                                                                                                          \
00421                                                                                                                                 \
00422   if ( !_totalAlpha ) {continue;}                                                                                               \
00423   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00424     {                                                                                                                           \
00425     if ( _alpha[_idx] )                                                                                                         \
00426       {                                                                                                                         \
00427       _tmp[0] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]  ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00428       _tmp[1] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00429       _tmp[2] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00430       _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha);                                                                     \
00431       }                                                                                                                         \
00432     }}                                                                                                                          \
00433   if ( !_tmp[3] ) {continue;}                                                                                                   \
00434   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                                 \
00435   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                                 \
00436   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                                 \
00437   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
00438 //ETX
00439 
00440 //BTX
00441 #define VTKKWRCHelper_LookupAndCombineIndependentColorsMax( COLORTABLE, SCALAROPACITYTABLE,                             \
00442                                                             IDX, WEIGHTS, CMPS, COLOR )                                 \
00443   {                                                                                                                     \
00444   unsigned int _tmp[4] = {0,0,0,0};                                                                                     \
00445   for ( int _idx = 0; _idx < CMPS; _idx++ )                                                                             \
00446     {                                                                                                                   \
00447     unsigned short _alpha = static_cast<unsigned short>(SCALAROPACITYTABLE[_idx][IDX[_idx]]*WEIGHTS[_idx]);             \
00448     _tmp[0] += static_cast<unsigned short>(((COLORTABLE[_idx][3*IDX[_idx]  ])*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT));      \
00449     _tmp[1] += static_cast<unsigned short>(((COLORTABLE[_idx][3*IDX[_idx]+1])*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT));      \
00450     _tmp[2] += static_cast<unsigned short>(((COLORTABLE[_idx][3*IDX[_idx]+2])*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT));      \
00451     _tmp[3] += _alpha;                                                                                                  \
00452     }                                                                                                                   \
00453   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                         \
00454   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                         \
00455   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                         \
00456   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);                                                                         \
00457   }
00458 //ETX
00459 
00460 //BTX
00461 #define VTKKWRCHelper_LookupAndCombineIndependentColorsGOUS( COLORTABLE, SOTABLE,                                               \
00462                                                            GOTABLE,                                                             \
00463                                                            SCALAR, MAG, WEIGHTS,                                                \
00464                                                            COMPONENTS, COLOR )                                                  \
00465   unsigned int _tmp[4] = {0,0,0,0};                                                                                             \
00466   unsigned short _alpha[4] = {0,0,0,0};                                                                                         \
00467   unsigned int _totalAlpha = 0;                                                                                                 \
00468                                                                                                                                 \
00469   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00470     {                                                                                                                           \
00471     _alpha[_idx] =  static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]);                                     \
00472     if ( _alpha[_idx] )                                                                                                         \
00473       {                                                                                                                         \
00474       _alpha[_idx] = static_cast<unsigned short>((_alpha[_idx]*GOTABLE[_idx][MAG[_idx]] + 0x7fff)>>(VTKKW_FP_SHIFT));           \
00475       _totalAlpha += _alpha[_idx];                                                                                              \
00476       }                                                                                                                         \
00477     }}                                                                                                                          \
00478                                                                                                                                 \
00479   if ( !_totalAlpha ) {continue;}                                                                                               \
00480   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00481     {                                                                                                                           \
00482     if ( _alpha[_idx] )                                                                                                         \
00483       {                                                                                                                         \
00484       _tmp[0] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]  ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00485       _tmp[1] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00486       _tmp[2] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00487       _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha);                                                                     \
00488       }                                                                                                                         \
00489     }}                                                                                                                          \
00490   if ( !_tmp[3] ) {continue;};                                                                                                  \
00491   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                                 \
00492   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                                 \
00493   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                                 \
00494   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
00495 //ETX
00496 
00497 //BTX
00498 #define VTKKWRCHelper_LookupAndCombineIndependentColorsShadeUS( COLORTABLE, SOTABLE,                                            \
00499                                                                 DTABLE, STABLE,                                                 \
00500                                                                 SCALAR, NORMAL, WEIGHTS,                                        \
00501                                                                 COMPONENTS, COLOR )                                             \
00502   unsigned int _tmp[4] = {0,0,0,0};                                                                                             \
00503   unsigned int _tmpC[3];                                                                                                        \
00504   unsigned short _alpha[4] = {0,0,0,0};                                                                                         \
00505   unsigned int _totalAlpha = 0;                                                                                                 \
00506                                                                                                                                 \
00507   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00508     {                                                                                                                           \
00509     _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]);                                      \
00510     _totalAlpha += _alpha[_idx];                                                                                                \
00511     }}                                                                                                                          \
00512                                                                                                                                 \
00513   if ( !_totalAlpha ) {continue;}                                                                                               \
00514   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00515     {                                                                                                                           \
00516     if ( _alpha[_idx] )                                                                                                         \
00517       {                                                                                                                         \
00518       _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]  ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00519       _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00520       _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00521       _tmpC[0] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]  ]*_tmpC[0]+0x7fff)>>VTKKW_FP_SHIFT);                 \
00522       _tmpC[1] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+1]*_tmpC[1]+0x7fff)>>VTKKW_FP_SHIFT);                 \
00523       _tmpC[2] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+2]*_tmpC[2]+0x7fff)>>VTKKW_FP_SHIFT);                 \
00524       _tmpC[0] += (STABLE[_idx][3*NORMAL[_idx]  ]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT;                                       \
00525       _tmpC[1] += (STABLE[_idx][3*NORMAL[_idx]+1]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT;                                       \
00526       _tmpC[2] += (STABLE[_idx][3*NORMAL[_idx]+2]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT;                                       \
00527       _tmp[0] += _tmpC[0];                                                                                                      \
00528       _tmp[1] += _tmpC[1];                                                                                                      \
00529       _tmp[2] += _tmpC[2];                                                                                                      \
00530       _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha);                                                                     \
00531       }                                                                                                                         \
00532     }}                                                                                                                           \
00533   if ( !_tmp[3] ) {continue;}                                                                                                   \
00534                                                                                                                                 \
00535   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                                 \
00536   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                                 \
00537   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                                 \
00538   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
00539 //ETX
00540 
00541 //BTX
00542 #define VTKKWRCHelper_LookupAndCombineIndependentColorsInterpolateShadeUS( COLORTABLE, SOTABLE,                                 \
00543                                                                            DTABLE, STABLE,                                      \
00544                                                                            SCALAR, WEIGHTS,                                     \
00545                                                                            COMPONENTS, COLOR )                                  \
00546   unsigned int _tmp[4] = {0,0,0,0};                                                                                             \
00547   unsigned int _tmpC[4];                                                                                                        \
00548   unsigned short _alpha[4] = {0,0,0,0};                                                                                         \
00549   unsigned int _totalAlpha = 0;                                                                                                 \
00550                                                                                                                                 \
00551   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00552     {                                                                                                                           \
00553     _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]);                                      \
00554     _totalAlpha += _alpha[_idx];                                                                                                \
00555     }}                                                                                                                          \
00556                                                                                                                                 \
00557   if ( !_totalAlpha ) {continue;}                                                                                               \
00558   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00559     {                                                                                                                           \
00560     if ( _alpha[_idx] )                                                                                                         \
00561       {                                                                                                                         \
00562       _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]  ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00563       _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00564       _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00565       _tmpC[3] = _alpha[_idx];                                                                                                  \
00566       VTKKWRCHelper_InterpolateShadingComponent( DTABLE, STABLE, _tmpC, _idx );                                                 \
00567       _tmp[0] += _tmpC[0];                                                                                                      \
00568       _tmp[1] += _tmpC[1];                                                                                                      \
00569       _tmp[2] += _tmpC[2];                                                                                                      \
00570       _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha);                                                                     \
00571       }                                                                                                                         \
00572     }}                                                                                                                          \
00573   if (!_tmp[3]) {continue;}                                                                                                     \
00574   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                                 \
00575   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                                 \
00576   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                                 \
00577   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
00578 //ETX
00579 
00580 //BTX
00581 #define VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( COLOR, TMP, REMAININGOPACITY )    \
00582   COLOR[0] += (TMP[0]*REMAININGOPACITY+0x7fff)>>VTKKW_FP_SHIFT;                                 \
00583   COLOR[1] += (TMP[1]*REMAININGOPACITY+0x7fff)>>VTKKW_FP_SHIFT;                                 \
00584   COLOR[2] += (TMP[2]*REMAININGOPACITY+0x7fff)>>VTKKW_FP_SHIFT;                                 \
00585   REMAININGOPACITY = (REMAININGOPACITY*((~(TMP[3])&VTKKW_FP_MASK))+0x7fff)>>VTKKW_FP_SHIFT;     \
00586   if ( REMAININGOPACITY < 0xff )                                                                \
00587     {                                                                                           \
00588     break;                                                                                      \
00589     }
00590 //ETX
00591 
00592 //BTX
00593 #define VTKKWRCHelper_LookupAndCombineIndependentColorsGOShadeUS( COLORTABLE, SOTABLE, GOTABLE,                                 \
00594                                                                 DTABLE, STABLE,                                                 \
00595                                                                 SCALAR, MAG, NORMAL, WEIGHTS,                                   \
00596                                                                 COMPONENTS, COLOR )                                             \
00597   unsigned int _tmp[4] = {0,0,0,0};                                                                                             \
00598   unsigned int _tmpC[3];                                                                                                        \
00599   unsigned short _alpha[4] = {0,0,0,0};                                                                                         \
00600   unsigned int _totalAlpha = 0;                                                                                                 \
00601                                                                                                                                 \
00602   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00603     {                                                                                                                           \
00604     _alpha[_idx] =  static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]);                                     \
00605     if ( _alpha[_idx] )                                                                                                         \
00606       {                                                                                                                         \
00607       _alpha[_idx] = static_cast<unsigned short>((_alpha[_idx]*GOTABLE[_idx][MAG[_idx]] + 0x7fff)>>(VTKKW_FP_SHIFT));           \
00608       _totalAlpha += _alpha[_idx];                                                                                              \
00609       }                                                                                                                         \
00610     }}                                                                                                                          \
00611                                                                                                                                 \
00612   if ( !_totalAlpha ) {continue;}                                                                                               \
00613                                                                                                                                 \
00614   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00615     {                                                                                                                           \
00616     if ( _alpha[_idx] )                                                                                                         \
00617       {                                                                                                                         \
00618       _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]  ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00619       _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00620       _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00621       _tmpC[0] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]  ]*_tmpC[0]+0x7fff)>>VTKKW_FP_SHIFT);                 \
00622       _tmpC[1] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+1]*_tmpC[1]+0x7fff)>>VTKKW_FP_SHIFT);                 \
00623       _tmpC[2] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+2]*_tmpC[2]+0x7fff)>>VTKKW_FP_SHIFT);                 \
00624       _tmpC[0] += (STABLE[_idx][3*NORMAL[_idx]  ]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT;                                       \
00625       _tmpC[1] += (STABLE[_idx][3*NORMAL[_idx]+1]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT;                                       \
00626       _tmpC[2] += (STABLE[_idx][3*NORMAL[_idx]+2]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT;                                       \
00627       _tmp[0] += _tmpC[0];                                                                                                      \
00628       _tmp[1] += _tmpC[1];                                                                                                      \
00629       _tmp[2] += _tmpC[2];                                                                                                      \
00630       _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha);                                                                     \
00631       }                                                                                                                         \
00632     }}                                                                                                                          \
00633   if ( !_tmp[3] ) {continue;}                                                                                                   \
00634   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                                 \
00635   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                                 \
00636   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                                 \
00637   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
00638 //ETX
00639 
00640 //BTX
00641 #define VTKKWRCHelper_LookupAndCombineIndependentColorsGOInterpolateShadeUS( COLORTABLE, SOTABLE, GOTABLE,                      \
00642                                                                 DTABLE, STABLE,                                                 \
00643                                                                 SCALAR, MAG, WEIGHTS,                                           \
00644                                                                 COMPONENTS, COLOR )                                             \
00645   unsigned int _tmp[4] = {0,0,0,0};                                                                                             \
00646   unsigned int _tmpC[4];                                                                                                        \
00647   unsigned short _alpha[4] = {0,0,0,0};                                                                                         \
00648   unsigned int _totalAlpha = 0;                                                                                                 \
00649                                                                                                                                 \
00650   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00651     {                                                                                                                           \
00652     _alpha[_idx] =  static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]);                                     \
00653     if ( _alpha[_idx] )                                                                                                         \
00654       {                                                                                                                         \
00655       _alpha[_idx] = static_cast<unsigned short>((_alpha[_idx]*GOTABLE[_idx][MAG[_idx]] + 0x7fff)>>(VTKKW_FP_SHIFT));           \
00656       _totalAlpha += _alpha[_idx];                                                                                              \
00657       }                                                                                                                         \
00658     }}                                                                                                                          \
00659                                                                                                                                 \
00660   if ( !_totalAlpha ) {continue;}                                                                                               \
00661   {for ( int _idx = 0; _idx < COMPONENTS; _idx++ )                                                                              \
00662     {                                                                                                                           \
00663     if ( _alpha[_idx] )                                                                                                         \
00664       {                                                                                                                         \
00665       _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]  ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00666       _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00667       _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT));   \
00668       _tmpC[3] = _alpha[_idx];                                                                                                  \
00669       VTKKWRCHelper_InterpolateShadingComponent( DTABLE, STABLE, _tmpC, _idx );                                                 \
00670       _tmp[0] += _tmpC[0];                                                                                                      \
00671       _tmp[1] += _tmpC[1];                                                                                                      \
00672       _tmp[2] += _tmpC[2];                                                                                                      \
00673       _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha);                                                                     \
00674       }                                                                                                                         \
00675     }}                                                                                                                           \
00676   if ( !_tmp[3] ) {continue;}                                                                                                   \
00677   COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]);                                                                                 \
00678   COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]);                                                                                 \
00679   COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]);                                                                                 \
00680   COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
00681 //ETX
00682 
00683 
00684 //BTX
00685 #define VTKKWRCHelper_SetPixelColor( IMAGEPTR, COLOR, REMAININGOPACITY )        \
00686   IMAGEPTR[0] = (COLOR[0]>32767)?(32767):(COLOR[0]);                            \
00687   IMAGEPTR[1] = (COLOR[1]>32767)?(32767):(COLOR[1]);                            \
00688   IMAGEPTR[2] = (COLOR[2]>32767)?(32767):(COLOR[2]);                           \
00689   unsigned int tmpAlpha = (~REMAININGOPACITY)&VTKKW_FP_MASK;                    \
00690   IMAGEPTR[3] = (tmpAlpha>32767)?(32767):(tmpAlpha);
00691 //ETX
00692 
00693 //BTX
00694 #define VTKKWRCHelper_MoveToNextSampleNN()                                      \
00695   if ( k < numSteps-1 )                                                         \
00696     {                                                                           \
00697     mapper->FixedPointIncrement( pos, dir );                                    \
00698     mapper->ShiftVectorDown( pos, spos );                                       \
00699     dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];            \
00700     }
00701 //ETX
00702 
00703 //BTX
00704 #define VTKKWRCHelper_MoveToNextSampleGONN()                            \
00705   if ( k < numSteps-1 )                                                 \
00706     {                                                                   \
00707     mapper->FixedPointIncrement( pos, dir );                            \
00708     mapper->ShiftVectorDown( pos, spos );                               \
00709     dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];    \
00710     magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1];  \
00711     }
00712 //ETX
00713 
00714 //BTX
00715 #define VTKKWRCHelper_MoveToNextSampleShadeNN()                         \
00716   if ( k < numSteps-1 )                                                 \
00717     {                                                                   \
00718     mapper->FixedPointIncrement( pos, dir );                            \
00719     mapper->ShiftVectorDown( pos, spos );                               \
00720     dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];    \
00721     dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1];  \
00722     }
00723 //ETX
00724 
00725 //BTX
00726 #define VTKKWRCHelper_MoveToNextSampleGOShadeNN()                       \
00727   if ( k < numSteps-1 )                                                 \
00728     {                                                                   \
00729     mapper->FixedPointIncrement( pos, dir );                            \
00730     mapper->ShiftVectorDown( pos, spos );                               \
00731     dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];    \
00732     magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1];  \
00733     dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1];  \
00734     }
00735 //ETX
00736 
00737 //BTX
00738 #define VTKKWRCHelper_InitializeVariables()                                                     \
00739   int i, j;                                                                                     \
00740   unsigned short *imagePtr;                                                                     \
00741                                                                                                 \
00742   int imageInUseSize[2];                                                                        \
00743   int imageMemorySize[2];                                                                       \
00744   int imageViewportSize[2];                                                                     \
00745   int imageOrigin[2];                                                                           \
00746   int dim[3];                                                                                   \
00747   float shift[4];                                                                               \
00748   float scale[4];                                                                               \
00749                                                                                                 \
00750   mapper->GetRayCastImage()->GetImageInUseSize(imageInUseSize);                                 \
00751   mapper->GetRayCastImage()->GetImageMemorySize(imageMemorySize);                               \
00752   mapper->GetRayCastImage()->GetImageViewportSize(imageViewportSize);                           \
00753   mapper->GetRayCastImage()->GetImageOrigin(imageOrigin);                                       \
00754   mapper->GetInput()->GetDimensions(dim);                                                       \
00755   mapper->GetTableShift( shift );                                                               \
00756   mapper->GetTableScale( scale );                                                               \
00757                                                                                                 \
00758   int *rowBounds                     = mapper->GetRowBounds();                                  \
00759   unsigned short *image              = mapper->GetRayCastImage()->GetImage();                   \
00760   vtkRenderWindow *renWin            = mapper->GetRenderWindow();                               \
00761   int components                     = mapper->GetInput()->GetNumberOfScalarComponents();       \
00762   int cropping                       = (mapper->GetCropping() &&                                \
00763                                         mapper->GetCroppingRegionFlags() != 0x2000 );           \
00764                                                                                                 \
00765   unsigned short *colorTable[4];                                                                \
00766   unsigned short *scalarOpacityTable[4];                                                        \
00767                                                                                                 \
00768   int c;                                                                                        \
00769   for ( c = 0; c < 4; c++ )                                                                     \
00770     {                                                                                           \
00771     colorTable[c]         = mapper->GetColorTable(c);                                           \
00772     (void)(colorTable[c]);                                                                      \
00773     scalarOpacityTable[c] = mapper->GetScalarOpacityTable(c);                                   \
00774     }                                                                                           \
00775                                                                                                 \
00776   unsigned int inc[3];                                                                          \
00777   inc[0] = components;                                                                          \
00778   inc[1] = dim[0]*components;                                                                   \
00779   inc[2] = dim[0]*dim[1]*components;
00780 //ETX
00781 
00782 //BTX
00783 #define VTKKWRCHelper_InitializeWeights()                       \
00784   float weights[4];                                             \
00785   weights[0] = vol->GetProperty()->GetComponentWeight(0);       \
00786   weights[1] = vol->GetProperty()->GetComponentWeight(1);       \
00787   weights[2] = vol->GetProperty()->GetComponentWeight(2);       \
00788   weights[3] = vol->GetProperty()->GetComponentWeight(3);
00789 //ETX
00790 
00791 //BTX
00792 #define VTKKWRCHelper_InitializeVariablesGO()                           \
00793   unsigned short *gradientOpacityTable[4];                              \
00794   for ( c = 0; c < 4; c++ )                                             \
00795     {                                                                   \
00796     gradientOpacityTable[c] = mapper->GetGradientOpacityTable(c);       \
00797     }                                                                   \
00798   unsigned char **gradientMag = mapper->GetGradientMagnitude();         \
00799                                                                         \
00800   unsigned int mInc[3];                                                 \
00801   if ( vol->GetProperty()->GetIndependentComponents() )                 \
00802     {                                                                   \
00803     mInc[0] = inc[0];                                                   \
00804     mInc[1] = inc[1];                                                   \
00805     mInc[2] = inc[2];                                                   \
00806     }                                                                   \
00807   else                                                                  \
00808     {                                                                   \
00809     mInc[0] = 1;                                                        \
00810     mInc[1] = dim[0];                                                   \
00811     mInc[2] = dim[0]*dim[1];                                            \
00812     }
00813 //ETX
00814 
00815 //BTX
00816 #define VTKKWRCHelper_InitializeVariablesShade()                        \
00817   unsigned short *diffuseShadingTable[4];                               \
00818   unsigned short *specularShadingTable[4];                              \
00819   for ( c = 0; c < 4; c++ )                                             \
00820     {                                                                   \
00821     diffuseShadingTable[c] = mapper->GetDiffuseShadingTable(c);         \
00822     specularShadingTable[c] = mapper->GetSpecularShadingTable(c);       \
00823     }                                                                   \
00824   unsigned short **gradientDir = mapper->GetGradientNormal();           \
00825   unsigned int dInc[3];                                                 \
00826   if ( vol->GetProperty()->GetIndependentComponents() )                 \
00827     {                                                                   \
00828     dInc[0] = inc[0];                                                   \
00829     dInc[1] = inc[1];                                                   \
00830     dInc[2] = inc[2];                                                   \
00831     }                                                                   \
00832   else                                                                  \
00833     {                                                                   \
00834     dInc[0] = 1;                                                        \
00835     dInc[1] = dim[0];                                                   \
00836     dInc[2] = dim[0]*dim[1];                                            \
00837     }
00838 //ETX
00839 
00840 //BTX
00841 #define VTKKWRCHelper_InitializeTrilinVariables()                                       \
00842   unsigned int Binc =                                                components;        \
00843   unsigned int Cinc =                            dim[0]*components;                     \
00844   unsigned int Dinc =                            dim[0]*components + components;        \
00845   unsigned int Einc = dim[0]*dim[1]*components;                                         \
00846   unsigned int Finc = dim[0]*dim[1]*components                     + components;        \
00847   unsigned int Ginc = dim[0]*dim[1]*components + dim[0]*components;                     \
00848   unsigned int Hinc = dim[0]*dim[1]*components + dim[0]*components + components;
00849 //ETX
00850 
00851 //BTX
00852 #define VTKKWRCHelper_InitializeTrilinVariablesGO()             \
00853   int magOffset;                                                \
00854   if (  vol->GetProperty()->GetIndependentComponents() )        \
00855     {                                                           \
00856     magOffset = components;                                     \
00857     }                                                           \
00858   else                                                          \
00859     {                                                           \
00860     magOffset = 1;                                              \
00861     }                                                           \
00862                                                                 \
00863   unsigned int mBFinc =                    magOffset;           \
00864   unsigned int mCGinc = dim[0]*magOffset;                       \
00865   unsigned int mDHinc = dim[0]*magOffset + magOffset;
00866 //ETX
00867 
00868 //BTX
00869 #define VTKKWRCHelper_InitializeTrilinVariablesShade()          \
00870   int dirOffset;                                                \
00871   if (  vol->GetProperty()->GetIndependentComponents() )        \
00872     {                                                           \
00873     dirOffset = components;                                     \
00874     }                                                           \
00875   else                                                          \
00876     {                                                           \
00877     dirOffset = 1;                                              \
00878     }                                                           \
00879                                                                 \
00880   unsigned int dBFinc =                    dirOffset;           \
00881   unsigned int dCGinc = dim[0]*dirOffset;                       \
00882   unsigned int dDHinc = dim[0]*dirOffset + dirOffset;
00883 //ETX
00884 
00885 //BTX
00886 #define VTKKWRCHelper_OuterInitialization()                             \
00887     if ( j%threadCount != threadID )                                    \
00888       {                                                                 \
00889       continue;                                                         \
00890       }                                                                 \
00891      if ( !threadID )                                                   \
00892       {                                                                 \
00893       if ( renWin->CheckAbortStatus() )                                 \
00894         {                                                               \
00895         break;                                                          \
00896         }                                                               \
00897       }                                                                 \
00898     else if ( renWin->GetAbortRender() )                                \
00899       {                                                                 \
00900       break;                                                            \
00901       }                                                                 \
00902     imagePtr = image + 4*(j*imageMemorySize[0] + rowBounds[j*2]);   
00903 
00904 //ETX
00905 
00906 //BTX
00907 #define VTKKWRCHelper_InnerInitialization()             \
00908   unsigned int   numSteps;                              \
00909   unsigned int   pos[3];                                \
00910   unsigned int   dir[3];                                \
00911   mapper->ComputeRayInfo( i, j, pos, dir, &numSteps );  \
00912   if ( numSteps == 0 )                                  \
00913     {                                                   \
00914     *(imagePtr  ) = 0;                                  \
00915     *(imagePtr+1) = 0;                                  \
00916     *(imagePtr+2) = 0;                                  \
00917     *(imagePtr+3) = 0;                                  \
00918     imagePtr += 4;                                      \
00919     continue;                                           \
00920     }                                                   \
00921   unsigned int   spos[3];                               \
00922   unsigned int   k;
00923 //ETX
00924 
00925 //BTX
00926 #define VTKKWRCHelper_InitializeMIPOneNN()                              \
00927   mapper->ShiftVectorDown( pos, spos );                                 \
00928   T *dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];   \
00929   T maxValue = *(dptr);
00930 //ETX
00931 
00932 //BTX
00933 #define VTKKWRCHelper_InitializeMIPMultiNN()                            \
00934   mapper->ShiftVectorDown( pos, spos );                                 \
00935   T *dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];   \
00936   T maxValue[4];                                                        \
00937   for ( c = 0; c < components; c++ )                                    \
00938     {                                                                   \
00939     maxValue[c] = *(dptr+c);                                            \
00940     }
00941 //ETX
00942 
00943 //BTX
00944 #define VTKKWRCHelper_InitializeMIPOneTrilin()          \
00945   T *dptr;                                              \
00946   unsigned int oldSPos[3];                              \
00947                                                         \
00948   oldSPos[1] = oldSPos[2] = 0;                          \
00949   oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1;          \
00950                                                         \
00951   unsigned int w1X, w1Y, w1Z;                           \
00952   unsigned int w2X, w2Y, w2Z;                           \
00953   unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y;          \
00954                                                         \
00955   unsigned short  maxValue=0;                           \
00956   unsigned short  val;                                  \
00957   unsigned int    A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;
00958 //ETX
00959 
00960 //BTX
00961 #define VTKKWRCHelper_InitializeMIPMultiTrilin()                \
00962   T *dptr;                                                      \
00963   unsigned int oldSPos[3];                                      \
00964                                                                 \
00965   oldSPos[1] = oldSPos[2] = 0;                                  \
00966   oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1;                  \
00967                                                                 \
00968   unsigned int w1X, w1Y, w1Z;                                   \
00969   unsigned int w2X, w2Y, w2Z;                                   \
00970   unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y;                  \
00971                                                                 \
00972   unsigned short  maxValue[4];                                  \
00973   unsigned short  val[4];                                       \
00974   unsigned int    A[4],B[4],C[4],D[4],E[4],F[4],G[4],H[4];
00975 //ETX
00976 
00977 //BTX
00978 #define VTKKWRCHelper_InitializeCompositeGONN()                                      \
00979   unsigned char *magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1];
00980 //ETX
00981 
00982 //BTX
00983 #define VTKKWRCHelper_InitializeCompositeShadeNN()                                      \
00984   unsigned short *dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1];
00985 //ETX
00986 
00987 //BTX
00988 #define VTKKWRCHelper_InitializeCompositeOneNN()                        \
00989   mapper->ShiftVectorDown( pos, spos );                                 \
00990   T *dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];   \
00991   unsigned int color[3] = {0,0,0};                                      \
00992   unsigned short remainingOpacity = 0x7fff;                             \
00993   unsigned short tmp[4];
00994 //ETX
00995 
00996 //BTX
00997 #define VTKKWRCHelper_InitializeCompositeMultiNN()                      \
00998   mapper->ShiftVectorDown( pos, spos );                                 \
00999   T *dptr = data +  spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2];   \
01000   unsigned int color[3] = {0,0,0};                                      \
01001   unsigned int remainingOpacity = 0x7fff;                               \
01002   unsigned short tmp[4];                                                \
01003   unsigned short val[4];
01004 //ETX
01005 
01006 //BTX
01007 #define VTKKWRCHelper_InitializeCompositeOneTrilin()    \
01008   T *dptr;                                              \
01009   unsigned int oldSPos[3];                              \
01010                                                         \
01011   oldSPos[1] = oldSPos[2] = 0;                          \
01012   oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1;          \
01013                                                         \
01014   unsigned int w1X, w1Y, w1Z;                           \
01015   unsigned int w2X, w2Y, w2Z;                           \
01016   unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y;          \
01017                                                         \
01018   unsigned short  val;                                  \
01019   unsigned int    A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;      \
01020                                                         \
01021   unsigned int color[3] = {0,0,0};                      \
01022   unsigned short remainingOpacity = 0x7fff;             \
01023   unsigned short tmp[4];
01024 //ETX
01025 
01026 //BTX
01027 #define VTKKWRCHelper_InitializeCompositeOneGOTrilin()          \
01028   unsigned char  *magPtrABCD = 0, *magPtrEFGH = 0;              \
01029   unsigned short  mag;                                          \
01030   unsigned int    mA=0,mB=0,mC=0,mD=0,mE=0,mF=0,mG=0,mH=0;
01031 //ETX
01032 
01033 //BTX
01034 #define VTKKWRCHelper_InitializeCompositeOneShadeTrilin()       \
01035   unsigned short *dirPtrABCD = 0, *dirPtrEFGH = 0;              \
01036   unsigned int    normalA=0,normalB=0,normalC=0,normalD=0;      \
01037   unsigned int    normalE=0,normalF=0,normalG=0,normalH=0;
01038 //ETX
01039 
01040 //BTX
01041 #define VTKKWRCHelper_InitializeCompositeMultiTrilin()          \
01042   T *dptr;                                                      \
01043   unsigned int oldSPos[3];                                      \
01044                                                                 \
01045   oldSPos[1] = oldSPos[2] = 0;                                  \
01046   oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1;                  \
01047                                                                 \
01048   unsigned int w1X, w1Y, w1Z;                                   \
01049   unsigned int w2X, w2Y, w2Z;                                   \
01050   unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y;                  \
01051                                                                 \
01052   unsigned short  val[4];                                       \
01053   unsigned int    A[4],B[4],C[4],D[4],E[4],F[4],G[4],H[4];      \
01054                                                                 \
01055   unsigned int color[3] = {0,0,0};                              \
01056   unsigned short remainingOpacity = 0x7fff;                     \
01057   unsigned short tmp[4];
01058 
01059 //ETX
01060 
01061 //BTX
01062 #define VTKKWRCHelper_InitializeCompositeMultiGOTrilin()                \
01063   unsigned char  *magPtrABCD = 0, *magPtrEFGH = 0;                      \
01064   unsigned short  mag[4];                                               \
01065   unsigned int    mA[4],mB[4],mC[4],mD[4],mE[4],mF[4],mG[4],mH[4];
01066 //ETX
01067 
01068 //BTX
01069 #define VTKKWRCHelper_InitializeCompositeMultiShadeTrilin()     \
01070   unsigned short *dirPtrABCD = 0, *dirPtrEFGH = 0;              \
01071   unsigned int    normalA[4],normalB[4],normalC[4],normalD[4];  \
01072   unsigned int    normalE[4],normalF[4],normalG[4],normalH[4];
01073 //ETX
01074 
01075 //BTX
01076 #define VTKKWRCHelper_InitializationAndLoopStartNN()            \
01077   VTKKWRCHelper_InitializeVariables();                          \
01078   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01079     {                                                           \
01080     VTKKWRCHelper_OuterInitialization();                        \
01081     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01082       {                                                         \
01083       VTKKWRCHelper_InnerInitialization();
01084 //ETX
01085 
01086 //BTX
01087 #define VTKKWRCHelper_InitializationAndLoopStartGONN()          \
01088   VTKKWRCHelper_InitializeVariables();                          \
01089   VTKKWRCHelper_InitializeVariablesGO();                        \
01090   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01091     {                                                           \
01092     VTKKWRCHelper_OuterInitialization();                        \
01093     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01094       {                                                         \
01095       VTKKWRCHelper_InnerInitialization();
01096 //ETX
01097 
01098 //BTX
01099 #define VTKKWRCHelper_InitializationAndLoopStartShadeNN()       \
01100   VTKKWRCHelper_InitializeVariables();                          \
01101   VTKKWRCHelper_InitializeVariablesShade();                     \
01102   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01103     {                                                           \
01104     VTKKWRCHelper_OuterInitialization();                        \
01105     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01106       {                                                         \
01107       VTKKWRCHelper_InnerInitialization();
01108 //ETX
01109 
01110 //BTX
01111 #define VTKKWRCHelper_InitializationAndLoopStartGOShadeNN()     \
01112   VTKKWRCHelper_InitializeVariables();                          \
01113   VTKKWRCHelper_InitializeVariablesGO();                        \
01114   VTKKWRCHelper_InitializeVariablesShade();                     \
01115   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01116     {                                                           \
01117     VTKKWRCHelper_OuterInitialization();                        \
01118     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01119       {                                                         \
01120       VTKKWRCHelper_InnerInitialization();
01121 //ETX
01122 
01123 //BTX
01124 #define VTKKWRCHelper_InitializationAndLoopStartTrilin()        \
01125   VTKKWRCHelper_InitializeVariables();                          \
01126   VTKKWRCHelper_InitializeTrilinVariables();                    \
01127   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01128     {                                                           \
01129     VTKKWRCHelper_OuterInitialization();                        \
01130     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01131       {                                                         \
01132       VTKKWRCHelper_InnerInitialization();
01133 //ETX
01134 
01135 //BTX
01136 #define VTKKWRCHelper_InitializationAndLoopStartGOTrilin()      \
01137   VTKKWRCHelper_InitializeVariables();                          \
01138   VTKKWRCHelper_InitializeVariablesGO();                        \
01139   VTKKWRCHelper_InitializeTrilinVariables();                    \
01140   VTKKWRCHelper_InitializeTrilinVariablesGO();                  \
01141   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01142     {                                                           \
01143     VTKKWRCHelper_OuterInitialization();                        \
01144     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01145       {                                                         \
01146       VTKKWRCHelper_InnerInitialization();
01147 //ETX
01148 
01149 //BTX
01150 #define VTKKWRCHelper_InitializationAndLoopStartShadeTrilin()   \
01151   VTKKWRCHelper_InitializeVariables();                          \
01152   VTKKWRCHelper_InitializeVariablesShade();                     \
01153   VTKKWRCHelper_InitializeTrilinVariables();                    \
01154   VTKKWRCHelper_InitializeTrilinVariablesShade();               \
01155   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01156     {                                                           \
01157     VTKKWRCHelper_OuterInitialization();                        \
01158     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01159       {                                                         \
01160       VTKKWRCHelper_InnerInitialization();
01161 //ETX
01162 
01163 //BTX
01164 #define VTKKWRCHelper_InitializationAndLoopStartGOShadeTrilin() \
01165   VTKKWRCHelper_InitializeVariables();                          \
01166   VTKKWRCHelper_InitializeVariablesShade();                     \
01167   VTKKWRCHelper_InitializeVariablesGO();                        \
01168   VTKKWRCHelper_InitializeTrilinVariables();                    \
01169   VTKKWRCHelper_InitializeTrilinVariablesShade();               \
01170   VTKKWRCHelper_InitializeTrilinVariablesGO();                  \
01171   for ( j = 0; j < imageInUseSize[1]; j++ )                     \
01172     {                                                           \
01173     VTKKWRCHelper_OuterInitialization();                        \
01174     for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ )      \
01175       {                                                         \
01176       VTKKWRCHelper_InnerInitialization();
01177 //ETX
01178 
01179 //BTX
01180 #define VTKKWRCHelper_IncrementAndLoopEnd()                                     \
01181       imagePtr+=4;                                                              \
01182       }                                                                         \
01183     if ( j%32 == 0 && threadID==0 )                                                           \
01184       {                                                                         \
01185       float fargs[1];                                                           \
01186       fargs[0] = static_cast<float>(j)/static_cast<float>(imageInUseSize[1]-1); \
01187       mapper->InvokeEvent( vtkCommand::ProgressEvent, fargs );                  \
01188       }                                                                         \
01189     }
01190 //ETX
01191 
01192 //BTX
01193 #define VTKKWRCHelper_CroppingCheckTrilin( POS )        \
01194   if ( cropping )                                       \
01195     {                                                   \
01196     if ( mapper->CheckIfCropped( POS ) )                \
01197       {                                                 \
01198       continue;                                         \
01199       }                                                 \
01200     }
01201 //ETX
01202 
01203 //BTX
01204 #define VTKKWRCHelper_CroppingCheckNN( POS )            \
01205   if ( cropping )                                       \
01206     {                                                   \
01207     if ( mapper->CheckIfCropped( POS ) )                \
01208       {                                                 \
01209       continue;                                         \
01210       }                                                 \
01211     }
01212 //ETX
01213 
01214 //BTX
01215 #define VTKKWRCHelper_SpaceLeapSetup()          \
01216   unsigned int mmpos[3];                        \
01217   mmpos[0] = (pos[0] >> VTKKW_FPMM_SHIFT) + 1;  \
01218   mmpos[1] = 0;                                 \
01219   mmpos[2] = 0;                                 \
01220   int mmvalid = 0;
01221 //ETX
01222 
01223 //BTX
01224 #define VTKKWRCHelper_SpaceLeapSetupMulti()     \
01225   unsigned int mmpos[3];                        \
01226   mmpos[0] = (pos[0] >> VTKKW_FPMM_SHIFT) + 1;  \
01227   mmpos[1] = 0;                                 \
01228   mmpos[2] = 0;                                 \
01229   int mmvalid[4] = {0,0,0,0};
01230 //ETX
01231 
01232 
01233 //BTX 
01234 #define VTKKWRCHelper_SpaceLeapCheck()                          \
01235   if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] ||                \
01236        pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] ||                \
01237        pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] )                 \
01238     {                                                           \
01239     mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT;                      \
01240     mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT;                      \
01241     mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT;                      \
01242     mmvalid = mapper->CheckMinMaxVolumeFlag( mmpos, 0 );        \
01243     }                                                           \
01244                                                                 \
01245   if ( !mmvalid )                                               \
01246     {                                                           \
01247     continue;                                                   \
01248     }
01249 //ETX
01250 
01251 //BTX 
01252 #define VTKKWRCHelper_MIPSpaceLeapCheck( MAXIDX, MAXIDXDEF )            \
01253   if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] ||                        \
01254        pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] ||                        \
01255        pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] )                         \
01256     {                                                                   \
01257     mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT;                              \
01258     mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT;                              \
01259     mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT;                              \
01260     mmvalid = (MAXIDXDEF)?                                              \
01261      (mapper->CheckMIPMinMaxVolumeFlag( mmpos, 0, MAXIDX )):(1);        \
01262     }                                                                   \
01263                                                                         \
01264   if ( !mmvalid )                                                       \
01265     {                                                                   \
01266     continue;                                                           \
01267     }
01268 //ETX
01269 
01270 
01271 //BTX 
01272 #define VTKKWRCHelper_MIPSpaceLeapPopulateMulti( MAXIDX )                       \
01273   if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] ||                                \
01274        pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] ||                                \
01275        pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] )                                 \
01276     {                                                                           \
01277     mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT;                                      \
01278     mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT;                                      \
01279     mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT;                                      \
01280     for ( c = 0; c < components; c++ )                                          \
01281       {                                                                         \
01282       mmvalid[c] = mapper->CheckMIPMinMaxVolumeFlag( mmpos, c, MAXIDX[c] );     \
01283       }                                                                         \
01284     }
01285 //ETX
01286 
01287 //BTX 
01288 #define VTKKWRCHelper_MIPSpaceLeapCheckMulti( COMP )  mmvalid[COMP]
01289 //ETX
01290 
01291 #include "vtkObject.h"
01292 #include "vtkVolumeRenderingReplacements.h"
01293 
01294 class vtkSlicerFixedPointVolumeRayCastMapper;
01295 class vtkVolume;
01296 
01297 class VTK_VOLUMERENDERINGREPLACEMENTS_EXPORT vtkSlicerFixedPointVolumeRayCastHelper : public vtkObject
01298 {
01299 public:
01300   static vtkSlicerFixedPointVolumeRayCastHelper *New();
01301   vtkTypeRevisionMacro(vtkSlicerFixedPointVolumeRayCastHelper,vtkObject);
01302   void PrintSelf( ostream& os, vtkIndent indent );
01303 
01304   virtual void   GenerateImage( int, 
01305                                 int,
01306                                 vtkVolume *,
01307                                 vtkSlicerFixedPointVolumeRayCastMapper *) {}
01308   
01309 protected:
01310   vtkSlicerFixedPointVolumeRayCastHelper();
01311   ~vtkSlicerFixedPointVolumeRayCastHelper();
01312   
01313 
01314 
01315 private:
01316   vtkSlicerFixedPointVolumeRayCastHelper(const vtkSlicerFixedPointVolumeRayCastHelper&);  // Not implemented.
01317   void operator=(const vtkSlicerFixedPointVolumeRayCastHelper&);  // Not implemented.
01318 };
01319 
01320 #endif
01321 
01322 
01323 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1