Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkFixedPointVolumeRayCastHelper.h

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

Generated on Mon Jan 21 23:07:37 2008 for VTK by  doxygen 1.4.3-20050530