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