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