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  COMPONENTS = (COMPONENTS < 4) ? COMPONENTS : 4; \
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  components = (components < 4) ? components : 4; \
780  unsigned short *colorTable[4]; \
781  unsigned short *scalarOpacityTable[4]; \
782  \
783  int c; \
784  for ( c = 0; c < 4; c++ ) \
785  { \
786  colorTable[c] = mapper->GetColorTable(c); \
787  (void)(colorTable[c]); \
788  scalarOpacityTable[c] = mapper->GetScalarOpacityTable(c); \
789  } \
790  \
791  vtkIdType inc[3]; \
792  inc[0] = components; \
793  inc[1] = inc[0]*dim[0]; \
794  inc[2] = inc[1]*dim[1];
795 //ETX
796 
797 //BTX
798 #define VTKKWRCHelper_InitializeWeights() \
799  float weights[4] = {}; \
800  weights[0] = vol->GetProperty()->GetComponentWeight(0); \
801  weights[1] = vol->GetProperty()->GetComponentWeight(1); \
802  weights[2] = vol->GetProperty()->GetComponentWeight(2); \
803  weights[3] = vol->GetProperty()->GetComponentWeight(3);
804 //ETX
805 
806 //BTX
807 #define VTKKWRCHelper_InitializeVariablesGO() \
808  unsigned short *gradientOpacityTable[4]; \
809  for ( c = 0; c < 4; c++ ) \
810  { \
811  gradientOpacityTable[c] = mapper->GetGradientOpacityTable(c); \
812  } \
813  unsigned char **gradientMag = mapper->GetGradientMagnitude(); \
814  \
815  vtkIdType mInc[3]; \
816  if ( vol->GetProperty()->GetIndependentComponents() ) \
817  { \
818  mInc[0] = inc[0]; \
819  mInc[1] = inc[1]; \
820  mInc[2] = inc[2]; \
821  } \
822  else \
823  { \
824  mInc[0] = 1; \
825  mInc[1] = mInc[0]*dim[0]; \
826  mInc[2] = mInc[1]*dim[1]; \
827  }
828 //ETX
829 
830 //BTX
831 #define VTKKWRCHelper_InitializeVariablesShade() \
832  unsigned short *diffuseShadingTable[4]; \
833  unsigned short *specularShadingTable[4]; \
834  for ( c = 0; c < 4; c++ ) \
835  { \
836  diffuseShadingTable[c] = mapper->GetDiffuseShadingTable(c); \
837  specularShadingTable[c] = mapper->GetSpecularShadingTable(c); \
838  } \
839  unsigned short **gradientDir = mapper->GetGradientNormal(); \
840  vtkIdType dInc[3]; \
841  if ( vol->GetProperty()->GetIndependentComponents() ) \
842  { \
843  dInc[0] = inc[0]; \
844  dInc[1] = inc[1]; \
845  dInc[2] = inc[2]; \
846  } \
847  else \
848  { \
849  dInc[0] = 1; \
850  dInc[1] = dInc[0]*dim[0]; \
851  dInc[2] = dInc[1]*dim[1]; \
852  }
853 //ETX
854 
855 //BTX
856 #define VTKKWRCHelper_InitializeTrilinVariables() \
857  vtkIdType Binc = components; \
858  vtkIdType Cinc = Binc*dim[0]; \
859  vtkIdType Dinc = Cinc + Binc; \
860  vtkIdType Einc = Cinc*dim[1]; \
861  vtkIdType Finc = Einc + Binc; \
862  vtkIdType Ginc = Einc + Cinc; \
863  vtkIdType Hinc = Ginc + Binc;
864 //ETX
865 
866 //BTX
867 #define VTKKWRCHelper_InitializeTrilinVariablesGO() \
868  vtkIdType magOffset; \
869  if ( vol->GetProperty()->GetIndependentComponents() ) \
870  { \
871  magOffset = components; \
872  } \
873  else \
874  { \
875  magOffset = 1; \
876  } \
877  \
878  vtkIdType mBFinc = magOffset; \
879  vtkIdType mCGinc = dim[0]*magOffset; \
880  vtkIdType mDHinc = dim[0]*magOffset + magOffset;
881 //ETX
882 
883 //BTX
884 #define VTKKWRCHelper_InitializeTrilinVariablesShade() \
885  vtkIdType dirOffset; \
886  if ( vol->GetProperty()->GetIndependentComponents() ) \
887  { \
888  dirOffset = components; \
889  } \
890  else \
891  { \
892  dirOffset = 1; \
893  } \
894  \
895  vtkIdType dBFinc = dirOffset; \
896  vtkIdType dCGinc = dim[0]*dirOffset; \
897  vtkIdType dDHinc = dim[0]*dirOffset + dirOffset;
898 //ETX
899 
900 //BTX
901 #define VTKKWRCHelper_OuterInitialization() \
902  if ( j%threadCount != threadID ) \
903  { \
904  continue; \
905  } \
906  if ( !threadID ) \
907  { \
908  if ( renWin->CheckAbortStatus() ) \
909  { \
910  break; \
911  } \
912  } \
913  else if ( renWin->GetAbortRender() ) \
914  { \
915  break; \
916  } \
917  imagePtr = image + 4*(j*imageMemorySize[0] + rowBounds[j*2]);
918 
919 //ETX
920 
921 //BTX
922 #define VTKKWRCHelper_InnerInitialization() \
923  unsigned int numSteps; \
924  unsigned int pos[3]; \
925  unsigned int dir[3]; \
926  mapper->ComputeRayInfo( i, j, pos, dir, &numSteps ); \
927  if ( numSteps == 0 ) \
928  { \
929  *(imagePtr ) = 0; \
930  *(imagePtr+1) = 0; \
931  *(imagePtr+2) = 0; \
932  *(imagePtr+3) = 0; \
933  imagePtr += 4; \
934  continue; \
935  } \
936  unsigned int spos[3]; \
937  unsigned int k;
938 //ETX
939 
940 //BTX
941 #define VTKKWRCHelper_InitializeMIPOneNN() \
942  mapper->ShiftVectorDown( pos, spos ); \
943  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
944  T maxValue = *(dptr);
945 //ETX
946 
947 //BTX
948 #define VTKKWRCHelper_InitializeMIPMultiNN() \
949  mapper->ShiftVectorDown( pos, spos ); \
950  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
951  T maxValue[4] = {}; \
952  for ( c = 0; c < components; c++ ) \
953  { \
954  maxValue[c] = *(dptr+c); \
955  }
956 //ETX
957 
958 //BTX
959 #define VTKKWRCHelper_InitializeMIPOneTrilin() \
960  T *dptr; \
961  unsigned int oldSPos[3]; \
962  \
963  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
964  oldSPos[1] = 0; \
965  oldSPos[2] = 0; \
966  \
967  unsigned int w1X, w1Y, w1Z; \
968  unsigned int w2X, w2Y, w2Z; \
969  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
970  \
971  unsigned short maxValue=0; \
972  unsigned short val; \
973  unsigned int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;
974 //ETX
975 
976 //BTX
977 #define VTKKWRCHelper_InitializeMIPMultiTrilin() \
978  T *dptr; \
979  unsigned int oldSPos[3]; \
980  \
981  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
982  oldSPos[1] = 0; \
983  oldSPos[2] = 0; \
984  \
985  unsigned int w1X, w1Y, w1Z; \
986  unsigned int w2X, w2Y, w2Z; \
987  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
988  \
989  unsigned short maxValue[4] = {}; \
990  unsigned short val[4] = {}; \
991  unsigned int A[4] = {}, B[4] = {}, C[4] = {}, D[4] = {}, \
992  E[4] = {}, F[4] = {}, G[4] = {}, H[4] = {};
993 //ETX
994 
995 //BTX
996 #define VTKKWRCHelper_InitializeCompositeGONN() \
997  unsigned char *magPtr = gradientMag[spos[2]] + spos[0]*mInc[0] + spos[1]*mInc[1];
998 //ETX
999 
1000 //BTX
1001 #define VTKKWRCHelper_InitializeCompositeShadeNN() \
1002  unsigned short *dirPtr = gradientDir[spos[2]] + spos[0]*dInc[0] + spos[1]*dInc[1];
1003 //ETX
1004 
1005 //BTX
1006 #define VTKKWRCHelper_InitializeCompositeOneNN() \
1007  mapper->ShiftVectorDown( pos, spos ); \
1008  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
1009  unsigned int color[3] = {0,0,0}; \
1010  unsigned short remainingOpacity = 0x7fff; \
1011  unsigned short tmp[4];
1012 //ETX
1013 
1014 //BTX
1015 #define VTKKWRCHelper_InitializeCompositeMultiNN() \
1016  mapper->ShiftVectorDown( pos, spos ); \
1017  T *dptr = data + spos[0]*inc[0] + spos[1]*inc[1] + spos[2]*inc[2]; \
1018  unsigned int color[3] = {0,0,0}; \
1019  unsigned int remainingOpacity = 0x7fff; \
1020  unsigned short tmp[4] = {}; \
1021  unsigned short val[4] = {};
1022 //ETX
1023 
1024 //BTX
1025 #define VTKKWRCHelper_InitializeCompositeOneTrilin() \
1026  T *dptr; \
1027  unsigned int oldSPos[3]; \
1028  \
1029  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
1030  oldSPos[1] = 0; \
1031  oldSPos[2] = 0; \
1032  \
1033  unsigned int w1X, w1Y, w1Z; \
1034  unsigned int w2X, w2Y, w2Z; \
1035  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
1036  \
1037  unsigned short val; \
1038  unsigned int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0; \
1039  \
1040  unsigned int color[3] = {0,0,0}; \
1041  unsigned short remainingOpacity = 0x7fff; \
1042  unsigned short tmp[4];
1043 //ETX
1044 
1045 //BTX
1046 #define VTKKWRCHelper_InitializeCompositeOneGOTrilin() \
1047  unsigned char *magPtrABCD = 0, *magPtrEFGH = 0; \
1048  unsigned short mag; \
1049  unsigned int mA=0,mB=0,mC=0,mD=0,mE=0,mF=0,mG=0,mH=0;
1050 //ETX
1051 
1052 //BTX
1053 #define VTKKWRCHelper_InitializeCompositeOneShadeTrilin() \
1054  unsigned short *dirPtrABCD = 0, *dirPtrEFGH = 0; \
1055  unsigned int normalA=0,normalB=0,normalC=0,normalD=0; \
1056  unsigned int normalE=0,normalF=0,normalG=0,normalH=0;
1057 //ETX
1058 
1059 //BTX
1060 #define VTKKWRCHelper_InitializeCompositeMultiTrilin() \
1061  T *dptr; \
1062  unsigned int oldSPos[3]; \
1063  \
1064  oldSPos[0] = (pos[0] >> VTKKW_FP_SHIFT) + 1; \
1065  oldSPos[1] = 0; \
1066  oldSPos[2] = 0; \
1067  \
1068  unsigned int w1X, w1Y, w1Z; \
1069  unsigned int w2X, w2Y, w2Z; \
1070  unsigned int w1Xw1Y, w2Xw1Y, w1Xw2Y, w2Xw2Y; \
1071  \
1072  unsigned short val[4] = {0, 0, 0, 0}; \
1073  unsigned int A[4] = {0, 0, 0, 0}; \
1074  unsigned int B[4] = {0, 0, 0, 0}; \
1075  unsigned int C[4] = {0, 0, 0, 0}; \
1076  unsigned int D[4] = {0, 0, 0, 0}; \
1077  unsigned int E[4] = {0, 0, 0, 0}; \
1078  unsigned int F[4] = {0, 0, 0, 0}; \
1079  unsigned int G[4] = {0, 0, 0, 0}; \
1080  unsigned int H[4] = {0, 0, 0, 0}; \
1081  \
1082  unsigned int color[3] = {0,0,0}; \
1083  unsigned short remainingOpacity = 0x7fff; \
1084  unsigned short tmp[4];
1085 //ETX
1086 
1087 //BTX
1088 #define VTKKWRCHelper_InitializeCompositeMultiGOTrilin() \
1089  unsigned char *magPtrABCD = 0, *magPtrEFGH = 0; \
1090  unsigned short mag[4] = {}; \
1091  unsigned int mA[4] = {}, mB[4] = {}, mC[4] = {}, \
1092  mD[4] = {}, mE[4] = {}, mF[4] = {}, \
1093  mG[4] = {}, mH[4] = {};
1094 //ETX
1095 
1096 //BTX
1097 #define VTKKWRCHelper_InitializeCompositeMultiShadeTrilin() \
1098  unsigned short *dirPtrABCD = 0, *dirPtrEFGH = 0; \
1099  unsigned int normalA[4],normalB[4],normalC[4],normalD[4]; \
1100  unsigned int normalE[4],normalF[4],normalG[4],normalH[4];
1101 //ETX
1102 
1103 //BTX
1104 #define VTKKWRCHelper_InitializationAndLoopStartNN() \
1105  VTKKWRCHelper_InitializeVariables(); \
1106  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1107  { \
1108  VTKKWRCHelper_OuterInitialization(); \
1109  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1110  { \
1111  VTKKWRCHelper_InnerInitialization();
1112 //ETX
1113 
1114 //BTX
1115 #define VTKKWRCHelper_InitializationAndLoopStartGONN() \
1116  VTKKWRCHelper_InitializeVariables(); \
1117  VTKKWRCHelper_InitializeVariablesGO(); \
1118  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1119  { \
1120  VTKKWRCHelper_OuterInitialization(); \
1121  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1122  { \
1123  VTKKWRCHelper_InnerInitialization();
1124 //ETX
1125 
1126 //BTX
1127 #define VTKKWRCHelper_InitializationAndLoopStartShadeNN() \
1128  VTKKWRCHelper_InitializeVariables(); \
1129  VTKKWRCHelper_InitializeVariablesShade(); \
1130  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1131  { \
1132  VTKKWRCHelper_OuterInitialization(); \
1133  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1134  { \
1135  VTKKWRCHelper_InnerInitialization();
1136 //ETX
1137 
1138 //BTX
1139 #define VTKKWRCHelper_InitializationAndLoopStartGOShadeNN() \
1140  VTKKWRCHelper_InitializeVariables(); \
1141  VTKKWRCHelper_InitializeVariablesGO(); \
1142  VTKKWRCHelper_InitializeVariablesShade(); \
1143  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1144  { \
1145  VTKKWRCHelper_OuterInitialization(); \
1146  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1147  { \
1148  VTKKWRCHelper_InnerInitialization();
1149 //ETX
1150 
1151 //BTX
1152 #define VTKKWRCHelper_InitializationAndLoopStartTrilin() \
1153  VTKKWRCHelper_InitializeVariables(); \
1154  VTKKWRCHelper_InitializeTrilinVariables(); \
1155  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1156  { \
1157  VTKKWRCHelper_OuterInitialization(); \
1158  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1159  { \
1160  VTKKWRCHelper_InnerInitialization();
1161 //ETX
1162 
1163 //BTX
1164 #define VTKKWRCHelper_InitializationAndLoopStartGOTrilin() \
1165  VTKKWRCHelper_InitializeVariables(); \
1166  VTKKWRCHelper_InitializeVariablesGO(); \
1167  VTKKWRCHelper_InitializeTrilinVariables(); \
1168  VTKKWRCHelper_InitializeTrilinVariablesGO(); \
1169  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1170  { \
1171  VTKKWRCHelper_OuterInitialization(); \
1172  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1173  { \
1174  VTKKWRCHelper_InnerInitialization();
1175 //ETX
1176 
1177 //BTX
1178 #define VTKKWRCHelper_InitializationAndLoopStartShadeTrilin() \
1179  VTKKWRCHelper_InitializeVariables(); \
1180  VTKKWRCHelper_InitializeVariablesShade(); \
1181  VTKKWRCHelper_InitializeTrilinVariables(); \
1182  VTKKWRCHelper_InitializeTrilinVariablesShade(); \
1183  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1184  { \
1185  VTKKWRCHelper_OuterInitialization(); \
1186  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1187  { \
1188  VTKKWRCHelper_InnerInitialization();
1189 //ETX
1190 
1191 //BTX
1192 #define VTKKWRCHelper_InitializationAndLoopStartGOShadeTrilin() \
1193  VTKKWRCHelper_InitializeVariables(); \
1194  VTKKWRCHelper_InitializeVariablesShade(); \
1195  VTKKWRCHelper_InitializeVariablesGO(); \
1196  VTKKWRCHelper_InitializeTrilinVariables(); \
1197  VTKKWRCHelper_InitializeTrilinVariablesShade(); \
1198  VTKKWRCHelper_InitializeTrilinVariablesGO(); \
1199  for ( j = 0; j < imageInUseSize[1]; j++ ) \
1200  { \
1201  VTKKWRCHelper_OuterInitialization(); \
1202  for ( i = rowBounds[j*2]; i <= rowBounds[j*2+1]; i++ ) \
1203  { \
1204  VTKKWRCHelper_InnerInitialization();
1205 //ETX
1206 
1207 //BTX
1208 #define VTKKWRCHelper_IncrementAndLoopEnd() \
1209  imagePtr+=4; \
1210  } \
1211  if ( (j/threadCount)%8 == 7 && threadID == 0) \
1212  { \
1213  double fargs[1]; \
1214  fargs[0] = static_cast<double>(j)/static_cast<float>(imageInUseSize[1]-1); \
1215  mapper->InvokeEvent( vtkCommand::VolumeMapperRenderProgressEvent, fargs ); \
1216  } \
1217  }
1218 //ETX
1219 
1220 //BTX
1221 #define VTKKWRCHelper_CroppingCheckTrilin( POS ) \
1222  if ( cropping ) \
1223  { \
1224  if ( mapper->CheckIfCropped( POS ) ) \
1225  { \
1226  continue; \
1227  } \
1228  }
1229 //ETX
1230 
1231 //BTX
1232 #define VTKKWRCHelper_CroppingCheckNN( POS ) \
1233  if ( cropping ) \
1234  { \
1235  if ( mapper->CheckIfCropped( POS ) ) \
1236  { \
1237  continue; \
1238  } \
1239  }
1240 //ETX
1241 
1242 //BTX
1243 #define VTKKWRCHelper_SpaceLeapSetup() \
1244  unsigned int mmpos[3]; \
1245  mmpos[0] = (pos[0] >> VTKKW_FPMM_SHIFT) + 1; \
1246  mmpos[1] = 0; \
1247  mmpos[2] = 0; \
1248  int mmvalid = 0;
1249 //ETX
1250 
1251 //BTX
1252 #define VTKKWRCHelper_SpaceLeapSetupMulti() \
1253  unsigned int mmpos[3]; \
1254  mmpos[0] = (pos[0] >> VTKKW_FPMM_SHIFT) + 1; \
1255  mmpos[1] = 0; \
1256  mmpos[2] = 0; \
1257  int mmvalid[4] = {0,0,0,0};
1258 //ETX
1259 
1260 
1261 //BTX
1262 #define VTKKWRCHelper_SpaceLeapCheck() \
1263  if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] || \
1264  pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] || \
1265  pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] ) \
1266  { \
1267  mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT; \
1268  mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT; \
1269  mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT; \
1270  mmvalid = mapper->CheckMinMaxVolumeFlag( mmpos, 0 ); \
1271  } \
1272  \
1273  if ( !mmvalid ) \
1274  { \
1275  continue; \
1276  }
1277 //ETX
1278 
1279 //BTX
1280 #define VTKKWRCHelper_MIPSpaceLeapCheck( MAXIDX, MAXIDXDEF, FLIP ) \
1281  if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] || \
1282  pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] || \
1283  pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] ) \
1284  { \
1285  mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT; \
1286  mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT; \
1287  mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT; \
1288  mmvalid = (MAXIDXDEF)? \
1289  (mapper->CheckMIPMinMaxVolumeFlag( mmpos, 0, MAXIDX, FLIP )):(1); \
1290  } \
1291  \
1292  if ( !mmvalid ) \
1293  { \
1294  continue; \
1295  }
1296 //ETX
1297 
1298 
1299 //BTX
1300 #define VTKKWRCHelper_MIPSpaceLeapPopulateMulti( MAXIDX, FLIP ) \
1301  if ( pos[0] >> VTKKW_FPMM_SHIFT != mmpos[0] || \
1302  pos[1] >> VTKKW_FPMM_SHIFT != mmpos[1] || \
1303  pos[2] >> VTKKW_FPMM_SHIFT != mmpos[2] ) \
1304  { \
1305  mmpos[0] = pos[0] >> VTKKW_FPMM_SHIFT; \
1306  mmpos[1] = pos[1] >> VTKKW_FPMM_SHIFT; \
1307  mmpos[2] = pos[2] >> VTKKW_FPMM_SHIFT; \
1308  for ( c = 0; c < components; c++ ) \
1309  { \
1310  mmvalid[c] = mapper->CheckMIPMinMaxVolumeFlag( mmpos, c, MAXIDX[c], FLIP ); \
1311  } \
1312  }
1313 //ETX
1314 
1315 //BTX
1316 #define VTKKWRCHelper_MIPSpaceLeapCheckMulti( COMP, FLIP ) mmvalid[COMP]
1317 //ETX
1318 
1319 #include "vtkRenderingVolumeModule.h" // For export macro
1320 #include "vtkObject.h"
1321 
1323 class vtkVolume;
1324 
1326 {
1327 public:
1330  void PrintSelf( ostream& os, vtkIndent indent );
1331 
1332  virtual void GenerateImage( int,
1333  int,
1334  vtkVolume *,
1336 
1337 protected:
1340 
1341 
1342 private:
1344  void operator=(const vtkFixedPointVolumeRayCastHelper&); // Not implemented.
1345 };
1346 
1347 #endif
1348 
1349 
1350 
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 *)