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