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