VTK
vtkFixedPointVolumeRayCastHelper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFixedPointVolumeRayCastHelper.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef vtkFixedPointVolumeRayCastHelper_h
27 #define vtkFixedPointVolumeRayCastHelper_h
28 
29 #define VTKKWRCHelper_GetCellScalarValues( DATA, SCALE, SHIFT ) \
30  A = static_cast<unsigned int >(SCALE*(*(DATA ) + SHIFT)); \
31  B = static_cast<unsigned int >(SCALE*(*(DATA+Binc) + SHIFT)); \
32  C = static_cast<unsigned int >(SCALE*(*(DATA+Cinc) + SHIFT)); \
33  D = static_cast<unsigned int >(SCALE*(*(DATA+Dinc) + SHIFT)); \
34  E = static_cast<unsigned int >(SCALE*(*(DATA+Einc) + SHIFT)); \
35  F = static_cast<unsigned int >(SCALE*(*(DATA+Finc) + SHIFT)); \
36  G = static_cast<unsigned int >(SCALE*(*(DATA+Ginc) + SHIFT)); \
37  H = static_cast<unsigned int >(SCALE*(*(DATA+Hinc) + SHIFT))
38 
39 #define VTKKWRCHelper_GetCellScalarValuesSimple( DATA ) \
40  A = static_cast<unsigned int >(*(DATA )); \
41  B = static_cast<unsigned int >(*(DATA+Binc)); \
42  C = static_cast<unsigned int >(*(DATA+Cinc)); \
43  D = static_cast<unsigned int >(*(DATA+Dinc)); \
44  E = static_cast<unsigned int >(*(DATA+Einc)); \
45  F = static_cast<unsigned int >(*(DATA+Finc)); \
46  G = static_cast<unsigned int >(*(DATA+Ginc)); \
47  H = static_cast<unsigned int >(*(DATA+Hinc))
48 
49 #define VTKKWRCHelper_GetCellMagnitudeValues( ABCD, EFGH ) \
50  mA = static_cast<unsigned int >(*(ABCD )); \
51  mB = static_cast<unsigned int >(*(ABCD+mBFinc)); \
52  mC = static_cast<unsigned int >(*(ABCD+mCGinc)); \
53  mD = static_cast<unsigned int >(*(ABCD+mDHinc)); \
54  mE = static_cast<unsigned int >(*(EFGH )); \
55  mF = static_cast<unsigned int >(*(EFGH+mBFinc)); \
56  mG = static_cast<unsigned int >(*(EFGH+mCGinc)); \
57  mH = static_cast<unsigned int >(*(EFGH+mDHinc))
58 
59 #define VTKKWRCHelper_GetCellDirectionValues( ABCD, EFGH ) \
60  normalA = static_cast<unsigned int >(*(ABCD )); \
61  normalB = static_cast<unsigned int >(*(ABCD+dBFinc)); \
62  normalC = static_cast<unsigned int >(*(ABCD+dCGinc)); \
63  normalD = static_cast<unsigned int >(*(ABCD+dDHinc)); \
64  normalE = static_cast<unsigned int >(*(EFGH )); \
65  normalF = static_cast<unsigned int >(*(EFGH+dBFinc)); \
66  normalG = static_cast<unsigned int >(*(EFGH+dCGinc)); \
67  normalH = static_cast<unsigned int >(*(EFGH+dDHinc));
68 
69 #define VTKKWRCHelper_GetCellComponentScalarValues( DATA, CIDX, SCALE, SHIFT ) \
70  A[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA ) + SHIFT)); \
71  B[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Binc) + SHIFT)); \
72  C[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Cinc) + SHIFT)); \
73  D[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Dinc) + SHIFT)); \
74  E[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Einc) + SHIFT)); \
75  F[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Finc) + SHIFT)); \
76  G[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Ginc) + SHIFT)); \
77  H[CIDX] = static_cast<unsigned int >(SCALE*(*(DATA+Hinc) + SHIFT))
78 
79 #define VTKKWRCHelper_GetCellComponentRawScalarValues( DATA, CIDX ) \
80  A[CIDX] = static_cast<unsigned int >((*(DATA ))); \
81  B[CIDX] = static_cast<unsigned int >((*(DATA+Binc))); \
82  C[CIDX] = static_cast<unsigned int >((*(DATA+Cinc))); \
83  D[CIDX] = static_cast<unsigned int >((*(DATA+Dinc))); \
84  E[CIDX] = static_cast<unsigned int >((*(DATA+Einc))); \
85  F[CIDX] = static_cast<unsigned int >((*(DATA+Finc))); \
86  G[CIDX] = static_cast<unsigned int >((*(DATA+Ginc))); \
87  H[CIDX] = static_cast<unsigned int >((*(DATA+Hinc)))
88 
89 #define VTKKWRCHelper_GetCellComponentMagnitudeValues( ABCD, EFGH, CIDX ) \
90  mA[CIDX] = static_cast<unsigned int >(*(ABCD )); \
91  mB[CIDX] = static_cast<unsigned int >(*(ABCD+mBFinc)); \
92  mC[CIDX] = static_cast<unsigned int >(*(ABCD+mCGinc)); \
93  mD[CIDX] = static_cast<unsigned int >(*(ABCD+mDHinc)); \
94  mE[CIDX] = static_cast<unsigned int >(*(EFGH )); \
95  mF[CIDX] = static_cast<unsigned int >(*(EFGH+mBFinc)); \
96  mG[CIDX] = static_cast<unsigned int >(*(EFGH+mCGinc)); \
97  mH[CIDX] = static_cast<unsigned int >(*(EFGH+mDHinc))
98 
99 #define VTKKWRCHelper_GetCellComponentDirectionValues( ABCD, EFGH, CIDX ) \
100  normalA[CIDX] = static_cast<unsigned int >(*(ABCD )); \
101  normalB[CIDX] = static_cast<unsigned int >(*(ABCD+dBFinc)); \
102  normalC[CIDX] = static_cast<unsigned int >(*(ABCD+dCGinc)); \
103  normalD[CIDX] = static_cast<unsigned int >(*(ABCD+dDHinc)); \
104  normalE[CIDX] = static_cast<unsigned int >(*(EFGH )); \
105  normalF[CIDX] = static_cast<unsigned int >(*(EFGH+dBFinc)); \
106  normalG[CIDX] = static_cast<unsigned int >(*(EFGH+dCGinc)); \
107  normalH[CIDX] = static_cast<unsigned int >(*(EFGH+dDHinc));
108 
109 #define VTKKWRCHelper_ComputeWeights( POS ) \
110  w2X = (POS[0]&VTKKW_FP_MASK); \
111  w2Y = (POS[1]&VTKKW_FP_MASK); \
112  w2Z = (POS[2]&VTKKW_FP_MASK); \
113  \
114  w1X = ((~w2X)&VTKKW_FP_MASK); \
115  w1Y = ((~w2Y)&VTKKW_FP_MASK); \
116  w1Z = ((~w2Z)&VTKKW_FP_MASK); \
117  \
118  w1Xw1Y = (0x4000+(w1X*w1Y))>>VTKKW_FP_SHIFT; \
119  w2Xw1Y = (0x4000+(w2X*w1Y))>>VTKKW_FP_SHIFT; \
120  w1Xw2Y = (0x4000+(w1X*w2Y))>>VTKKW_FP_SHIFT; \
121  w2Xw2Y = (0x4000+(w2X*w2Y))>>VTKKW_FP_SHIFT; \
122 
123 #define VTKKWRCHelper_InterpolateScalar( VAL ) \
124  VAL = \
125  (0x7fff + ((A*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
126  (B*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
127  (C*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
128  (D*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
129  (E*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
130  (F*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
131  (G*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
132  (H*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;
133 
134 #define VTKKWRCHelper_InterpolateMagnitude( VAL ) \
135  VAL = \
136  (0x7fff + ((mA*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
137  (mB*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
138  (mC*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
139  (mD*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
140  (mE*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
141  (mF*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
142  (mG*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
143  (mH*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT;
144 
145 #define VTKKWRCHelper_InterpolateScalarComponent( VAL, CIDX, COMPONENTS ) \
146  for ( CIDX = 0; CIDX < COMPONENTS; CIDX++ ) \
147  { \
148  VAL[CIDX] = \
149  (0x7fff + ((A[CIDX]*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
150  (B[CIDX]*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
151  (C[CIDX]*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
152  (D[CIDX]*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
153  (E[CIDX]*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
154  (F[CIDX]*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
155  (G[CIDX]*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
156  (H[CIDX]*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
157  } \
158 
159 #define VTKKWRCHelper_InterpolateMagnitudeComponent( VAL, CIDX, COMPONENTS ) \
160  for ( CIDX = 0; CIDX < COMPONENTS; CIDX++ ) \
161  { \
162  VAL[CIDX] = \
163  (0x7fff + ((mA[CIDX]*((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
164  (mB[CIDX]*((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
165  (mC[CIDX]*((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
166  (mD[CIDX]*((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
167  (mE[CIDX]*((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
168  (mF[CIDX]*((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
169  (mG[CIDX]*((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
170  (mH[CIDX]*((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
171  }
172 
173 #define VTKKWRCHelper_InterpolateShading( DTABLE, STABLE, COLOR ) \
174  unsigned int _tmpDColor[3]; \
175  unsigned int _tmpSColor[3]; \
176  \
177  _tmpDColor[0] = \
178  (0x7fff + ((DTABLE[3*normalA] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
179  (DTABLE[3*normalB] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
180  (DTABLE[3*normalC] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
181  (DTABLE[3*normalD] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
182  (DTABLE[3*normalE] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
183  (DTABLE[3*normalF] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
184  (DTABLE[3*normalG] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
185  (DTABLE[3*normalH] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
186  \
187  _tmpDColor[1] = \
188  (0x7fff + ((DTABLE[3*normalA+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
189  (DTABLE[3*normalB+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
190  (DTABLE[3*normalC+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
191  (DTABLE[3*normalD+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
192  (DTABLE[3*normalE+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
193  (DTABLE[3*normalF+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
194  (DTABLE[3*normalG+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
195  (DTABLE[3*normalH+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
196  \
197  _tmpDColor[2] = \
198  (0x7fff + ((DTABLE[3*normalA+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
199  (DTABLE[3*normalB+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
200  (DTABLE[3*normalC+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
201  (DTABLE[3*normalD+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
202  (DTABLE[3*normalE+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
203  (DTABLE[3*normalF+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
204  (DTABLE[3*normalG+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
205  (DTABLE[3*normalH+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
206  \
207  _tmpSColor[0] = \
208  (0x7fff + ((STABLE[3*normalA] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
209  (STABLE[3*normalB] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
210  (STABLE[3*normalC] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
211  (STABLE[3*normalD] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
212  (STABLE[3*normalE] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
213  (STABLE[3*normalF] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
214  (STABLE[3*normalG] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
215  (STABLE[3*normalH] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
216  \
217  _tmpSColor[1] = \
218  (0x7fff + ((STABLE[3*normalA+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
219  (STABLE[3*normalB+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
220  (STABLE[3*normalC+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
221  (STABLE[3*normalD+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
222  (STABLE[3*normalE+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
223  (STABLE[3*normalF+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
224  (STABLE[3*normalG+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
225  (STABLE[3*normalH+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
226  \
227  _tmpSColor[2] = \
228  (0x7fff + ((STABLE[3*normalA+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
229  (STABLE[3*normalB+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
230  (STABLE[3*normalC+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
231  (STABLE[3*normalD+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
232  (STABLE[3*normalE+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
233  (STABLE[3*normalF+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
234  (STABLE[3*normalG+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
235  (STABLE[3*normalH+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
236  \
237  \
238  COLOR[0] = static_cast<unsigned short>((_tmpDColor[0]*COLOR[0]+0x7fff)>>VTKKW_FP_SHIFT); \
239  COLOR[1] = static_cast<unsigned short>((_tmpDColor[1]*COLOR[1]+0x7fff)>>VTKKW_FP_SHIFT); \
240  COLOR[2] = static_cast<unsigned short>((_tmpDColor[2]*COLOR[2]+0x7fff)>>VTKKW_FP_SHIFT); \
241  COLOR[0] += (_tmpSColor[0]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT; \
242  COLOR[1] += (_tmpSColor[1]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT; \
243  COLOR[2] += (_tmpSColor[2]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;
244 
245 #define VTKKWRCHelper_InterpolateShadingComponent( DTABLE, STABLE, COLOR, CIDX ) \
246  unsigned int _tmpDColor[3]; \
247  unsigned int _tmpSColor[3]; \
248  \
249  _tmpDColor[0] = \
250  (0x7fff + ((DTABLE[CIDX][3*normalA[CIDX]] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
251  (DTABLE[CIDX][3*normalB[CIDX]] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
252  (DTABLE[CIDX][3*normalC[CIDX]] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
253  (DTABLE[CIDX][3*normalD[CIDX]] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
254  (DTABLE[CIDX][3*normalE[CIDX]] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
255  (DTABLE[CIDX][3*normalF[CIDX]] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
256  (DTABLE[CIDX][3*normalG[CIDX]] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
257  (DTABLE[CIDX][3*normalH[CIDX]] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
258  \
259  _tmpDColor[1] = \
260  (0x7fff + ((DTABLE[CIDX][3*normalA[CIDX]+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
261  (DTABLE[CIDX][3*normalB[CIDX]+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
262  (DTABLE[CIDX][3*normalC[CIDX]+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
263  (DTABLE[CIDX][3*normalD[CIDX]+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
264  (DTABLE[CIDX][3*normalE[CIDX]+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
265  (DTABLE[CIDX][3*normalF[CIDX]+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
266  (DTABLE[CIDX][3*normalG[CIDX]+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
267  (DTABLE[CIDX][3*normalH[CIDX]+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
268  \
269  _tmpDColor[2] = \
270  (0x7fff + ((DTABLE[CIDX][3*normalA[CIDX]+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
271  (DTABLE[CIDX][3*normalB[CIDX]+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
272  (DTABLE[CIDX][3*normalC[CIDX]+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
273  (DTABLE[CIDX][3*normalD[CIDX]+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
274  (DTABLE[CIDX][3*normalE[CIDX]+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
275  (DTABLE[CIDX][3*normalF[CIDX]+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
276  (DTABLE[CIDX][3*normalG[CIDX]+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
277  (DTABLE[CIDX][3*normalH[CIDX]+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
278  \
279  _tmpSColor[0] = \
280  (0x7fff + ((STABLE[CIDX][3*normalA[CIDX]] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
281  (STABLE[CIDX][3*normalB[CIDX]] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
282  (STABLE[CIDX][3*normalC[CIDX]] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
283  (STABLE[CIDX][3*normalD[CIDX]] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
284  (STABLE[CIDX][3*normalE[CIDX]] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
285  (STABLE[CIDX][3*normalF[CIDX]] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
286  (STABLE[CIDX][3*normalG[CIDX]] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
287  (STABLE[CIDX][3*normalH[CIDX]] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
288  \
289  _tmpSColor[1] = \
290  (0x7fff + ((STABLE[CIDX][3*normalA[CIDX]+1] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
291  (STABLE[CIDX][3*normalB[CIDX]+1] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
292  (STABLE[CIDX][3*normalC[CIDX]+1] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
293  (STABLE[CIDX][3*normalD[CIDX]+1] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
294  (STABLE[CIDX][3*normalE[CIDX]+1] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
295  (STABLE[CIDX][3*normalF[CIDX]+1] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
296  (STABLE[CIDX][3*normalG[CIDX]+1] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
297  (STABLE[CIDX][3*normalH[CIDX]+1] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
298  \
299  _tmpSColor[2] = \
300  (0x7fff + ((STABLE[CIDX][3*normalA[CIDX]+2] * ((0x4000 + w1Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
301  (STABLE[CIDX][3*normalB[CIDX]+2] * ((0x4000 + w2Xw1Y*w1Z)>>VTKKW_FP_SHIFT)) + \
302  (STABLE[CIDX][3*normalC[CIDX]+2] * ((0x4000 + w1Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
303  (STABLE[CIDX][3*normalD[CIDX]+2] * ((0x4000 + w2Xw2Y*w1Z)>>VTKKW_FP_SHIFT)) + \
304  (STABLE[CIDX][3*normalE[CIDX]+2] * ((0x4000 + w1Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
305  (STABLE[CIDX][3*normalF[CIDX]+2] * ((0x4000 + w2Xw1Y*w2Z)>>VTKKW_FP_SHIFT)) + \
306  (STABLE[CIDX][3*normalG[CIDX]+2] * ((0x4000 + w1Xw2Y*w2Z)>>VTKKW_FP_SHIFT)) + \
307  (STABLE[CIDX][3*normalH[CIDX]+2] * ((0x4000 + w2Xw2Y*w2Z)>>VTKKW_FP_SHIFT)))) >> VTKKW_FP_SHIFT; \
308  \
309  \
310  COLOR[0] = static_cast<unsigned short>((_tmpDColor[0]*COLOR[0]+0x7fff)>>VTKKW_FP_SHIFT); \
311  COLOR[1] = static_cast<unsigned short>((_tmpDColor[1]*COLOR[1]+0x7fff)>>VTKKW_FP_SHIFT); \
312  COLOR[2] = static_cast<unsigned short>((_tmpDColor[2]*COLOR[2]+0x7fff)>>VTKKW_FP_SHIFT); \
313  COLOR[0] += (_tmpSColor[0]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT; \
314  COLOR[1] += (_tmpSColor[1]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT; \
315  COLOR[2] += (_tmpSColor[2]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;
316 
317 #define VTKKWRCHelper_LookupColorUS( COLORTABLE, SCALAROPACITYTABLE, IDX, COLOR ) \
318  COLOR[3] = SCALAROPACITYTABLE[IDX]; \
319  if ( !COLOR[3] ) {continue;} \
320  COLOR[0] = static_cast<unsigned short> \
321  ((COLORTABLE[3*IDX ]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
322  COLOR[1] = static_cast<unsigned short> \
323  ((COLORTABLE[3*IDX+1]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
324  COLOR[2] = static_cast<unsigned short> \
325  ((COLORTABLE[3*IDX+2]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));
326 
327 #define VTKKWRCHelper_LookupColorMax( COLORTABLE, SCALAROPACITYTABLE, IDX, COLOR ) \
328  COLOR[3] = SCALAROPACITYTABLE[IDX]; \
329  COLOR[0] = static_cast<unsigned short> \
330  ((COLORTABLE[3*IDX ]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
331  COLOR[1] = static_cast<unsigned short> \
332  ((COLORTABLE[3*IDX+1]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
333  COLOR[2] = static_cast<unsigned short> \
334  ((COLORTABLE[3*IDX+2]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));
335 
336 #define VTKKWRCHelper_LookupDependentColorUS( COLORTABLE, SCALAROPACITYTABLE, IDX, CMPS, COLOR ) \
337  { \
338  unsigned short _alpha; \
339  switch ( CMPS ) \
340  { \
341  case 2: \
342  _alpha = SCALAROPACITYTABLE[IDX[1]]; \
343  COLOR[0] = static_cast<unsigned short> \
344  ((COLORTABLE[3*IDX[0] ]*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT)); \
345  COLOR[1] = static_cast<unsigned short> \
346  ((COLORTABLE[3*IDX[0]+1]*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT)); \
347  COLOR[2] = static_cast<unsigned short> \
348  ((COLORTABLE[3*IDX[0]+2]*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT)); \
349  COLOR[3] = _alpha; \
350  break; \
351  case 4: \
352  _alpha = SCALAROPACITYTABLE[IDX[3]]; \
353  COLOR[0] = static_cast<unsigned short>((IDX[0]*_alpha + 0x7f)>>8 ); \
354  COLOR[1] = static_cast<unsigned short>((IDX[1]*_alpha + 0x7f)>>8 ); \
355  COLOR[2] = static_cast<unsigned short>((IDX[2]*_alpha + 0x7f)>>8 ); \
356  COLOR[3] = _alpha; \
357  break; \
358  } \
359  }
360 
361 #define VTKKWRCHelper_LookupColorGOUS( CTABLE, SOTABLE, GOTABLE, IDX, IDX2, COLOR ) \
362  COLOR[3] = (SOTABLE[IDX] * GOTABLE[IDX2] + 0x7fff)>>VTKKW_FP_SHIFT; \
363  if ( !COLOR[3] ) {continue;} \
364  COLOR[0] = static_cast<unsigned short> \
365  ((CTABLE[3*IDX ]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
366  COLOR[1] = static_cast<unsigned short> \
367  ((CTABLE[3*IDX+1]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
368  COLOR[2] = static_cast<unsigned short> \
369  ((CTABLE[3*IDX+2]*COLOR[3] + 0x7fff)>>(VTKKW_FP_SHIFT));
370 
371 #define VTKKWRCHelper_LookupShading( DTABLE, STABLE, NORMAL, COLOR ) \
372  COLOR[0] = static_cast<unsigned short>((DTABLE[3*NORMAL ]*COLOR[0]+0x7fff)>>VTKKW_FP_SHIFT); \
373  COLOR[1] = static_cast<unsigned short>((DTABLE[3*NORMAL+1]*COLOR[1]+0x7fff)>>VTKKW_FP_SHIFT); \
374  COLOR[2] = static_cast<unsigned short>((DTABLE[3*NORMAL+2]*COLOR[2]+0x7fff)>>VTKKW_FP_SHIFT); \
375  COLOR[0] += (STABLE[3*NORMAL ]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT; \
376  COLOR[1] += (STABLE[3*NORMAL+1]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT; \
377  COLOR[2] += (STABLE[3*NORMAL+2]*COLOR[3] + 0x7fff)>>VTKKW_FP_SHIFT;
378 
379 #define VTKKWRCHelper_LookupAndCombineIndependentColorsUS( COLORTABLE, SOTABLE, \
380  SCALAR, WEIGHTS, \
381  COMPONENTS, COLOR ) \
382  unsigned int _tmp[4] = {0,0,0,0}; \
383  unsigned short _alpha[4] = {0,0,0,0}; \
384  unsigned int _totalAlpha = 0; \
385  \
386  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
387  { \
388  _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]); \
389  _totalAlpha += _alpha[_idx]; \
390  }} \
391  \
392  if ( !_totalAlpha ) {continue;} \
393  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
394  { \
395  if ( _alpha[_idx] ) \
396  { \
397  _tmp[0] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx] ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
398  _tmp[1] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
399  _tmp[2] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
400  _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha); \
401  } \
402  }} \
403  if ( !_tmp[3] ) {continue;} \
404  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
405  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
406  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
407  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
408 
409 #define VTKKWRCHelper_LookupAndCombineIndependentColorsMax( COLORTABLE, SCALAROPACITYTABLE, \
410  IDX, WEIGHTS, CMPS, COLOR ) \
411 { \
412  unsigned int _tmp[4] = {0,0,0,0}; \
413  for ( int _idx = 0; _idx < CMPS; _idx++ ) \
414  { \
415  unsigned short _alpha = static_cast<unsigned short>(SCALAROPACITYTABLE[_idx][IDX[_idx]]*WEIGHTS[_idx]); \
416  _tmp[0] += static_cast<unsigned short>(((COLORTABLE[_idx][3*IDX[_idx] ])*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT)); \
417  _tmp[1] += static_cast<unsigned short>(((COLORTABLE[_idx][3*IDX[_idx]+1])*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT)); \
418  _tmp[2] += static_cast<unsigned short>(((COLORTABLE[_idx][3*IDX[_idx]+2])*_alpha + 0x7fff)>>(VTKKW_FP_SHIFT)); \
419  _tmp[3] += _alpha; \
420  } \
421  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
422  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
423  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
424  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]); \
425 }
426 
427 #define VTKKWRCHelper_LookupAndCombineIndependentColorsGOUS( COLORTABLE, SOTABLE, \
428  GOTABLE, \
429  SCALAR, MAG, WEIGHTS, \
430  COMPONENTS, COLOR ) \
431  unsigned int _tmp[4] = {0,0,0,0}; \
432  unsigned short _alpha[4] = {0,0,0,0}; \
433  unsigned int _totalAlpha = 0; \
434  COMPONENTS = (COMPONENTS < 4) ? COMPONENTS : 4; \
435  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
436  { \
437  _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]); \
438  if ( _alpha[_idx] ) \
439  { \
440  _alpha[_idx] = static_cast<unsigned short>((_alpha[_idx]*GOTABLE[_idx][MAG[_idx]] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
441  _totalAlpha += _alpha[_idx]; \
442  } \
443  }} \
444  \
445  if ( !_totalAlpha ) {continue;} \
446  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
447  { \
448  if ( _alpha[_idx] ) \
449  { \
450  _tmp[0] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx] ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
451  _tmp[1] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
452  _tmp[2] += static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
453  _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha); \
454  } \
455  }} \
456  if ( !_tmp[3] ) {continue;}; \
457  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
458  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
459  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
460  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
461 
462 #define VTKKWRCHelper_LookupAndCombineIndependentColorsShadeUS( COLORTABLE, SOTABLE, \
463  DTABLE, STABLE, \
464  SCALAR, NORMAL, WEIGHTS, \
465  COMPONENTS, COLOR ) \
466  unsigned int _tmp[4] = {0,0,0,0}; \
467  unsigned int _tmpC[3]; \
468  unsigned short _alpha[4] = {0,0,0,0}; \
469  unsigned int _totalAlpha = 0; \
470  \
471  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
472  { \
473  _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]); \
474  _totalAlpha += _alpha[_idx]; \
475  }} \
476  \
477  if ( !_totalAlpha ) {continue;} \
478  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
479  { \
480  if ( _alpha[_idx] ) \
481  { \
482  _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx] ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
483  _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
484  _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
485  _tmpC[0] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx] ]*_tmpC[0]+0x7fff)>>VTKKW_FP_SHIFT); \
486  _tmpC[1] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+1]*_tmpC[1]+0x7fff)>>VTKKW_FP_SHIFT); \
487  _tmpC[2] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+2]*_tmpC[2]+0x7fff)>>VTKKW_FP_SHIFT); \
488  _tmpC[0] += (STABLE[_idx][3*NORMAL[_idx] ]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT; \
489  _tmpC[1] += (STABLE[_idx][3*NORMAL[_idx]+1]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT; \
490  _tmpC[2] += (STABLE[_idx][3*NORMAL[_idx]+2]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT; \
491  _tmp[0] += _tmpC[0]; \
492  _tmp[1] += _tmpC[1]; \
493  _tmp[2] += _tmpC[2]; \
494  _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha); \
495  } \
496  }} \
497  if ( !_tmp[3] ) {continue;} \
498  \
499  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
500  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
501  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
502  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
503 
504 #define VTKKWRCHelper_LookupAndCombineIndependentColorsInterpolateShadeUS( COLORTABLE, SOTABLE, \
505  DTABLE, STABLE, \
506  SCALAR, WEIGHTS, \
507  COMPONENTS, COLOR ) \
508  unsigned int _tmp[4] = {0,0,0,0}; \
509  unsigned int _tmpC[4]; \
510  unsigned short _alpha[4] = {0,0,0,0}; \
511  unsigned int _totalAlpha = 0; \
512  \
513  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
514  { \
515  _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]); \
516  _totalAlpha += _alpha[_idx]; \
517  }} \
518  \
519  if ( !_totalAlpha ) {continue;} \
520  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
521  { \
522  if ( _alpha[_idx] ) \
523  { \
524  _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx] ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
525  _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
526  _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
527  _tmpC[3] = _alpha[_idx]; \
528  VTKKWRCHelper_InterpolateShadingComponent( DTABLE, STABLE, _tmpC, _idx ); \
529  _tmp[0] += _tmpC[0]; \
530  _tmp[1] += _tmpC[1]; \
531  _tmp[2] += _tmpC[2]; \
532  _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha); \
533  } \
534  }} \
535  if (!_tmp[3]) {continue;} \
536  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
537  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
538  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
539  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
540 
541 #define VTKKWRCHelper_CompositeColorAndCheckEarlyTermination( COLOR, TMP, REMAININGOPACITY ) \
542  COLOR[0] += (TMP[0]*REMAININGOPACITY+0x7fff)>>VTKKW_FP_SHIFT; \
543  COLOR[1] += (TMP[1]*REMAININGOPACITY+0x7fff)>>VTKKW_FP_SHIFT; \
544  COLOR[2] += (TMP[2]*REMAININGOPACITY+0x7fff)>>VTKKW_FP_SHIFT; \
545  REMAININGOPACITY = (REMAININGOPACITY*((~(TMP[3])&VTKKW_FP_MASK))+0x7fff)>>VTKKW_FP_SHIFT; \
546  if ( REMAININGOPACITY < 0xff ) \
547  { \
548  break; \
549  }
550 
551 #define VTKKWRCHelper_LookupAndCombineIndependentColorsGOShadeUS( COLORTABLE, SOTABLE, GOTABLE, \
552  DTABLE, STABLE, \
553  SCALAR, MAG, NORMAL, WEIGHTS, \
554  COMPONENTS, COLOR ) \
555  unsigned int _tmp[4] = {0,0,0,0}; \
556  unsigned int _tmpC[3]; \
557  unsigned short _alpha[4] = {0,0,0,0}; \
558  unsigned int _totalAlpha = 0; \
559  \
560  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
561  { \
562  _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]); \
563  if ( _alpha[_idx] ) \
564  { \
565  _alpha[_idx] = static_cast<unsigned short>((_alpha[_idx]*GOTABLE[_idx][MAG[_idx]] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
566  _totalAlpha += _alpha[_idx]; \
567  } \
568  }} \
569  \
570  if ( !_totalAlpha ) {continue;} \
571  \
572  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
573  { \
574  if ( _alpha[_idx] ) \
575  { \
576  _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx] ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
577  _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
578  _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
579  _tmpC[0] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx] ]*_tmpC[0]+0x7fff)>>VTKKW_FP_SHIFT); \
580  _tmpC[1] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+1]*_tmpC[1]+0x7fff)>>VTKKW_FP_SHIFT); \
581  _tmpC[2] = static_cast<unsigned short>((DTABLE[_idx][3*NORMAL[_idx]+2]*_tmpC[2]+0x7fff)>>VTKKW_FP_SHIFT); \
582  _tmpC[0] += (STABLE[_idx][3*NORMAL[_idx] ]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT; \
583  _tmpC[1] += (STABLE[_idx][3*NORMAL[_idx]+1]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT; \
584  _tmpC[2] += (STABLE[_idx][3*NORMAL[_idx]+2]*_alpha[_idx] + 0x7fff)>>VTKKW_FP_SHIFT; \
585  _tmp[0] += _tmpC[0]; \
586  _tmp[1] += _tmpC[1]; \
587  _tmp[2] += _tmpC[2]; \
588  _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha); \
589  } \
590  }} \
591  if ( !_tmp[3] ) {continue;} \
592  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
593  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
594  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
595  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
596 
597 #define VTKKWRCHelper_LookupAndCombineIndependentColorsGOInterpolateShadeUS( COLORTABLE, SOTABLE, GOTABLE, \
598  DTABLE, STABLE, \
599  SCALAR, MAG, WEIGHTS, \
600  COMPONENTS, COLOR ) \
601  unsigned int _tmp[4] = {0,0,0,0}; \
602  unsigned int _tmpC[4]; \
603  unsigned short _alpha[4] = {0,0,0,0}; \
604  unsigned int _totalAlpha = 0; \
605  \
606  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
607  { \
608  _alpha[_idx] = static_cast<unsigned short>(SOTABLE[_idx][SCALAR[_idx]]*WEIGHTS[_idx]); \
609  if ( _alpha[_idx] ) \
610  { \
611  _alpha[_idx] = static_cast<unsigned short>((_alpha[_idx]*GOTABLE[_idx][MAG[_idx]] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
612  _totalAlpha += _alpha[_idx]; \
613  } \
614  }} \
615  \
616  if ( !_totalAlpha ) {continue;} \
617  {for ( int _idx = 0; _idx < COMPONENTS; _idx++ ) \
618  { \
619  if ( _alpha[_idx] ) \
620  { \
621  _tmpC[0] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx] ])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
622  _tmpC[1] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+1])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
623  _tmpC[2] = static_cast<unsigned short>(((COLORTABLE[_idx][3*SCALAR[_idx]+2])*_alpha[_idx] + 0x7fff)>>(VTKKW_FP_SHIFT)); \
624  _tmpC[3] = _alpha[_idx]; \
625  VTKKWRCHelper_InterpolateShadingComponent( DTABLE, STABLE, _tmpC, _idx ); \
626  _tmp[0] += _tmpC[0]; \
627  _tmp[1] += _tmpC[1]; \
628  _tmp[2] += _tmpC[2]; \
629  _tmp[3] += ((_alpha[_idx]*_alpha[_idx])/_totalAlpha); \
630  } \
631  }} \
632  if ( !_tmp[3] ) {continue;} \
633  COLOR[0] = (_tmp[0]>32767)?(32767):(_tmp[0]); \
634  COLOR[1] = (_tmp[1]>32767)?(32767):(_tmp[1]); \
635  COLOR[2] = (_tmp[2]>32767)?(32767):(_tmp[2]); \
636  COLOR[3] = (_tmp[3]>32767)?(32767):(_tmp[3]);
637 
638 #define VTKKWRCHelper_SetPixelColor( IMAGEPTR, COLOR, REMAININGOPACITY ) \
639  IMAGEPTR[0] = (COLOR[0]>32767)?(32767):(COLOR[0]); \
640  IMAGEPTR[1] = (COLOR[1]>32767)?(32767):(COLOR[1]); \
641  IMAGEPTR[2] = (COLOR[2]>32767)?(32767):(COLOR[2]); \
642  unsigned int tmpAlpha = (~REMAININGOPACITY)&VTKKW_FP_MASK; \
643  IMAGEPTR[3] = (tmpAlpha>32767)?(32767):(tmpAlpha);
644 
645 #define VTKKWRCHelper_MoveToNextSampleNN() \
646  if ( k < numSteps-1 ) \
647  { \
648  mapper->FixedPointIncrement( pos, dir ); \
649  mapper->ShiftVectorDown( pos, spos ); \
650  dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
651  }
652 
653 #define VTKKWRCHelper_MoveToNextSampleGONN() \
654  if ( k < numSteps-1 ) \
655  { \
656  mapper->FixedPointIncrement( pos, dir ); \
657  mapper->ShiftVectorDown( pos, spos ); \
658  dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
659  magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1]; \
660  }
661 
662 #define VTKKWRCHelper_MoveToNextSampleShadeNN() \
663  if ( k < numSteps-1 ) \
664  { \
665  mapper->FixedPointIncrement( pos, dir ); \
666  mapper->ShiftVectorDown( pos, spos ); \
667  dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
668  dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1]; \
669  }
670 
671 #define VTKKWRCHelper_MoveToNextSampleGOShadeNN() \
672  if ( k < numSteps-1 ) \
673  { \
674  mapper->FixedPointIncrement( pos, dir ); \
675  mapper->ShiftVectorDown( pos, spos ); \
676  dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
677  magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1]; \
678  dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1]; \
679  }
680 
681 #define VTKKWRCHelper_InitializeVariables() \
682  int i, j; \
683  unsigned short *imagePtr; \
684  \
685  int imageInUseSize[2]; \
686  int imageMemorySize[2]; \
687  int imageViewportSize[2]; \
688  int imageOrigin[2]; \
689  int dim[3]; \
690  float shift[4]; \
691  float scale[4]; \
692  \
693  mapper->GetRayCastImage()->GetImageInUseSize(imageInUseSize); \
694  mapper->GetRayCastImage()->GetImageMemorySize(imageMemorySize); \
695  mapper->GetRayCastImage()->GetImageViewportSize(imageViewportSize); \
696  mapper->GetRayCastImage()->GetImageOrigin(imageOrigin); \
697  mapper->GetInput()->GetDimensions(dim); \
698  mapper->GetTableShift( shift ); \
699  mapper->GetTableScale( scale ); \
700  \
701  int *rowBounds = mapper->GetRowBounds(); \
702  unsigned short *image = mapper->GetRayCastImage()->GetImage(); \
703  vtkRenderWindow *renWin = mapper->GetRenderWindow(); \
704  int components = mapper->GetInput()->GetNumberOfScalarComponents(); \
705  int cropping = (mapper->GetCropping() && \
706  mapper->GetCroppingRegionFlags() != 0x2000 ); \
707  \
708  components = (components < 4) ? components : 4; \
709  unsigned short *colorTable[4]; \
710  unsigned short *scalarOpacityTable[4]; \
711  \
712  int c; \
713  for ( c = 0; c < 4; c++ ) \
714  { \
715  colorTable[c] = mapper->GetColorTable(c); \
716  (void)(colorTable[c]); \
717  scalarOpacityTable[c] = mapper->GetScalarOpacityTable(c); \
718  } \
719  \
720  vtkIdType inc[3]; \
721  inc[0] = components; \
722  inc[1] = inc[0]*dim[0]; \
723  inc[2] = inc[1]*dim[1];
724 
725 #define VTKKWRCHelper_InitializeWeights() \
726  float weights[4] = {}; \
727  weights[0] = vol->GetProperty()->GetComponentWeight(0); \
728  weights[1] = vol->GetProperty()->GetComponentWeight(1); \
729  weights[2] = vol->GetProperty()->GetComponentWeight(2); \
730  weights[3] = vol->GetProperty()->GetComponentWeight(3);
731 
732 #define VTKKWRCHelper_InitializeVariablesGO() \
733  unsigned short *gradientOpacityTable[4]; \
734  for ( c = 0; c < 4; c++ ) \
735  { \
736  gradientOpacityTable[c] = mapper->GetGradientOpacityTable(c); \
737  } \
738  unsigned char **gradientMag = mapper->GetGradientMagnitude(); \
739  \
740  vtkIdType mInc[3]; \
741  if ( vol->GetProperty()->GetIndependentComponents() ) \
742  { \
743  mInc[0] = inc[0]; \
744  mInc[1] = inc[1]; \
745  mInc[2] = inc[2]; \
746  } \
747  else \
748  { \
749  mInc[0] = 1; \
750  mInc[1] = mInc[0]*dim[0]; \
751  mInc[2] = mInc[1]*dim[1]; \
752  }
753 
754 #define VTKKWRCHelper_InitializeVariablesShade() \
755  unsigned short *diffuseShadingTable[4]; \
756  unsigned short *specularShadingTable[4]; \
757  for ( c = 0; c < 4; c++ ) \
758  { \
759  diffuseShadingTable[c] = mapper->GetDiffuseShadingTable(c); \
760  specularShadingTable[c] = mapper->GetSpecularShadingTable(c); \
761  } \
762  unsigned short **gradientDir = mapper->GetGradientNormal(); \
763  vtkIdType dInc[3]; \
764  if ( vol->GetProperty()->GetIndependentComponents() ) \
765  { \
766  dInc[0] = inc[0]; \
767  dInc[1] = inc[1]; \
768  dInc[2] = inc[2]; \
769  } \
770  else \
771  { \
772  dInc[0] = 1; \
773  dInc[1] = dInc[0]*dim[0]; \
774  dInc[2] = dInc[1]*dim[1]; \
775  }
776 
777 #define VTKKWRCHelper_InitializeTrilinVariables() \
778  vtkIdType Binc = components; \
779  vtkIdType Cinc = Binc*dim[0]; \
780  vtkIdType Dinc = Cinc + Binc; \
781  vtkIdType Einc = Cinc*dim[1]; \
782  vtkIdType Finc = Einc + Binc; \
783  vtkIdType Ginc = Einc + Cinc; \
784  vtkIdType Hinc = Ginc + Binc;
785 
786 #define VTKKWRCHelper_InitializeTrilinVariablesGO() \
787  vtkIdType magOffset; \
788  if ( vol->GetProperty()->GetIndependentComponents() ) \
789  { \
790  magOffset = components; \
791  } \
792  else \
793  { \
794  magOffset = 1; \
795  } \
796  \
797  vtkIdType mBFinc = magOffset; \
798  vtkIdType mCGinc = dim[0]*magOffset; \
799  vtkIdType mDHinc = dim[0]*magOffset + magOffset;
800 
801 #define VTKKWRCHelper_InitializeTrilinVariablesShade() \
802  vtkIdType dirOffset; \
803  if ( vol->GetProperty()->GetIndependentComponents() ) \
804  { \
805  dirOffset = components; \
806  } \
807  else \
808  { \
809  dirOffset = 1; \
810  } \
811  \
812  vtkIdType dBFinc = dirOffset; \
813  vtkIdType dCGinc = dim[0]*dirOffset; \
814  vtkIdType dDHinc = dim[0]*dirOffset + dirOffset;
815 
816 #define VTKKWRCHelper_OuterInitialization() \
817  if ( j%threadCount != threadID ) \
818  { \
819  continue; \
820  } \
821  if ( !threadID ) \
822  { \
823  if ( renWin->CheckAbortStatus() ) \
824  { \
825  break; \
826  } \
827  } \
828  else if ( renWin->GetAbortRender() ) \
829  { \
830  break; \
831  } \
832  imagePtr = image + 4*(j*imageMemorySize[0] + rowBounds[j*2]);
833 
834 #define VTKKWRCHelper_InnerInitialization() \
835  unsigned int numSteps; \
836  unsigned int pos[3]; \
837  unsigned int dir[3]; \
838  mapper->ComputeRayInfo( i, j, pos, dir, &numSteps ); \
839  if ( numSteps == 0 ) \
840  { \
841  *(imagePtr ) = 0; \
842  *(imagePtr+1) = 0; \
843  *(imagePtr+2) = 0; \
844  *(imagePtr+3) = 0; \
845  imagePtr += 4; \
846  continue; \
847  } \
848  unsigned int spos[3]; \
849  unsigned int k;
850 
851 #define VTKKWRCHelper_InitializeMIPOneNN() \
852  mapper->ShiftVectorDown( pos, spos ); \
853  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
854  T maxValue = *(dptr);
855 
856 #define VTKKWRCHelper_InitializeMIPMultiNN() \
857  mapper->ShiftVectorDown( pos, spos ); \
858  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
859  T maxValue[4] = {}; \
860  for ( c = 0; c < components; c++ ) \
861  { \
862  maxValue[c] = *(dptr+c); \
863  }
864 
865 #define VTKKWRCHelper_InitializeMIPOneTrilin() \
866  T *dptr; \
867  unsigned int oldSPos[3]; \
868  \
869  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
870  oldSPos[1] = 0; \
871  oldSPos[2] = 0; \
872  \
873  unsigned int w1X, w1Y, w1Z; \
874  unsigned int w2X, w2Y, w2Z; \
875  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
876  \
877  unsigned short maxValue=0; \
878  unsigned short val; \
879  unsigned int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;
880 
881 #define VTKKWRCHelper_InitializeMIPMultiTrilin() \
882  T *dptr; \
883  unsigned int oldSPos[3]; \
884  \
885  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
886  oldSPos[1] = 0; \
887  oldSPos[2] = 0; \
888  \
889  unsigned int w1X, w1Y, w1Z; \
890  unsigned int w2X, w2Y, w2Z; \
891  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
892  \
893  unsigned short maxValue[4] = {}; \
894  unsigned short val[4] = {}; \
895  unsigned int A[4] = {}, B[4] = {}, C[4] = {}, D[4] = {}, \
896  E[4] = {}, F[4] = {}, G[4] = {}, H[4] = {};
897 
898 #define VTKKWRCHelper_InitializeCompositeGONN() \
899  unsigned char *magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1];
900 
901 #define VTKKWRCHelper_InitializeCompositeShadeNN() \
902  unsigned short *dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1];
903 
904 #define VTKKWRCHelper_InitializeCompositeOneNN() \
905  mapper->ShiftVectorDown( pos, spos ); \
906  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
907  unsigned int color[3] = {0,0,0}; \
908  unsigned short remainingOpacity = 0x7fff; \
909  unsigned short tmp[4];
910 
911 #define VTKKWRCHelper_InitializeCompositeMultiNN() \
912  mapper->ShiftVectorDown( pos, spos ); \
913  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
914  unsigned int color[3] = {0,0,0}; \
915  unsigned int remainingOpacity = 0x7fff; \
916  unsigned short tmp[4] = {}; \
917  unsigned short val[4] = {};
918 
919 #define VTKKWRCHelper_InitializeCompositeOneTrilin() \
920  T *dptr; \
921  unsigned int oldSPos[3]; \
922  \
923  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
924  oldSPos[1] = 0; \
925  oldSPos[2] = 0; \
926  \
927  unsigned int w1X, w1Y, w1Z; \
928  unsigned int w2X, w2Y, w2Z; \
929  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
930  \
931  unsigned short val; \
932  unsigned int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0; \
933  \
934  unsigned int color[3] = {0,0,0}; \
935  unsigned short remainingOpacity = 0x7fff; \
936  unsigned short tmp[4];
937 
938 #define VTKKWRCHelper_InitializeCompositeOneGOTrilin() \
939  unsigned char *magPtrABCD = 0, *magPtrEFGH = 0; \
940  unsigned short mag; \
941  unsigned int mA=0,mB=0,mC=0,mD=0,mE=0,mF=0,mG=0,mH=0;
942 
943 #define VTKKWRCHelper_InitializeCompositeOneShadeTrilin() \
944  unsigned short *dirPtrABCD = 0, *dirPtrEFGH = 0; \
945  unsigned int normalA=0,normalB=0,normalC=0,normalD=0; \
946  unsigned int normalE=0,normalF=0,normalG=0,normalH=0;
947 
948 #define VTKKWRCHelper_InitializeCompositeMultiTrilin() \
949  T *dptr; \
950  unsigned int oldSPos[3]; \
951  \
952  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
953  oldSPos[1] = 0; \
954  oldSPos[2] = 0; \
955  \
956  unsigned int w1X, w1Y, w1Z; \
957  unsigned int w2X, w2Y, w2Z; \
958  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
959  \
960  unsigned short val[4] = {0, 0, 0, 0}; \
961  unsigned int A[4] = {0, 0, 0, 0}; \
962  unsigned int B[4] = {0, 0, 0, 0}; \
963  unsigned int C[4] = {0, 0, 0, 0}; \
964  unsigned int D[4] = {0, 0, 0, 0}; \
965  unsigned int E[4] = {0, 0, 0, 0}; \
966  unsigned int F[4] = {0, 0, 0, 0}; \
967  unsigned int G[4] = {0, 0, 0, 0}; \
968  unsigned int H[4] = {0, 0, 0, 0}; \
969  \
970  unsigned int color[3] = {0,0,0}; \
971  unsigned short remainingOpacity = 0x7fff; \
972  unsigned short tmp[4];
973 
974 #define VTKKWRCHelper_InitializeCompositeMultiGOTrilin() \
975  unsigned char *magPtrABCD = 0, *magPtrEFGH = 0; \
976  unsigned short mag[4] = {}; \
977  unsigned int mA[4] = {}, mB[4] = {}, mC[4] = {}, \
978  mD[4] = {}, mE[4] = {}, mF[4] = {}, \
979  mG[4] = {}, mH[4] = {};
980 
981 #define VTKKWRCHelper_InitializeCompositeMultiShadeTrilin() \
982  unsigned short *dirPtrABCD = 0, *dirPtrEFGH = 0; \
983  unsigned int normalA[4],normalB[4],normalC[4],normalD[4]; \
984  unsigned int normalE[4],normalF[4],normalG[4],normalH[4];
985 
986 #define VTKKWRCHelper_InitializationAndLoopStartNN() \
987  VTKKWRCHelper_InitializeVariables(); \
988  for ( j = 0; j < imageInUseSize[1]; j++ ) \
989  { \
990  VTKKWRCHelper_OuterInitialization(); \
991  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
992  { \
993  VTKKWRCHelper_InnerInitialization();
994 
995 #define VTKKWRCHelper_InitializationAndLoopStartGONN() \
996  VTKKWRCHelper_InitializeVariables(); \
997  VTKKWRCHelper_InitializeVariablesGO(); \
998  for ( j = 0; j < imageInUseSize[1]; j++ ) \
999  { \
1000  VTKKWRCHelper_OuterInitialization(); \
1001  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1002  { \
1003  VTKKWRCHelper_InnerInitialization();
1004 
1005 #define VTKKWRCHelper_InitializationAndLoopStartShadeNN() \
1006  VTKKWRCHelper_InitializeVariables(); \
1007  VTKKWRCHelper_InitializeVariablesShade(); \
1008  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1009  { \
1010  VTKKWRCHelper_OuterInitialization(); \
1011  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1012  { \
1013  VTKKWRCHelper_InnerInitialization();
1014 
1015 #define VTKKWRCHelper_InitializationAndLoopStartGOShadeNN() \
1016  VTKKWRCHelper_InitializeVariables(); \
1017  VTKKWRCHelper_InitializeVariablesGO(); \
1018  VTKKWRCHelper_InitializeVariablesShade(); \
1019  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1020  { \
1021  VTKKWRCHelper_OuterInitialization(); \
1022  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1023  { \
1024  VTKKWRCHelper_InnerInitialization();
1025 
1026 #define VTKKWRCHelper_InitializationAndLoopStartTrilin() \
1027  VTKKWRCHelper_InitializeVariables(); \
1028  VTKKWRCHelper_InitializeTrilinVariables(); \
1029  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1030  { \
1031  VTKKWRCHelper_OuterInitialization(); \
1032  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1033  { \
1034  VTKKWRCHelper_InnerInitialization();
1035 
1036 #define VTKKWRCHelper_InitializationAndLoopStartGOTrilin() \
1037  VTKKWRCHelper_InitializeVariables(); \
1038  VTKKWRCHelper_InitializeVariablesGO(); \
1039  VTKKWRCHelper_InitializeTrilinVariables(); \
1040  VTKKWRCHelper_InitializeTrilinVariablesGO(); \
1041  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1042  { \
1043  VTKKWRCHelper_OuterInitialization(); \
1044  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1045  { \
1046  VTKKWRCHelper_InnerInitialization();
1047 
1048 #define VTKKWRCHelper_InitializationAndLoopStartShadeTrilin() \
1049  VTKKWRCHelper_InitializeVariables(); \
1050  VTKKWRCHelper_InitializeVariablesShade(); \
1051  VTKKWRCHelper_InitializeTrilinVariables(); \
1052  VTKKWRCHelper_InitializeTrilinVariablesShade(); \
1053  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1054  { \
1055  VTKKWRCHelper_OuterInitialization(); \
1056  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1057  { \
1058  VTKKWRCHelper_InnerInitialization();
1059 
1060 #define VTKKWRCHelper_InitializationAndLoopStartGOShadeTrilin() \
1061  VTKKWRCHelper_InitializeVariables(); \
1062  VTKKWRCHelper_InitializeVariablesShade(); \
1063  VTKKWRCHelper_InitializeVariablesGO(); \
1064  VTKKWRCHelper_InitializeTrilinVariables(); \
1065  VTKKWRCHelper_InitializeTrilinVariablesShade(); \
1066  VTKKWRCHelper_InitializeTrilinVariablesGO(); \
1067  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1068  { \
1069  VTKKWRCHelper_OuterInitialization(); \
1070  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1071  { \
1072  VTKKWRCHelper_InnerInitialization();
1073 
1074 #define VTKKWRCHelper_IncrementAndLoopEnd() \
1075  imagePtr+=4; \
1076  } \
1077  if ( (j/threadCount)%8 == 7 && threadID == 0) \
1078  { \
1079  double fargs[1]; \
1080  fargs[0] = static_cast<double>(j)/static_cast<float>(imageInUseSize[1]-1); \
1081  mapper->InvokeEvent( vtkCommand::VolumeMapperRenderProgressEvent, fargs ); \
1082  } \
1083  }
1084 
1085 #define VTKKWRCHelper_CroppingCheckTrilin( POS ) \
1086  if ( cropping ) \
1087  { \
1088  if ( mapper->CheckIfCropped( POS ) ) \
1089  { \
1090  continue; \
1091  } \
1092  }
1093 
1094 #define VTKKWRCHelper_CroppingCheckNN( POS ) \
1095  if ( cropping ) \
1096  { \
1097  if ( mapper->CheckIfCropped( POS ) ) \
1098  { \
1099  continue; \
1100  } \
1101  }
1102 
1103 #define VTKKWRCHelper_SpaceLeapSetup() \
1104  unsigned int mmpos[3]; \
1105  mmpos[0] = (pos[0] >> VTKKW_FPMM_SHIFT) + 1; \
1106  mmpos[1] = 0; \
1107  mmpos[2] = 0; \
1108  int mmvalid = 0;
1109 
1110 #define VTKKWRCHelper_SpaceLeapSetupMulti() \
1111  unsigned int mmpos[3]; \
1112  mmpos[0] = (pos[0] >> VTKKW_FPMM_SHIFT) + 1; \
1113  mmpos[1] = 0; \
1114  mmpos[2] = 0; \
1115  int mmvalid[4] = {0,0,0,0};
1116 
1117 #define VTKKWRCHelper_SpaceLeapCheck() \
1118  if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] || \
1119  pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] || \
1120  pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] ) \
1121  { \
1122  mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT; \
1123  mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT; \
1124  mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT; \
1125  mmvalid = mapper->CheckMinMaxVolumeFlag( mmpos, 0 ); \
1126  } \
1127  \
1128  if ( !mmvalid ) \
1129  { \
1130  continue; \
1131  }
1132 
1133 #define VTKKWRCHelper_MIPSpaceLeapCheck( MAXIDX, MAXIDXDEF, FLIP ) \
1134  if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] || \
1135  pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] || \
1136  pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] ) \
1137  { \
1138  mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT; \
1139  mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT; \
1140  mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT; \
1141  mmvalid = (MAXIDXDEF)? \
1142  (mapper->CheckMIPMinMaxVolumeFlag( mmpos, 0, MAXIDX, FLIP )):(1); \
1143  } \
1144  \
1145  if ( !mmvalid ) \
1146  { \
1147  continue; \
1148  }
1149 
1150 #define VTKKWRCHelper_MIPSpaceLeapPopulateMulti( MAXIDX, FLIP ) \
1151  if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] || \
1152  pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] || \
1153  pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] ) \
1154  { \
1155  mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT; \
1156  mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT; \
1157  mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT; \
1158  for ( c = 0; c < components; c++ ) \
1159  { \
1160  mmvalid[c] = mapper->CheckMIPMinMaxVolumeFlag( mmpos, c, MAXIDX[c], FLIP ); \
1161  } \
1162  }
1163 
1164 #define VTKKWRCHelper_MIPSpaceLeapCheckMulti( COMP, FLIP ) mmvalid[COMP]
1165 
1166 #include "vtkRenderingVolumeModule.h" // For export macro
1167 #include "vtkObject.h"
1168 
1170 class vtkVolume;
1171 
1172 class VTKRENDERINGVOLUME_EXPORT vtkFixedPointVolumeRayCastHelper : public vtkObject
1173 {
1174 public:
1177  void PrintSelf( ostream& os, vtkIndent indent ) override;
1178 
1179  virtual void GenerateImage( int,
1180  int,
1181  vtkVolume *,
1183 
1184 protected:
1187 
1188 
1189 private:
1191  void operator=(const vtkFixedPointVolumeRayCastHelper&) = delete;
1192 };
1193 
1194 #endif
1195 
1196 
1197 
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
An abstract helper that generates images for the volume ray cast mapper.
a simple class to control print indentation
Definition: vtkIndent.h:39
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void GenerateImage(int, int, vtkVolume *, vtkFixedPointVolumeRayCastMapper *)