00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include "vp_global.h"
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #undef UNROLL_RUN_LOOP
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 #define MULTIPLE_MATERIALS
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #define GRAYSCALE
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 #define RLEVOLUME
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 #undef INDEX_VOLUME
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 #define ALL_ZERO 0
00161 #define TOP_NONZERO 1
00162 #define BOT_NONZERO 2
00163 #define ALL_NONZERO 3
00164
00165
00166 #define ALL_ZERO__ALL_ZERO ((ALL_ZERO << 2) | ALL_ZERO)
00167 #define ALL_ZERO__TOP_NONZERO ((ALL_ZERO << 2) | TOP_NONZERO)
00168 #define ALL_ZERO__BOT_NONZERO ((ALL_ZERO << 2) | BOT_NONZERO)
00169 #define ALL_ZERO__ALL_NONZERO ((ALL_ZERO << 2) | ALL_NONZERO)
00170 #define TOP_NONZERO__ALL_ZERO ((TOP_NONZERO << 2) | ALL_ZERO)
00171 #define TOP_NONZERO__TOP_NONZERO ((TOP_NONZERO << 2) | TOP_NONZERO)
00172 #define TOP_NONZERO__BOT_NONZERO ((TOP_NONZERO << 2) | BOT_NONZERO)
00173 #define TOP_NONZERO__ALL_NONZERO ((TOP_NONZERO << 2) | ALL_NONZERO)
00174 #define BOT_NONZERO__ALL_ZERO ((BOT_NONZERO << 2) | ALL_ZERO)
00175 #define BOT_NONZERO__TOP_NONZERO ((BOT_NONZERO << 2) | TOP_NONZERO)
00176 #define BOT_NONZERO__BOT_NONZERO ((BOT_NONZERO << 2) | BOT_NONZERO)
00177 #define BOT_NONZERO__ALL_NONZERO ((BOT_NONZERO << 2) | ALL_NONZERO)
00178 #define ALL_NONZERO__ALL_ZERO ((ALL_NONZERO << 2) | ALL_ZERO)
00179 #define ALL_NONZERO__TOP_NONZERO ((ALL_NONZERO << 2) | TOP_NONZERO)
00180 #define ALL_NONZERO__BOT_NONZERO ((ALL_NONZERO << 2) | BOT_NONZERO)
00181 #define ALL_NONZERO__ALL_NONZERO ((ALL_NONZERO << 2) | ALL_NONZERO)
00182
00183 #ifdef SKIP_ERT
00184 #define PIXEL_IS_OPAQUE(ipixel) 0
00185 #else
00186 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00187 #endif
00188
00189 #ifdef STATISTICS
00190 extern int vpResampleCount;
00191 extern int vpCompositeCount;
00192 extern int vpERTSkipCount;
00193 extern int vpERTSkipAgainCount;
00194 extern int vpERTUpdateCount;
00195 extern int vpSpecialZeroSkipCount;
00196 extern int vpRunFragmentCount;
00197 #define COUNT_RESAMPLE vpResampleCount++
00198 #define COUNT_COMPOSITE vpCompositeCount++
00199 #define COUNT_ERT_SKIP vpERTSkipCount++
00200 #define COUNT_ERT_SKIP_AGAIN vpERTSkipAgainCount++
00201 #define COUNT_ERT_UPDATE vpERTUpdateCount++
00202 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00203 #define COUNT_RUN_FRAGMENT vpRunFragmentCount++
00204 #else
00205 #define COUNT_RESAMPLE
00206 #define COUNT_COMPOSITE
00207 #define COUNT_ERT_SKIP
00208 #define COUNT_ERT_SKIP_AGAIN
00209 #define COUNT_ERT_UPDATE
00210 #define COUNT_SPECIAL_ZERO_SKIP
00211 #define COUNT_RUN_FRAGMENT
00212 #endif
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 void
00223 VPCompAC1NB (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00224 weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00225 run_lengths, voxel_data )
00226 vpContext *vpc;
00227 int icount;
00228 int jcount;
00229 int k;
00230 double slice_depth_cueing_dbl;
00231 GrayIntPixel *intimage;
00232 double weightTLdbl;
00233 double weightBLdbl;
00234 double weightTRdbl;
00235 double weightBRdbl;
00236
00237 unsigned char *run_lengths;
00238 void *voxel_data;
00239
00240 {
00241 int i, j;
00242 GrayIntPixel *ipixel;
00243 GrayIntPixel *ipixel2;
00244 int update_interval;
00245 float iopc;
00246 float iopc_inv;
00247 float acc_opc;
00248 float top_opc, bot_opc;
00249 #ifdef NO_REUSE_VOXEL
00250 #define voxels_loaded 0
00251 #define CLEAR_VOXELS_LOADED
00252 #define SET_VOXELS_LOADED
00253 #else
00254 int voxels_loaded;
00255
00256 #define CLEAR_VOXELS_LOADED voxels_loaded = 0
00257 #define SET_VOXELS_LOADED voxels_loaded = 1
00258 #endif
00259 float wgtTL, wgtBL,
00260 wgtTR, wgtBR;
00261
00262
00263 unsigned char *topRLElen;
00264 unsigned char *botRLElen;
00265 char *topRLEdata;
00266 char *botRLEdata;
00267 int toprun_count;
00268 int botrun_count;
00269 int last_run_state;
00270 int run_state;
00271 int final_run_state;
00272 float min_opacity;
00273 float max_opacity;
00274 float slice_depth_cueing;
00275 float *opac_correct;
00276 int ert_skip_count;
00277 int intermediate_width;
00278 int count;
00279 float *shade_table;
00280 int norm_offset;
00281 int shade_index;
00282 float shade_factor;
00283
00284
00285 #ifdef MULTIPLE_MATERIALS
00286 float *weight_table;
00287 int wgt_offset;
00288 int weight_index;
00289 int m, num_materials;
00290 float weight1, weight2;
00291 #endif
00292
00293 #ifdef GRAYSCALE
00294 float acc_clr;
00295 float top_clr, bot_clr;
00296 #endif
00297
00298 #ifdef RGB
00299 float acc_rclr;
00300 float acc_gclr;
00301 float acc_bclr;
00302 float top_rclr;
00303 float bot_rclr;
00304 float top_gclr;
00305 float bot_gclr;
00306 float top_bclr;
00307 float bot_bclr;
00308 #endif
00309
00310 #ifdef RLEVOLUME
00311 int voxel_istride;
00312 #endif
00313
00314 #ifdef RAWVOLUME
00315 int use_octree;
00316 MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00317
00318 int scans_left;
00319 int best_view_axis;
00320 unsigned char runlen_buf1[VP_MAX_VOLUME_DIM];
00321 unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00322 unsigned char *top_len_base;
00323 unsigned char *bot_len_base;
00324 int opac_param;
00325 float opacity;
00326 int opacity_int;
00327 int param0_offset;
00328 int param0_size;
00329 float *param0_table;
00330 int param1_offset;
00331 int param1_size;
00332 float *param1_table;
00333 int param2_offset;
00334 int param2_size;
00335 float *param2_table;
00336 #endif
00337
00338 #ifdef INDEX_VOLUME
00339 unsigned char *scanline_topRLElen;
00340 unsigned char *scanline_botRLElen;
00341 char *scanline_topRLEdata;
00342 char *scanline_botRLEdata;
00343 VoxelLocation *top_voxel_index;
00344 VoxelLocation *bot_voxel_index;
00345 VoxelLocation *vindex;
00346 int next_i;
00347 int next_scan;
00348 #endif
00349
00350 #ifdef CALLBACK
00351
00352 #ifdef GRAYSCALE
00353 void (*shade_func) ANSI_ARGS((void *, float *, void *));
00354 #endif
00355 #ifdef RGB
00356 void (*shade_func) ANSI_ARGS((void *, float *, float *, float *, void *));
00357 #endif
00358 void *client_data;
00359 #endif
00360
00361 #ifdef USE_SHADOW_BUFFER
00362 float *shadow_table;
00363 int shadow_width;
00364 GrayIntPixel *shadow_pixel;
00365 #ifdef GRAYSCALE
00366 float top_sclr, bot_sclr;
00367 #endif
00368 #ifdef RGB
00369 float top_rsclr;
00370 float bot_rsclr;
00371 float top_gsclr;
00372 float bot_gsclr;
00373 float top_bsclr;
00374 float bot_bsclr;
00375 #endif
00376 #endif
00377
00378 #ifdef DEBUG
00379 float trace_opcTL, trace_opcBL, trace_opcTR, trace_opcBR;
00380 float trace_rsclrTL, trace_rsclrBL, trace_rsclrTR, trace_rsclrBR;
00381 float trace_rclrTL, trace_rclrBL, trace_rclrTR, trace_rclrBR;
00382 float trace_gclrTL, trace_gclrBL, trace_gclrTR, trace_gclrBR;
00383 float trace_bclrTL, trace_bclrBL, trace_bclrTR, trace_bclrBR;
00384 GrayIntPixel *trace_pixel_ptr;
00385
00386 #ifdef COMPUTE_SHADOW_BUFFER
00387 int slice_u_int, shadow_slice_u_int;
00388 int slice_v_int, shadow_slice_v_int;
00389 #endif
00390 #endif
00391
00392 DECLARE_HIRES_TIME(t0);
00393 DECLARE_HIRES_TIME(t1);
00394
00395
00396
00397
00398
00399 GET_HIRES_TIME(vpc, t0);
00400
00401 wgtTL = weightTLdbl;
00402 wgtBL = weightBLdbl;
00403 wgtTR = weightTRdbl;
00404 wgtBR = weightBRdbl;
00405 slice_depth_cueing = slice_depth_cueing_dbl;
00406 min_opacity = vpc->min_opacity;
00407 max_opacity = vpc->max_opacity;
00408 #ifdef USE_SHADOW_BUFFER
00409 opac_correct = vpc->shadow_opac_correct;
00410 #else
00411 opac_correct = vpc->affine_opac_correct;
00412 #endif
00413 #ifdef COMPUTE_SHADOW_BUFFER
00414 intermediate_width = vpc->shadow_width;
00415 #else
00416 intermediate_width = vpc->intermediate_width;
00417 #endif
00418 #ifdef USE_SHADOW_BUFFER
00419 shadow_table = vpc->shadow_color_table;
00420 shadow_width = vpc->shadow_width;
00421 shadow_pixel = shadow_buffer;
00422 #endif
00423 ipixel = intimage;
00424 shade_table = vpc->shade_color_table;
00425 norm_offset = vpc->field_offset[vpc->color_field];
00426
00427 #ifdef MULTIPLE_MATERIALS
00428 weight_table = vpc->shade_weight_table;
00429 wgt_offset = vpc->field_offset[vpc->weight_field];
00430 num_materials = vpc->num_materials;
00431 #endif
00432
00433 #ifdef RLEVOLUME
00434 topRLEdata = voxel_data;
00435 botRLEdata = voxel_data;
00436 topRLElen = run_lengths;
00437 botRLElen = run_lengths;
00438 voxel_istride = vpc->rle_bytes_per_voxel;
00439 #endif
00440
00441 #ifdef RAWVOLUME
00442 ASSERT(vpc->num_clsfy_params > 0);
00443 ASSERT(vpc->num_clsfy_params < 3);
00444 param0_offset = vpc->field_offset[vpc->param_field[0]];
00445 param0_size = vpc->field_size[vpc->param_field[0]];
00446 param0_table = vpc->clsfy_table[0];
00447 if (vpc->num_clsfy_params > 1) {
00448 param1_offset = vpc->field_offset[vpc->param_field[1]];
00449 param1_size = vpc->field_size[vpc->param_field[1]];
00450 param1_table = vpc->clsfy_table[1];
00451 } else {
00452 param1_offset = 0;
00453 param1_size = 0;
00454 param1_table = NULL;
00455 }
00456 if (vpc->num_clsfy_params > 2) {
00457 param2_offset = vpc->field_offset[vpc->param_field[2]];
00458 param2_size = vpc->field_size[vpc->param_field[2]];
00459 param2_table = vpc->clsfy_table[2];
00460 } else {
00461 param2_offset = 0;
00462 param2_size = 0;
00463 param2_table = NULL;
00464 }
00465 if (vpc->mm_octree == NULL) {
00466 use_octree = 0;
00467 } else {
00468 use_octree = 1;
00469 best_view_axis = vpc->best_view_axis;
00470 VPInitOctreeLevelStack(vpc, level_stack, best_view_axis, k);
00471 scans_left = 0;
00472 bot_len_base = runlen_buf1;
00473 }
00474 #endif
00475
00476 #ifdef CALLBACK
00477 shade_func = vpc->shade_func;
00478 client_data = vpc->client_data;
00479 ASSERT(shade_func != NULL);
00480 #endif
00481
00482 #ifdef DEBUG
00483 trace_pixel_ptr = 0;
00484 if (vpc->trace_u >= 0 && vpc->trace_v >= 0) {
00485 #ifdef GRAYSCALE
00486 trace_pixel_ptr = &vpc->int_image.gray_intim[vpc->trace_u +
00487 vpc->trace_v*vpc->intermediate_width];
00488 #endif
00489 #ifdef RGB
00490 trace_pixel_ptr = &vpc->int_image.rgb_intim[vpc->trace_u +
00491 vpc->trace_v*vpc->intermediate_width];
00492 #endif
00493 #ifdef COMPUTE_SHADOW_BUFFER
00494 slice_u_int = (int)ceil(vpc->shear_i * vpc->trace_shadow_k +
00495 vpc->trans_i) - 1;
00496 shadow_slice_u_int = (int)ceil(vpc->shadow_shear_i *
00497 vpc->trace_shadow_k + vpc->shadow_trans_i) - 1;
00498 slice_v_int = (int)ceil(vpc->shear_j * vpc->trace_shadow_k
00499 + vpc->trans_j) - 1;
00500 shadow_slice_v_int = (int)ceil(vpc->shadow_shear_j *
00501 vpc->trace_shadow_k + vpc->shadow_trans_j) - 1;
00502 trace_pixel_ptr = &vpc->shadow_buffer[vpc->trace_u +
00503 shadow_slice_u_int - slice_u_int +
00504 (vpc->trace_v + shadow_slice_v_int -
00505 slice_v_int)*vpc->shadow_width];
00506 #endif
00507 }
00508 #endif
00509
00510
00511
00512
00513
00514 for (j = 0; j <= jcount; j++) {
00515
00516
00517
00518
00519
00520 i = icount;
00521 CLEAR_VOXELS_LOADED;
00522 last_run_state = ALL_ZERO;
00523
00524 #ifdef RAWVOLUME
00525 botRLEdata = (char *)voxel_data + j*voxel_jstride;
00526 topRLEdata = botRLEdata - voxel_jstride;
00527 if (!use_octree) {
00528 if (j == 0) {
00529 run_state = BOT_NONZERO;
00530 toprun_count = icount+2;
00531 botrun_count = icount;
00532 } else if (j == jcount) {
00533 run_state = TOP_NONZERO;
00534 toprun_count = icount;
00535 botrun_count = icount+2;
00536 } else {
00537 run_state = ALL_NONZERO;
00538 toprun_count = icount;
00539 botrun_count = icount;
00540 }
00541 } else
00542 #endif
00543 if (j == 0) {
00544 run_state = BOT_NONZERO;
00545 toprun_count = icount+2;
00546 botrun_count = 0;
00547 } else if (j == jcount) {
00548 run_state = TOP_NONZERO;
00549 toprun_count = 0;
00550 botrun_count = icount+2;
00551 } else {
00552 run_state = ALL_NONZERO;
00553 toprun_count = 0;
00554 botrun_count = 0;
00555 }
00556
00557 #ifdef INDEX_VOLUME
00558 scanline_topRLElen = topRLElen;
00559 scanline_botRLElen = botRLElen;
00560 scanline_topRLEdata = topRLEdata;
00561 scanline_botRLEdata = botRLEdata;
00562 if (j == 0) {
00563 top_voxel_index = voxel_index;
00564 bot_voxel_index = voxel_index;
00565 } else {
00566 top_voxel_index = bot_voxel_index;
00567 bot_voxel_index += icount;
00568 }
00569 #endif
00570
00571
00572
00573
00574
00575
00576 #ifdef RAWVOLUME
00577 if (use_octree) {
00578 top_len_base = bot_len_base;
00579 if (scans_left == 0) {
00580 if (bot_len_base == runlen_buf1)
00581 bot_len_base = runlen_buf2;
00582 else
00583 bot_len_base = runlen_buf1;
00584
00585 GET_HIRES_TIME(vpc, t1);
00586 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00587 COPY_HIRES_TIME(t0, t1);
00588
00589 scans_left = VPComputeScanRuns(vpc, level_stack, bot_len_base,
00590 best_view_axis, j, icount);
00591
00592 GET_HIRES_TIME(vpc, t1);
00593 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_OCTREE, t0, t1);
00594 COPY_HIRES_TIME(t0, t1);
00595 }
00596 #ifdef DEBUG
00597 if (j > 0)
00598 VPCheckRuns(vpc, top_len_base, best_view_axis, k, j-1);
00599 if (j < jcount)
00600 VPCheckRuns(vpc, bot_len_base, best_view_axis, k, j);
00601 #endif
00602 scans_left--;
00603 topRLElen = top_len_base;
00604 botRLElen = bot_len_base;
00605 }
00606 #endif
00607
00608
00609
00610
00611
00612 Debug((vpc, VPDEBUG_COMPOSITE, "StartIScan(u=%d,v=%d)\n",
00613 (((int)ipixel - (int)vpc->int_image.gray_intim) /
00614 sizeof(GrayIntPixel)) % vpc->intermediate_width,
00615 (((int)ipixel - (int)vpc->int_image.gray_intim) /
00616 sizeof(GrayIntPixel)) / vpc->intermediate_width));
00617
00618 #ifdef UNROLL_RUN_LOOP
00619 while (i > 0) {
00620 #else
00621 while (i >= 0) {
00622 #endif
00623
00624
00625
00626
00627 if (last_run_state == ALL_ZERO) {
00628 #ifndef UNROLL_RUN_LOOP
00629 if (i == 0) {
00630 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00631 ipixel += 1;
00632 final_run_state = ALL_ZERO;
00633 i = -1;
00634 break;
00635 }
00636 #endif
00637
00638
00639 while (toprun_count == 0) {
00640 toprun_count = *topRLElen++;
00641 run_state ^= 1;
00642 }
00643 while (botrun_count == 0) {
00644 botrun_count = *botRLElen++;
00645 run_state ^= 2;
00646 }
00647 if (run_state == ALL_ZERO) {
00648 COUNT_SPECIAL_ZERO_SKIP;
00649
00650
00651 count = MIN(toprun_count, botrun_count);
00652 toprun_count -= count;
00653 botrun_count -= count;
00654 ipixel += count;
00655 ;
00656 ;
00657 i -= count;
00658 ASSERT(i >= 0);
00659 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(%d)\n", count));
00660 continue;
00661 }
00662 }
00663
00664 #ifndef SKIP_ERT
00665
00666
00667
00668
00669 if ((ert_skip_count = ipixel->lnk) != 0) {
00670
00671 GET_HIRES_TIME(vpc, t1);
00672 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00673 COPY_HIRES_TIME(t0, t1);
00674
00675 COUNT_ERT_SKIP;
00676
00677 #ifndef UNROLL_RUN_LOOP
00678 if (i == 0) {
00679 ipixel += 1;
00680 final_run_state = last_run_state;
00681 i = -1;
00682 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00683 break;
00684 }
00685 #endif
00686
00687
00688 if (ert_skip_count < i &&
00689 (count = ipixel[ert_skip_count].lnk) != 0) {
00690
00691 do {
00692 COUNT_ERT_SKIP_AGAIN;
00693 ert_skip_count += count;
00694 } while (ert_skip_count < i &&
00695 (count = ipixel[ert_skip_count].lnk) != 0);
00696
00697
00698
00699
00700
00701
00702 ipixel2 = ipixel;
00703 update_interval = 1;
00704 count = ert_skip_count - 1;
00705 while (count > 0) {
00706 COUNT_ERT_UPDATE;
00707 ipixel2 += update_interval;
00708 if (count > 255)
00709 ipixel2->lnk = 255;
00710 else
00711 ipixel2->lnk = count;
00712 update_interval *= 2;
00713 count -= update_interval;
00714 }
00715
00716
00717 COUNT_ERT_UPDATE;
00718 if (ert_skip_count > 255)
00719 ert_skip_count = 255;
00720 ipixel->lnk = ert_skip_count;
00721 }
00722
00723
00724 if (ert_skip_count > i)
00725 ert_skip_count = i;
00726 Debug((vpc, VPDEBUG_COMPOSITE,"ERTSkip(%d)\n",ert_skip_count));
00727 ipixel += ert_skip_count;
00728 CLEAR_VOXELS_LOADED;
00729
00730 #ifdef INDEX_VOLUME
00731
00732 next_i = icount - i + ert_skip_count;
00733 if (next_i == icount) {
00734 next_i--;
00735 next_scan = 1;
00736 } else {
00737 next_scan = 0;
00738 }
00739
00740
00741 vindex = &top_voxel_index[next_i];
00742 toprun_count = vindex->run_count;
00743 topRLElen = scanline_topRLElen + vindex->len_offset;
00744 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00745 run_state &= ~1;
00746 topRLEdata = scanline_topRLEdata +
00747 (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00748 } else {
00749 run_state |= 1;
00750 topRLEdata = scanline_topRLEdata + vindex->data_offset;
00751 }
00752
00753
00754 vindex = &bot_voxel_index[next_i];
00755 botrun_count = vindex->run_count;
00756 botRLElen = scanline_botRLElen + vindex->len_offset;
00757 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00758 run_state &= ~2;
00759 botRLEdata = scanline_botRLEdata +
00760 (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00761 } else {
00762 run_state |= 2;
00763 botRLEdata = scanline_botRLEdata + vindex->data_offset;
00764 }
00765
00766
00767 if (next_scan) {
00768
00769 while (toprun_count == 0) {
00770 toprun_count = *topRLElen++;
00771 run_state ^= 1;
00772 }
00773 toprun_count--;
00774 if (run_state & 1) {
00775 topRLEdata += 1 * voxel_istride;
00776 } else {
00777 ;
00778 }
00779
00780
00781 while (botrun_count == 0) {
00782 botrun_count = *botRLElen++;
00783 run_state ^= 2;
00784 }
00785 botrun_count--;
00786 if (run_state & 2) {
00787 botRLEdata += 1 * voxel_istride;
00788 } else {
00789 ;
00790 }
00791 }
00792
00793 #else
00794
00795 count = ert_skip_count;
00796 for (;;) {
00797 if (toprun_count >= count) {
00798 toprun_count -= count;
00799 if (run_state & 1) {
00800 topRLEdata += count * voxel_istride;
00801 } else {
00802 ;
00803 }
00804 break;
00805 } else {
00806 count -= toprun_count;
00807 if (run_state & 1) {
00808 topRLEdata += toprun_count * voxel_istride;
00809 } else {
00810 ;
00811 }
00812 toprun_count = *topRLElen++;
00813 if (toprun_count == 0)
00814 toprun_count = *topRLElen++;
00815 else
00816 run_state ^= 1;
00817 }
00818 }
00819
00820
00821 count = ert_skip_count;
00822 for (;;) {
00823 if (botrun_count >= count) {
00824 botrun_count -= count;
00825 if (run_state & 2) {
00826 botRLEdata += count * voxel_istride;
00827 } else {
00828 ;
00829 }
00830 break;
00831 } else {
00832 count -= botrun_count;
00833 if (run_state & 2) {
00834 botRLEdata += botrun_count * voxel_istride;
00835 } else {
00836 ;
00837 }
00838 botrun_count = *botRLElen++;
00839 if (botrun_count == 0)
00840 botrun_count = *botRLElen++;
00841 else
00842 run_state ^= 2;
00843 }
00844 }
00845 #endif
00846 i -= ert_skip_count;
00847 last_run_state = run_state;
00848 if (i == 0) {
00849 #ifdef UNROLL_RUN_LOOP
00850 break;
00851 #else
00852 if (last_run_state == ALL_ZERO) {
00853 ipixel += 1;
00854 final_run_state = ALL_ZERO;
00855 i = -1;
00856 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00857 break;
00858 }
00859 if (ipixel->lnk != 0) {
00860 ipixel += 1;
00861 final_run_state = last_run_state;
00862 i = -1;
00863 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00864 break;
00865 }
00866 #endif
00867 }
00868
00869 GET_HIRES_TIME(vpc, t1);
00870 STORE_HIRES_TIME(vpc, VPTIMER_ERT, t0, t1);
00871 COPY_HIRES_TIME(t0, t1);
00872 }
00873 ASSERT(ipixel->opcflt < max_opacity);
00874 #endif
00875
00876
00877
00878
00879
00880 #ifndef UNROLL_RUN_LOOP
00881 if (i == 0) {
00882 final_run_state = last_run_state;
00883 run_state = ALL_ZERO;
00884 i = -1;
00885 count = 1;
00886 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
00887 } else {
00888 #endif
00889
00890 while (toprun_count == 0) {
00891 toprun_count = *topRLElen++;
00892 run_state ^= 1;
00893 }
00894 while (botrun_count == 0) {
00895 botrun_count = *botRLElen++;
00896 run_state ^= 2;
00897 }
00898
00899
00900 count = MIN(toprun_count, botrun_count);
00901 toprun_count -= count;
00902 botrun_count -= count;
00903 i -= count;
00904 Debug((vpc, VPDEBUG_COMPOSITE, "Run(%d)\n", count));
00905 ASSERT(i >= 0);
00906 #ifndef UNROLL_RUN_LOOP
00907 }
00908 #endif
00909 COUNT_RUN_FRAGMENT;
00910
00911
00912
00913
00914
00915 GET_HIRES_TIME(vpc, t1);
00916 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00917 COPY_HIRES_TIME(t0, t1);
00918
00919 #ifdef SKIP_COMPOSITE
00920 switch (run_state) {
00921 case ALL_ZERO:
00922 ipixel += count;
00923 ;
00924 ;
00925 count = 0;
00926 break;
00927 case TOP_NONZERO:
00928 ipixel += count;
00929 topRLEdata += count * voxel_istride;
00930 ;
00931 count = 0;
00932 break;
00933 case BOT_NONZERO:
00934 ipixel += count;
00935 ;
00936 botRLEdata += count * voxel_istride;
00937 count = 0;
00938 break;
00939 case ALL_NONZERO:
00940 ipixel += count;
00941 topRLEdata += count * voxel_istride;
00942 botRLEdata += count * voxel_istride;
00943 count = 0;
00944 break;
00945 }
00946 #else
00947 #ifdef UNROLL_RUN_LOOP
00948
00949 switch ((last_run_state << 2) | run_state) {
00950 case ALL_ZERO__ALL_ZERO:
00951
00952 ipixel += count;
00953 ;
00954 ;
00955 count = 0;
00956 break;
00957 case TOP_NONZERO__ALL_ZERO:
00958
00959
00960 if (!voxels_loaded) {
00961
00962 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
00963
00964
00965 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
00966 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
00967
00968
00969
00970 top_clr =
00971 shade_table[shade_index + 1*0 + 0] *
00972 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00973 ;
00974 for (m = 1; m < num_materials; m++) {
00975
00976
00977 top_clr +=
00978 shade_table[shade_index + 1*m + 0] *
00979 weight_table[weight_index + m];
00980 ;
00981 };
00982 shade_factor = top_opc * slice_depth_cueing;
00983
00984 top_clr *= shade_factor;
00985 ;
00986 }
00987
00988 #ifdef DEBUG
00989 if (ipixel == trace_pixel_ptr) {
00990 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
00991 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
00992 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
00993 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
00994 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
00995 }
00996 #endif
00997 ;
00998
00999 acc_opc = top_opc * wgtTL;
01000 acc_clr = top_clr * wgtTL;
01001
01002 #ifdef DEBUG
01003 if (ipixel == trace_pixel_ptr) {
01004 trace_opcTL = top_opc;
01005 trace_rclrTL = top_clr;
01006
01007 }
01008 #endif
01009 ;
01010
01011 COUNT_RESAMPLE;
01012 if (acc_opc > min_opacity) {
01013 COUNT_COMPOSITE;
01014 iopc = ipixel->opcflt;
01015 # ifndef SKIP_ERT
01016 ASSERT(iopc < max_opacity);
01017 # endif
01018 iopc_inv = (float)1. - iopc;
01019 ipixel->clrflt += acc_clr * iopc_inv;
01020 iopc += acc_opc * iopc_inv;
01021 ipixel->opcflt = iopc;
01022
01023 #ifdef DEBUG
01024 if (ipixel == trace_pixel_ptr) {
01025 #ifdef COMPUTE_SHADOW_BUFFER
01026 printf("{%3d} %3d %3d", k, icount-i-count, j);
01027 #else
01028 printf("[%3d] %3d %3d", k, icount-i-count, j);
01029 #endif
01030 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01031 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01032 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01033 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01034 printf(" %3.0f %3.0f\n", iopc*255.,
01035 ipixel->clrflt);
01036
01037
01038 }
01039 #endif
01040 ;
01041 # ifndef SKIP_ERT
01042 if (iopc >= max_opacity) {
01043 ASSERT(ipixel->lnk == 0);
01044 ipixel->lnk = 1;
01045 }
01046 # endif
01047 };
01048 ipixel += count;
01049 ;
01050 ;
01051 count = 0;
01052 break;
01053 case BOT_NONZERO__ALL_ZERO:
01054
01055
01056 if (!voxels_loaded) {
01057
01058 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01059
01060
01061 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01062 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01063
01064
01065
01066 bot_clr =
01067 shade_table[shade_index + 1*0 + 0] *
01068 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01069 ;
01070 for (m = 1; m < num_materials; m++) {
01071
01072
01073 bot_clr +=
01074 shade_table[shade_index + 1*m + 0] *
01075 weight_table[weight_index + m];
01076 ;
01077 };
01078 shade_factor = bot_opc * slice_depth_cueing;
01079
01080 bot_clr *= shade_factor;
01081 ;
01082 }
01083
01084 #ifdef DEBUG
01085 if (ipixel == trace_pixel_ptr) {
01086 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01087 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01088 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01089 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01090 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01091 }
01092 #endif
01093 ;
01094
01095 acc_opc = bot_opc * wgtBL;
01096 acc_clr = bot_clr * wgtBL;
01097
01098 #ifdef DEBUG
01099 if (ipixel == trace_pixel_ptr) {
01100 trace_opcBL = bot_opc;
01101 trace_rclrBL = bot_clr;
01102
01103 }
01104 #endif
01105 ;
01106
01107 COUNT_RESAMPLE;
01108 if (acc_opc > min_opacity) {
01109 COUNT_COMPOSITE;
01110 iopc = ipixel->opcflt;
01111 # ifndef SKIP_ERT
01112 ASSERT(iopc < max_opacity);
01113 # endif
01114 iopc_inv = (float)1. - iopc;
01115 ipixel->clrflt += acc_clr * iopc_inv;
01116 iopc += acc_opc * iopc_inv;
01117 ipixel->opcflt = iopc;
01118
01119 #ifdef DEBUG
01120 if (ipixel == trace_pixel_ptr) {
01121 #ifdef COMPUTE_SHADOW_BUFFER
01122 printf("{%3d} %3d %3d", k, icount-i-count, j);
01123 #else
01124 printf("[%3d] %3d %3d", k, icount-i-count, j);
01125 #endif
01126 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01127 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01128 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01129 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01130 printf(" %3.0f %3.0f\n", iopc*255.,
01131 ipixel->clrflt);
01132
01133
01134 }
01135 #endif
01136 ;
01137 # ifndef SKIP_ERT
01138 if (iopc >= max_opacity) {
01139 ASSERT(ipixel->lnk == 0);
01140 ipixel->lnk = 1;
01141 }
01142 # endif
01143 };
01144 ipixel += count;
01145 ;
01146 ;
01147 count = 0;
01148 break;
01149 case ALL_NONZERO__ALL_ZERO:
01150
01151
01152 if (!voxels_loaded) {
01153
01154 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01155
01156
01157 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01158 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01159
01160
01161
01162 top_clr =
01163 shade_table[shade_index + 1*0 + 0] *
01164 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01165 ;
01166 for (m = 1; m < num_materials; m++) {
01167
01168
01169 top_clr +=
01170 shade_table[shade_index + 1*m + 0] *
01171 weight_table[weight_index + m];
01172 ;
01173 };
01174 shade_factor = top_opc * slice_depth_cueing;
01175
01176 top_clr *= shade_factor;
01177 ;
01178
01179 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01180
01181
01182 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01183 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01184
01185
01186
01187 bot_clr =
01188 shade_table[shade_index + 1*0 + 0] *
01189 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01190 ;
01191 for (m = 1; m < num_materials; m++) {
01192
01193
01194 bot_clr +=
01195 shade_table[shade_index + 1*m + 0] *
01196 weight_table[weight_index + m];
01197 ;
01198 };
01199 shade_factor = bot_opc * slice_depth_cueing;
01200
01201 bot_clr *= shade_factor;
01202 ;
01203 }
01204
01205 #ifdef DEBUG
01206 if (ipixel == trace_pixel_ptr) {
01207 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01208 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01209 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01210 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01211 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01212 }
01213 #endif
01214 ;
01215
01216 acc_opc = top_opc * wgtTL;
01217 acc_clr = top_clr * wgtTL;
01218
01219 #ifdef DEBUG
01220 if (ipixel == trace_pixel_ptr) {
01221 trace_opcTL = top_opc;
01222 trace_rclrTL = top_clr;
01223
01224 }
01225 #endif
01226 ;
01227
01228 acc_opc += bot_opc * wgtBL;
01229 acc_clr += bot_clr * wgtBL;
01230
01231 #ifdef DEBUG
01232 if (ipixel == trace_pixel_ptr) {
01233 trace_opcBL = bot_opc;
01234 trace_rclrBL = bot_clr;
01235
01236 }
01237 #endif
01238 ;
01239
01240 COUNT_RESAMPLE;
01241 if (acc_opc > min_opacity) {
01242 COUNT_COMPOSITE;
01243 iopc = ipixel->opcflt;
01244 # ifndef SKIP_ERT
01245 ASSERT(iopc < max_opacity);
01246 # endif
01247 iopc_inv = (float)1. - iopc;
01248 ipixel->clrflt += acc_clr * iopc_inv;
01249 iopc += acc_opc * iopc_inv;
01250 ipixel->opcflt = iopc;
01251
01252 #ifdef DEBUG
01253 if (ipixel == trace_pixel_ptr) {
01254 #ifdef COMPUTE_SHADOW_BUFFER
01255 printf("{%3d} %3d %3d", k, icount-i-count, j);
01256 #else
01257 printf("[%3d] %3d %3d", k, icount-i-count, j);
01258 #endif
01259 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01260 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01261 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01262 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01263 printf(" %3.0f %3.0f\n", iopc*255.,
01264 ipixel->clrflt);
01265
01266
01267 }
01268 #endif
01269 ;
01270 # ifndef SKIP_ERT
01271 if (iopc >= max_opacity) {
01272 ASSERT(ipixel->lnk == 0);
01273 ipixel->lnk = 1;
01274 }
01275 # endif
01276 };
01277 ipixel += count;
01278 ;
01279 ;
01280 count = 0;
01281 break;
01282 case ALL_ZERO__TOP_NONZERO:
01283
01284
01285 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01286
01287
01288 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01289 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01290
01291
01292
01293 top_clr =
01294 shade_table[shade_index + 1*0 + 0] *
01295 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01296 ;
01297 for (m = 1; m < num_materials; m++) {
01298
01299
01300 top_clr +=
01301 shade_table[shade_index + 1*m + 0] *
01302 weight_table[weight_index + m];
01303 ;
01304 };
01305 shade_factor = top_opc * slice_depth_cueing;
01306
01307 top_clr *= shade_factor;
01308 ;
01309
01310 #ifdef DEBUG
01311 if (ipixel == trace_pixel_ptr) {
01312 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01313 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01314 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01315 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01316 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01317 }
01318 #endif
01319 ;
01320
01321 acc_opc = top_opc * wgtTR;
01322 acc_clr = top_clr * wgtTR;
01323
01324 #ifdef DEBUG
01325 if (ipixel == trace_pixel_ptr) {
01326 trace_opcTR = top_opc;
01327 trace_rclrTR = top_clr;
01328
01329 }
01330 #endif
01331 ;
01332
01333 COUNT_RESAMPLE;
01334 if (acc_opc > min_opacity) {
01335 COUNT_COMPOSITE;
01336 iopc = ipixel->opcflt;
01337 # ifndef SKIP_ERT
01338 ASSERT(iopc < max_opacity);
01339 # endif
01340 iopc_inv = (float)1. - iopc;
01341 ipixel->clrflt += acc_clr * iopc_inv;
01342 iopc += acc_opc * iopc_inv;
01343 ipixel->opcflt = iopc;
01344
01345 #ifdef DEBUG
01346 if (ipixel == trace_pixel_ptr) {
01347 #ifdef COMPUTE_SHADOW_BUFFER
01348 printf("{%3d} %3d %3d", k, icount-i-count, j);
01349 #else
01350 printf("[%3d] %3d %3d", k, icount-i-count, j);
01351 #endif
01352 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01353 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01354 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01355 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01356 printf(" %3.0f %3.0f\n", iopc*255.,
01357 ipixel->clrflt);
01358
01359
01360 }
01361 #endif
01362 ;
01363 # ifndef SKIP_ERT
01364 if (iopc >= max_opacity) {
01365 ASSERT(ipixel->lnk == 0);
01366 ipixel->lnk = 1;
01367 }
01368 # endif
01369 };
01370 ipixel += 1;
01371 topRLEdata += 1 * voxel_istride;
01372 ;
01373 count--;
01374 SET_VOXELS_LOADED;
01375
01376
01377
01378 while (count > 0) {
01379 if (PIXEL_IS_OPAQUE(ipixel))
01380 break;
01381 if (!voxels_loaded) {
01382
01383 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01384
01385
01386 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01387 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01388
01389
01390
01391 top_clr =
01392 shade_table[shade_index + 1*0 + 0] *
01393 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01394 ;
01395 for (m = 1; m < num_materials; m++) {
01396
01397
01398 top_clr +=
01399 shade_table[shade_index + 1*m + 0] *
01400 weight_table[weight_index + m];
01401 ;
01402 };
01403 shade_factor = top_opc * slice_depth_cueing;
01404
01405 top_clr *= shade_factor;
01406 ;
01407 }
01408
01409 #ifdef DEBUG
01410 if (ipixel == trace_pixel_ptr) {
01411 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01412 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01413 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01414 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01415 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01416 }
01417 #endif
01418 ;
01419
01420 acc_opc = top_opc * wgtTL;
01421 acc_clr = top_clr * wgtTL;
01422
01423 #ifdef DEBUG
01424 if (ipixel == trace_pixel_ptr) {
01425 trace_opcTL = top_opc;
01426 trace_rclrTL = top_clr;
01427
01428 }
01429 #endif
01430 ;
01431
01432 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01433
01434
01435 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01436 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01437
01438
01439
01440 top_clr =
01441 shade_table[shade_index + 1*0 + 0] *
01442 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01443 ;
01444 for (m = 1; m < num_materials; m++) {
01445
01446
01447 top_clr +=
01448 shade_table[shade_index + 1*m + 0] *
01449 weight_table[weight_index + m];
01450 ;
01451 };
01452 shade_factor = top_opc * slice_depth_cueing;
01453
01454 top_clr *= shade_factor;
01455 ;
01456
01457 acc_opc += top_opc * wgtTR;
01458 acc_clr += top_clr * wgtTR;
01459
01460 #ifdef DEBUG
01461 if (ipixel == trace_pixel_ptr) {
01462 trace_opcTR = top_opc;
01463 trace_rclrTR = top_clr;
01464
01465 }
01466 #endif
01467 ;
01468
01469 COUNT_RESAMPLE;
01470 if (acc_opc > min_opacity) {
01471 COUNT_COMPOSITE;
01472 iopc = ipixel->opcflt;
01473 # ifndef SKIP_ERT
01474 ASSERT(iopc < max_opacity);
01475 # endif
01476 iopc_inv = (float)1. - iopc;
01477 ipixel->clrflt += acc_clr * iopc_inv;
01478 iopc += acc_opc * iopc_inv;
01479 ipixel->opcflt = iopc;
01480
01481 #ifdef DEBUG
01482 if (ipixel == trace_pixel_ptr) {
01483 #ifdef COMPUTE_SHADOW_BUFFER
01484 printf("{%3d} %3d %3d", k, icount-i-count, j);
01485 #else
01486 printf("[%3d] %3d %3d", k, icount-i-count, j);
01487 #endif
01488 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01489 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01490 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01491 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01492 printf(" %3.0f %3.0f\n", iopc*255.,
01493 ipixel->clrflt);
01494
01495
01496 }
01497 #endif
01498 ;
01499 # ifndef SKIP_ERT
01500 if (iopc >= max_opacity) {
01501 ASSERT(ipixel->lnk == 0);
01502 ipixel->lnk = 1;
01503 }
01504 # endif
01505 };
01506 ipixel += 1;
01507 topRLEdata += 1 * voxel_istride;
01508 ;
01509 count--;
01510 SET_VOXELS_LOADED;
01511 }
01512 break;
01513 case TOP_NONZERO__TOP_NONZERO:
01514
01515
01516 while (count > 0) {
01517 if (PIXEL_IS_OPAQUE(ipixel))
01518 break;
01519 if (!voxels_loaded) {
01520
01521 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01522
01523
01524 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01525 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01526
01527
01528
01529 top_clr =
01530 shade_table[shade_index + 1*0 + 0] *
01531 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01532 ;
01533 for (m = 1; m < num_materials; m++) {
01534
01535
01536 top_clr +=
01537 shade_table[shade_index + 1*m + 0] *
01538 weight_table[weight_index + m];
01539 ;
01540 };
01541 shade_factor = top_opc * slice_depth_cueing;
01542
01543 top_clr *= shade_factor;
01544 ;
01545 }
01546
01547 #ifdef DEBUG
01548 if (ipixel == trace_pixel_ptr) {
01549 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01550 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01551 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01552 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01553 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01554 }
01555 #endif
01556 ;
01557
01558 acc_opc = top_opc * wgtTL;
01559 acc_clr = top_clr * wgtTL;
01560
01561 #ifdef DEBUG
01562 if (ipixel == trace_pixel_ptr) {
01563 trace_opcTL = top_opc;
01564 trace_rclrTL = top_clr;
01565
01566 }
01567 #endif
01568 ;
01569
01570 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01571
01572
01573 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01574 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01575
01576
01577
01578 top_clr =
01579 shade_table[shade_index + 1*0 + 0] *
01580 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01581 ;
01582 for (m = 1; m < num_materials; m++) {
01583
01584
01585 top_clr +=
01586 shade_table[shade_index + 1*m + 0] *
01587 weight_table[weight_index + m];
01588 ;
01589 };
01590 shade_factor = top_opc * slice_depth_cueing;
01591
01592 top_clr *= shade_factor;
01593 ;
01594
01595 acc_opc += top_opc * wgtTR;
01596 acc_clr += top_clr * wgtTR;
01597
01598 #ifdef DEBUG
01599 if (ipixel == trace_pixel_ptr) {
01600 trace_opcTR = top_opc;
01601 trace_rclrTR = top_clr;
01602
01603 }
01604 #endif
01605 ;
01606
01607 COUNT_RESAMPLE;
01608 if (acc_opc > min_opacity) {
01609 COUNT_COMPOSITE;
01610 iopc = ipixel->opcflt;
01611 # ifndef SKIP_ERT
01612 ASSERT(iopc < max_opacity);
01613 # endif
01614 iopc_inv = (float)1. - iopc;
01615 ipixel->clrflt += acc_clr * iopc_inv;
01616 iopc += acc_opc * iopc_inv;
01617 ipixel->opcflt = iopc;
01618
01619 #ifdef DEBUG
01620 if (ipixel == trace_pixel_ptr) {
01621 #ifdef COMPUTE_SHADOW_BUFFER
01622 printf("{%3d} %3d %3d", k, icount-i-count, j);
01623 #else
01624 printf("[%3d] %3d %3d", k, icount-i-count, j);
01625 #endif
01626 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01627 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01628 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01629 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01630 printf(" %3.0f %3.0f\n", iopc*255.,
01631 ipixel->clrflt);
01632
01633
01634 }
01635 #endif
01636 ;
01637 # ifndef SKIP_ERT
01638 if (iopc >= max_opacity) {
01639 ASSERT(ipixel->lnk == 0);
01640 ipixel->lnk = 1;
01641 }
01642 # endif
01643 };
01644 ipixel += 1;
01645 topRLEdata += 1 * voxel_istride;
01646 ;
01647 count--;
01648 SET_VOXELS_LOADED;
01649 }
01650 break;
01651 case BOT_NONZERO__TOP_NONZERO:
01652
01653
01654 if (!voxels_loaded) {
01655
01656 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01657
01658
01659 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01660 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01661
01662
01663
01664 bot_clr =
01665 shade_table[shade_index + 1*0 + 0] *
01666 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01667 ;
01668 for (m = 1; m < num_materials; m++) {
01669
01670
01671 bot_clr +=
01672 shade_table[shade_index + 1*m + 0] *
01673 weight_table[weight_index + m];
01674 ;
01675 };
01676 shade_factor = bot_opc * slice_depth_cueing;
01677
01678 bot_clr *= shade_factor;
01679 ;
01680 }
01681
01682 #ifdef DEBUG
01683 if (ipixel == trace_pixel_ptr) {
01684 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01685 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01686 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01687 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01688 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01689 }
01690 #endif
01691 ;
01692
01693 acc_opc = bot_opc * wgtBL;
01694 acc_clr = bot_clr * wgtBL;
01695
01696 #ifdef DEBUG
01697 if (ipixel == trace_pixel_ptr) {
01698 trace_opcBL = bot_opc;
01699 trace_rclrBL = bot_clr;
01700
01701 }
01702 #endif
01703 ;
01704
01705 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01706
01707
01708 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01709 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01710
01711
01712
01713 top_clr =
01714 shade_table[shade_index + 1*0 + 0] *
01715 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01716 ;
01717 for (m = 1; m < num_materials; m++) {
01718
01719
01720 top_clr +=
01721 shade_table[shade_index + 1*m + 0] *
01722 weight_table[weight_index + m];
01723 ;
01724 };
01725 shade_factor = top_opc * slice_depth_cueing;
01726
01727 top_clr *= shade_factor;
01728 ;
01729
01730 acc_opc += top_opc * wgtTR;
01731 acc_clr += top_clr * wgtTR;
01732
01733 #ifdef DEBUG
01734 if (ipixel == trace_pixel_ptr) {
01735 trace_opcTR = top_opc;
01736 trace_rclrTR = top_clr;
01737
01738 }
01739 #endif
01740 ;
01741
01742 COUNT_RESAMPLE;
01743 if (acc_opc > min_opacity) {
01744 COUNT_COMPOSITE;
01745 iopc = ipixel->opcflt;
01746 # ifndef SKIP_ERT
01747 ASSERT(iopc < max_opacity);
01748 # endif
01749 iopc_inv = (float)1. - iopc;
01750 ipixel->clrflt += acc_clr * iopc_inv;
01751 iopc += acc_opc * iopc_inv;
01752 ipixel->opcflt = iopc;
01753
01754 #ifdef DEBUG
01755 if (ipixel == trace_pixel_ptr) {
01756 #ifdef COMPUTE_SHADOW_BUFFER
01757 printf("{%3d} %3d %3d", k, icount-i-count, j);
01758 #else
01759 printf("[%3d] %3d %3d", k, icount-i-count, j);
01760 #endif
01761 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01762 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01763 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01764 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01765 printf(" %3.0f %3.0f\n", iopc*255.,
01766 ipixel->clrflt);
01767
01768
01769 }
01770 #endif
01771 ;
01772 # ifndef SKIP_ERT
01773 if (iopc >= max_opacity) {
01774 ASSERT(ipixel->lnk == 0);
01775 ipixel->lnk = 1;
01776 }
01777 # endif
01778 };
01779 ipixel += 1;
01780 topRLEdata += 1 * voxel_istride;
01781 ;
01782 count--;
01783 SET_VOXELS_LOADED;
01784
01785
01786
01787 while (count > 0) {
01788 if (PIXEL_IS_OPAQUE(ipixel))
01789 break;
01790 if (!voxels_loaded) {
01791
01792 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01793
01794
01795 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01796 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01797
01798
01799
01800 top_clr =
01801 shade_table[shade_index + 1*0 + 0] *
01802 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01803 ;
01804 for (m = 1; m < num_materials; m++) {
01805
01806
01807 top_clr +=
01808 shade_table[shade_index + 1*m + 0] *
01809 weight_table[weight_index + m];
01810 ;
01811 };
01812 shade_factor = top_opc * slice_depth_cueing;
01813
01814 top_clr *= shade_factor;
01815 ;
01816 }
01817
01818 #ifdef DEBUG
01819 if (ipixel == trace_pixel_ptr) {
01820 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01821 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01822 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01823 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01824 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01825 }
01826 #endif
01827 ;
01828
01829 acc_opc = top_opc * wgtTL;
01830 acc_clr = top_clr * wgtTL;
01831
01832 #ifdef DEBUG
01833 if (ipixel == trace_pixel_ptr) {
01834 trace_opcTL = top_opc;
01835 trace_rclrTL = top_clr;
01836
01837 }
01838 #endif
01839 ;
01840
01841 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01842
01843
01844 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01845 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01846
01847
01848
01849 top_clr =
01850 shade_table[shade_index + 1*0 + 0] *
01851 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01852 ;
01853 for (m = 1; m < num_materials; m++) {
01854
01855
01856 top_clr +=
01857 shade_table[shade_index + 1*m + 0] *
01858 weight_table[weight_index + m];
01859 ;
01860 };
01861 shade_factor = top_opc * slice_depth_cueing;
01862
01863 top_clr *= shade_factor;
01864 ;
01865
01866 acc_opc += top_opc * wgtTR;
01867 acc_clr += top_clr * wgtTR;
01868
01869 #ifdef DEBUG
01870 if (ipixel == trace_pixel_ptr) {
01871 trace_opcTR = top_opc;
01872 trace_rclrTR = top_clr;
01873
01874 }
01875 #endif
01876 ;
01877
01878 COUNT_RESAMPLE;
01879 if (acc_opc > min_opacity) {
01880 COUNT_COMPOSITE;
01881 iopc = ipixel->opcflt;
01882 # ifndef SKIP_ERT
01883 ASSERT(iopc < max_opacity);
01884 # endif
01885 iopc_inv = (float)1. - iopc;
01886 ipixel->clrflt += acc_clr * iopc_inv;
01887 iopc += acc_opc * iopc_inv;
01888 ipixel->opcflt = iopc;
01889
01890 #ifdef DEBUG
01891 if (ipixel == trace_pixel_ptr) {
01892 #ifdef COMPUTE_SHADOW_BUFFER
01893 printf("{%3d} %3d %3d", k, icount-i-count, j);
01894 #else
01895 printf("[%3d] %3d %3d", k, icount-i-count, j);
01896 #endif
01897 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01898 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01899 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01900 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01901 printf(" %3.0f %3.0f\n", iopc*255.,
01902 ipixel->clrflt);
01903
01904
01905 }
01906 #endif
01907 ;
01908 # ifndef SKIP_ERT
01909 if (iopc >= max_opacity) {
01910 ASSERT(ipixel->lnk == 0);
01911 ipixel->lnk = 1;
01912 }
01913 # endif
01914 };
01915 ipixel += 1;
01916 topRLEdata += 1 * voxel_istride;
01917 ;
01918 count--;
01919 SET_VOXELS_LOADED;
01920 }
01921 break;
01922 case ALL_NONZERO__TOP_NONZERO:
01923
01924
01925 if (!voxels_loaded) {
01926
01927 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01928
01929
01930 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01931 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01932
01933
01934
01935 top_clr =
01936 shade_table[shade_index + 1*0 + 0] *
01937 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01938 ;
01939 for (m = 1; m < num_materials; m++) {
01940
01941
01942 top_clr +=
01943 shade_table[shade_index + 1*m + 0] *
01944 weight_table[weight_index + m];
01945 ;
01946 };
01947 shade_factor = top_opc * slice_depth_cueing;
01948
01949 top_clr *= shade_factor;
01950 ;
01951
01952 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01953
01954
01955 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01956 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01957
01958
01959
01960 bot_clr =
01961 shade_table[shade_index + 1*0 + 0] *
01962 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01963 ;
01964 for (m = 1; m < num_materials; m++) {
01965
01966
01967 bot_clr +=
01968 shade_table[shade_index + 1*m + 0] *
01969 weight_table[weight_index + m];
01970 ;
01971 };
01972 shade_factor = bot_opc * slice_depth_cueing;
01973
01974 bot_clr *= shade_factor;
01975 ;
01976 }
01977
01978 #ifdef DEBUG
01979 if (ipixel == trace_pixel_ptr) {
01980 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01981 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01982 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01983 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01984 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01985 }
01986 #endif
01987 ;
01988
01989 acc_opc = top_opc * wgtTL;
01990 acc_clr = top_clr * wgtTL;
01991
01992 #ifdef DEBUG
01993 if (ipixel == trace_pixel_ptr) {
01994 trace_opcTL = top_opc;
01995 trace_rclrTL = top_clr;
01996
01997 }
01998 #endif
01999 ;
02000
02001 acc_opc += bot_opc * wgtBL;
02002 acc_clr += bot_clr * wgtBL;
02003
02004 #ifdef DEBUG
02005 if (ipixel == trace_pixel_ptr) {
02006 trace_opcBL = bot_opc;
02007 trace_rclrBL = bot_clr;
02008
02009 }
02010 #endif
02011 ;
02012
02013 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02014
02015
02016 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
02017 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02018
02019
02020
02021 top_clr =
02022 shade_table[shade_index + 1*0 + 0] *
02023 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02024 ;
02025 for (m = 1; m < num_materials; m++) {
02026
02027
02028 top_clr +=
02029 shade_table[shade_index + 1*m + 0] *
02030 weight_table[weight_index + m];
02031 ;
02032 };
02033 shade_factor = top_opc * slice_depth_cueing;
02034
02035 top_clr *= shade_factor;
02036 ;
02037
02038 acc_opc += top_opc * wgtTR;
02039 acc_clr += top_clr * wgtTR;
02040
02041 #ifdef DEBUG
02042 if (ipixel == trace_pixel_ptr) {
02043 trace_opcTR = top_opc;
02044 trace_rclrTR = top_clr;
02045
02046 }
02047 #endif
02048 ;
02049
02050 COUNT_RESAMPLE;
02051 if (acc_opc > min_opacity) {
02052 COUNT_COMPOSITE;
02053 iopc = ipixel->opcflt;
02054 # ifndef SKIP_ERT
02055 ASSERT(iopc < max_opacity);
02056 # endif
02057 iopc_inv = (float)1. - iopc;
02058 ipixel->clrflt += acc_clr * iopc_inv;
02059 iopc += acc_opc * iopc_inv;
02060 ipixel->opcflt = iopc;
02061
02062 #ifdef DEBUG
02063 if (ipixel == trace_pixel_ptr) {
02064 #ifdef COMPUTE_SHADOW_BUFFER
02065 printf("{%3d} %3d %3d", k, icount-i-count, j);
02066 #else
02067 printf("[%3d] %3d %3d", k, icount-i-count, j);
02068 #endif
02069 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02070 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02071 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02072 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02073 printf(" %3.0f %3.0f\n", iopc*255.,
02074 ipixel->clrflt);
02075
02076
02077 }
02078 #endif
02079 ;
02080 # ifndef SKIP_ERT
02081 if (iopc >= max_opacity) {
02082 ASSERT(ipixel->lnk == 0);
02083 ipixel->lnk = 1;
02084 }
02085 # endif
02086 };
02087 ipixel += 1;
02088 topRLEdata += 1 * voxel_istride;
02089 ;
02090 count--;
02091 SET_VOXELS_LOADED;
02092
02093
02094
02095 while (count > 0) {
02096 if (PIXEL_IS_OPAQUE(ipixel))
02097 break;
02098 if (!voxels_loaded) {
02099
02100 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02101
02102
02103 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02104 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02105
02106
02107
02108 top_clr =
02109 shade_table[shade_index + 1*0 + 0] *
02110 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02111 ;
02112 for (m = 1; m < num_materials; m++) {
02113
02114
02115 top_clr +=
02116 shade_table[shade_index + 1*m + 0] *
02117 weight_table[weight_index + m];
02118 ;
02119 };
02120 shade_factor = top_opc * slice_depth_cueing;
02121
02122 top_clr *= shade_factor;
02123 ;
02124 }
02125
02126 #ifdef DEBUG
02127 if (ipixel == trace_pixel_ptr) {
02128 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02129 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02130 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02131 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02132 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02133 }
02134 #endif
02135 ;
02136
02137 acc_opc = top_opc * wgtTL;
02138 acc_clr = top_clr * wgtTL;
02139
02140 #ifdef DEBUG
02141 if (ipixel == trace_pixel_ptr) {
02142 trace_opcTL = top_opc;
02143 trace_rclrTL = top_clr;
02144
02145 }
02146 #endif
02147 ;
02148
02149 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02150
02151
02152 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
02153 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02154
02155
02156
02157 top_clr =
02158 shade_table[shade_index + 1*0 + 0] *
02159 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02160 ;
02161 for (m = 1; m < num_materials; m++) {
02162
02163
02164 top_clr +=
02165 shade_table[shade_index + 1*m + 0] *
02166 weight_table[weight_index + m];
02167 ;
02168 };
02169 shade_factor = top_opc * slice_depth_cueing;
02170
02171 top_clr *= shade_factor;
02172 ;
02173
02174 acc_opc += top_opc * wgtTR;
02175 acc_clr += top_clr * wgtTR;
02176
02177 #ifdef DEBUG
02178 if (ipixel == trace_pixel_ptr) {
02179 trace_opcTR = top_opc;
02180 trace_rclrTR = top_clr;
02181
02182 }
02183 #endif
02184 ;
02185
02186 COUNT_RESAMPLE;
02187 if (acc_opc > min_opacity) {
02188 COUNT_COMPOSITE;
02189 iopc = ipixel->opcflt;
02190 # ifndef SKIP_ERT
02191 ASSERT(iopc < max_opacity);
02192 # endif
02193 iopc_inv = (float)1. - iopc;
02194 ipixel->clrflt += acc_clr * iopc_inv;
02195 iopc += acc_opc * iopc_inv;
02196 ipixel->opcflt = iopc;
02197
02198 #ifdef DEBUG
02199 if (ipixel == trace_pixel_ptr) {
02200 #ifdef COMPUTE_SHADOW_BUFFER
02201 printf("{%3d} %3d %3d", k, icount-i-count, j);
02202 #else
02203 printf("[%3d] %3d %3d", k, icount-i-count, j);
02204 #endif
02205 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02206 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02207 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02208 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02209 printf(" %3.0f %3.0f\n", iopc*255.,
02210 ipixel->clrflt);
02211
02212
02213 }
02214 #endif
02215 ;
02216 # ifndef SKIP_ERT
02217 if (iopc >= max_opacity) {
02218 ASSERT(ipixel->lnk == 0);
02219 ipixel->lnk = 1;
02220 }
02221 # endif
02222 };
02223 ipixel += 1;
02224 topRLEdata += 1 * voxel_istride;
02225 ;
02226 count--;
02227 SET_VOXELS_LOADED;
02228 }
02229 break;
02230 case ALL_ZERO__BOT_NONZERO:
02231
02232
02233 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02234
02235
02236 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02237 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02238
02239
02240
02241 bot_clr =
02242 shade_table[shade_index + 1*0 + 0] *
02243 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02244 ;
02245 for (m = 1; m < num_materials; m++) {
02246
02247
02248 bot_clr +=
02249 shade_table[shade_index + 1*m + 0] *
02250 weight_table[weight_index + m];
02251 ;
02252 };
02253 shade_factor = bot_opc * slice_depth_cueing;
02254
02255 bot_clr *= shade_factor;
02256 ;
02257
02258 #ifdef DEBUG
02259 if (ipixel == trace_pixel_ptr) {
02260 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02261 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02262 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02263 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02264 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02265 }
02266 #endif
02267 ;
02268
02269 acc_opc = bot_opc * wgtBR;
02270 acc_clr = bot_clr * wgtBR;
02271
02272 #ifdef DEBUG
02273 if (ipixel == trace_pixel_ptr) {
02274 trace_opcBR = bot_opc;
02275 trace_rclrBR = bot_clr;
02276
02277 }
02278 #endif
02279 ;
02280
02281 COUNT_RESAMPLE;
02282 if (acc_opc > min_opacity) {
02283 COUNT_COMPOSITE;
02284 iopc = ipixel->opcflt;
02285 # ifndef SKIP_ERT
02286 ASSERT(iopc < max_opacity);
02287 # endif
02288 iopc_inv = (float)1. - iopc;
02289 ipixel->clrflt += acc_clr * iopc_inv;
02290 iopc += acc_opc * iopc_inv;
02291 ipixel->opcflt = iopc;
02292
02293 #ifdef DEBUG
02294 if (ipixel == trace_pixel_ptr) {
02295 #ifdef COMPUTE_SHADOW_BUFFER
02296 printf("{%3d} %3d %3d", k, icount-i-count, j);
02297 #else
02298 printf("[%3d] %3d %3d", k, icount-i-count, j);
02299 #endif
02300 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02301 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02302 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02303 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02304 printf(" %3.0f %3.0f\n", iopc*255.,
02305 ipixel->clrflt);
02306
02307
02308 }
02309 #endif
02310 ;
02311 # ifndef SKIP_ERT
02312 if (iopc >= max_opacity) {
02313 ASSERT(ipixel->lnk == 0);
02314 ipixel->lnk = 1;
02315 }
02316 # endif
02317 };
02318 ipixel += 1;
02319 ;
02320 botRLEdata += 1 * voxel_istride;
02321 count--;
02322 SET_VOXELS_LOADED;
02323
02324
02325
02326 while (count > 0) {
02327 if (PIXEL_IS_OPAQUE(ipixel))
02328 break;
02329 if (!voxels_loaded) {
02330
02331 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02332
02333
02334 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02335 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02336
02337
02338
02339 bot_clr =
02340 shade_table[shade_index + 1*0 + 0] *
02341 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02342 ;
02343 for (m = 1; m < num_materials; m++) {
02344
02345
02346 bot_clr +=
02347 shade_table[shade_index + 1*m + 0] *
02348 weight_table[weight_index + m];
02349 ;
02350 };
02351 shade_factor = bot_opc * slice_depth_cueing;
02352
02353 bot_clr *= shade_factor;
02354 ;
02355 }
02356
02357 #ifdef DEBUG
02358 if (ipixel == trace_pixel_ptr) {
02359 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02360 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02361 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02362 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02363 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02364 }
02365 #endif
02366 ;
02367
02368 acc_opc = bot_opc * wgtBL;
02369 acc_clr = bot_clr * wgtBL;
02370
02371 #ifdef DEBUG
02372 if (ipixel == trace_pixel_ptr) {
02373 trace_opcBL = bot_opc;
02374 trace_rclrBL = bot_clr;
02375
02376 }
02377 #endif
02378 ;
02379
02380 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02381
02382
02383 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02384 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02385
02386
02387
02388 bot_clr =
02389 shade_table[shade_index + 1*0 + 0] *
02390 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02391 ;
02392 for (m = 1; m < num_materials; m++) {
02393
02394
02395 bot_clr +=
02396 shade_table[shade_index + 1*m + 0] *
02397 weight_table[weight_index + m];
02398 ;
02399 };
02400 shade_factor = bot_opc * slice_depth_cueing;
02401
02402 bot_clr *= shade_factor;
02403 ;
02404
02405 acc_opc += bot_opc * wgtBR;
02406 acc_clr += bot_clr * wgtBR;
02407
02408 #ifdef DEBUG
02409 if (ipixel == trace_pixel_ptr) {
02410 trace_opcBR = bot_opc;
02411 trace_rclrBR = bot_clr;
02412
02413 }
02414 #endif
02415 ;
02416
02417 COUNT_RESAMPLE;
02418 if (acc_opc > min_opacity) {
02419 COUNT_COMPOSITE;
02420 iopc = ipixel->opcflt;
02421 # ifndef SKIP_ERT
02422 ASSERT(iopc < max_opacity);
02423 # endif
02424 iopc_inv = (float)1. - iopc;
02425 ipixel->clrflt += acc_clr * iopc_inv;
02426 iopc += acc_opc * iopc_inv;
02427 ipixel->opcflt = iopc;
02428
02429 #ifdef DEBUG
02430 if (ipixel == trace_pixel_ptr) {
02431 #ifdef COMPUTE_SHADOW_BUFFER
02432 printf("{%3d} %3d %3d", k, icount-i-count, j);
02433 #else
02434 printf("[%3d] %3d %3d", k, icount-i-count, j);
02435 #endif
02436 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02437 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02438 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02439 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02440 printf(" %3.0f %3.0f\n", iopc*255.,
02441 ipixel->clrflt);
02442
02443
02444 }
02445 #endif
02446 ;
02447 # ifndef SKIP_ERT
02448 if (iopc >= max_opacity) {
02449 ASSERT(ipixel->lnk == 0);
02450 ipixel->lnk = 1;
02451 }
02452 # endif
02453 };
02454 ipixel += 1;
02455 ;
02456 botRLEdata += 1 * voxel_istride;
02457 count--;
02458 SET_VOXELS_LOADED;
02459 }
02460 break;
02461 case TOP_NONZERO__BOT_NONZERO:
02462
02463 if (!voxels_loaded) {
02464
02465 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02466
02467
02468 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02469 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02470
02471
02472
02473 top_clr =
02474 shade_table[shade_index + 1*0 + 0] *
02475 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02476 ;
02477 for (m = 1; m < num_materials; m++) {
02478
02479
02480 top_clr +=
02481 shade_table[shade_index + 1*m + 0] *
02482 weight_table[weight_index + m];
02483 ;
02484 };
02485 shade_factor = top_opc * slice_depth_cueing;
02486
02487 top_clr *= shade_factor;
02488 ;
02489 }
02490
02491 #ifdef DEBUG
02492 if (ipixel == trace_pixel_ptr) {
02493 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02494 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02495 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02496 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02497 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02498 }
02499 #endif
02500 ;
02501
02502 acc_opc = top_opc * wgtTL;
02503 acc_clr = top_clr * wgtTL;
02504
02505 #ifdef DEBUG
02506 if (ipixel == trace_pixel_ptr) {
02507 trace_opcTL = top_opc;
02508 trace_rclrTL = top_clr;
02509
02510 }
02511 #endif
02512 ;
02513
02514 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02515
02516
02517 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02518 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02519
02520
02521
02522 bot_clr =
02523 shade_table[shade_index + 1*0 + 0] *
02524 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02525 ;
02526 for (m = 1; m < num_materials; m++) {
02527
02528
02529 bot_clr +=
02530 shade_table[shade_index + 1*m + 0] *
02531 weight_table[weight_index + m];
02532 ;
02533 };
02534 shade_factor = bot_opc * slice_depth_cueing;
02535
02536 bot_clr *= shade_factor;
02537 ;
02538
02539 acc_opc += bot_opc * wgtBR;
02540 acc_clr += bot_clr * wgtBR;
02541
02542 #ifdef DEBUG
02543 if (ipixel == trace_pixel_ptr) {
02544 trace_opcBR = bot_opc;
02545 trace_rclrBR = bot_clr;
02546
02547 }
02548 #endif
02549 ;
02550
02551 COUNT_RESAMPLE;
02552 if (acc_opc > min_opacity) {
02553 COUNT_COMPOSITE;
02554 iopc = ipixel->opcflt;
02555 # ifndef SKIP_ERT
02556 ASSERT(iopc < max_opacity);
02557 # endif
02558 iopc_inv = (float)1. - iopc;
02559 ipixel->clrflt += acc_clr * iopc_inv;
02560 iopc += acc_opc * iopc_inv;
02561 ipixel->opcflt = iopc;
02562
02563 #ifdef DEBUG
02564 if (ipixel == trace_pixel_ptr) {
02565 #ifdef COMPUTE_SHADOW_BUFFER
02566 printf("{%3d} %3d %3d", k, icount-i-count, j);
02567 #else
02568 printf("[%3d] %3d %3d", k, icount-i-count, j);
02569 #endif
02570 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02571 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02572 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02573 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02574 printf(" %3.0f %3.0f\n", iopc*255.,
02575 ipixel->clrflt);
02576
02577
02578 }
02579 #endif
02580 ;
02581 # ifndef SKIP_ERT
02582 if (iopc >= max_opacity) {
02583 ASSERT(ipixel->lnk == 0);
02584 ipixel->lnk = 1;
02585 }
02586 # endif
02587 };
02588 ipixel += 1;
02589 ;
02590 botRLEdata += 1 * voxel_istride;
02591 count--;
02592 SET_VOXELS_LOADED;
02593
02594
02595
02596 while (count > 0) {
02597 if (PIXEL_IS_OPAQUE(ipixel))
02598 break;
02599 if (!voxels_loaded) {
02600
02601 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02602
02603
02604 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02605 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02606
02607
02608
02609 bot_clr =
02610 shade_table[shade_index + 1*0 + 0] *
02611 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02612 ;
02613 for (m = 1; m < num_materials; m++) {
02614
02615
02616 bot_clr +=
02617 shade_table[shade_index + 1*m + 0] *
02618 weight_table[weight_index + m];
02619 ;
02620 };
02621 shade_factor = bot_opc * slice_depth_cueing;
02622
02623 bot_clr *= shade_factor;
02624 ;
02625 }
02626
02627 #ifdef DEBUG
02628 if (ipixel == trace_pixel_ptr) {
02629 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02630 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02631 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02632 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02633 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02634 }
02635 #endif
02636 ;
02637
02638 acc_opc = bot_opc * wgtBL;
02639 acc_clr = bot_clr * wgtBL;
02640
02641 #ifdef DEBUG
02642 if (ipixel == trace_pixel_ptr) {
02643 trace_opcBL = bot_opc;
02644 trace_rclrBL = bot_clr;
02645
02646 }
02647 #endif
02648 ;
02649
02650 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02651
02652
02653 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02654 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02655
02656
02657
02658 bot_clr =
02659 shade_table[shade_index + 1*0 + 0] *
02660 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02661 ;
02662 for (m = 1; m < num_materials; m++) {
02663
02664
02665 bot_clr +=
02666 shade_table[shade_index + 1*m + 0] *
02667 weight_table[weight_index + m];
02668 ;
02669 };
02670 shade_factor = bot_opc * slice_depth_cueing;
02671
02672 bot_clr *= shade_factor;
02673 ;
02674
02675 acc_opc += bot_opc * wgtBR;
02676 acc_clr += bot_clr * wgtBR;
02677
02678 #ifdef DEBUG
02679 if (ipixel == trace_pixel_ptr) {
02680 trace_opcBR = bot_opc;
02681 trace_rclrBR = bot_clr;
02682
02683 }
02684 #endif
02685 ;
02686
02687 COUNT_RESAMPLE;
02688 if (acc_opc > min_opacity) {
02689 COUNT_COMPOSITE;
02690 iopc = ipixel->opcflt;
02691 # ifndef SKIP_ERT
02692 ASSERT(iopc < max_opacity);
02693 # endif
02694 iopc_inv = (float)1. - iopc;
02695 ipixel->clrflt += acc_clr * iopc_inv;
02696 iopc += acc_opc * iopc_inv;
02697 ipixel->opcflt = iopc;
02698
02699 #ifdef DEBUG
02700 if (ipixel == trace_pixel_ptr) {
02701 #ifdef COMPUTE_SHADOW_BUFFER
02702 printf("{%3d} %3d %3d", k, icount-i-count, j);
02703 #else
02704 printf("[%3d] %3d %3d", k, icount-i-count, j);
02705 #endif
02706 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02707 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02708 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02709 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02710 printf(" %3.0f %3.0f\n", iopc*255.,
02711 ipixel->clrflt);
02712
02713
02714 }
02715 #endif
02716 ;
02717 # ifndef SKIP_ERT
02718 if (iopc >= max_opacity) {
02719 ASSERT(ipixel->lnk == 0);
02720 ipixel->lnk = 1;
02721 }
02722 # endif
02723 };
02724 ipixel += 1;
02725 ;
02726 botRLEdata += 1 * voxel_istride;
02727 count--;
02728 SET_VOXELS_LOADED;
02729 }
02730 break;
02731 case BOT_NONZERO__BOT_NONZERO:
02732
02733
02734 while (count > 0) {
02735 if (PIXEL_IS_OPAQUE(ipixel))
02736 break;
02737 if (!voxels_loaded) {
02738
02739 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02740
02741
02742 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02743 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02744
02745
02746
02747 bot_clr =
02748 shade_table[shade_index + 1*0 + 0] *
02749 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02750 ;
02751 for (m = 1; m < num_materials; m++) {
02752
02753
02754 bot_clr +=
02755 shade_table[shade_index + 1*m + 0] *
02756 weight_table[weight_index + m];
02757 ;
02758 };
02759 shade_factor = bot_opc * slice_depth_cueing;
02760
02761 bot_clr *= shade_factor;
02762 ;
02763 }
02764
02765 #ifdef DEBUG
02766 if (ipixel == trace_pixel_ptr) {
02767 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02768 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02769 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02770 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02771 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02772 }
02773 #endif
02774 ;
02775
02776 acc_opc = bot_opc * wgtBL;
02777 acc_clr = bot_clr * wgtBL;
02778
02779 #ifdef DEBUG
02780 if (ipixel == trace_pixel_ptr) {
02781 trace_opcBL = bot_opc;
02782 trace_rclrBL = bot_clr;
02783
02784 }
02785 #endif
02786 ;
02787
02788 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02789
02790
02791 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02792 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02793
02794
02795
02796 bot_clr =
02797 shade_table[shade_index + 1*0 + 0] *
02798 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02799 ;
02800 for (m = 1; m < num_materials; m++) {
02801
02802
02803 bot_clr +=
02804 shade_table[shade_index + 1*m + 0] *
02805 weight_table[weight_index + m];
02806 ;
02807 };
02808 shade_factor = bot_opc * slice_depth_cueing;
02809
02810 bot_clr *= shade_factor;
02811 ;
02812
02813 acc_opc += bot_opc * wgtBR;
02814 acc_clr += bot_clr * wgtBR;
02815
02816 #ifdef DEBUG
02817 if (ipixel == trace_pixel_ptr) {
02818 trace_opcBR = bot_opc;
02819 trace_rclrBR = bot_clr;
02820
02821 }
02822 #endif
02823 ;
02824
02825 COUNT_RESAMPLE;
02826 if (acc_opc > min_opacity) {
02827 COUNT_COMPOSITE;
02828 iopc = ipixel->opcflt;
02829 # ifndef SKIP_ERT
02830 ASSERT(iopc < max_opacity);
02831 # endif
02832 iopc_inv = (float)1. - iopc;
02833 ipixel->clrflt += acc_clr * iopc_inv;
02834 iopc += acc_opc * iopc_inv;
02835 ipixel->opcflt = iopc;
02836
02837 #ifdef DEBUG
02838 if (ipixel == trace_pixel_ptr) {
02839 #ifdef COMPUTE_SHADOW_BUFFER
02840 printf("{%3d} %3d %3d", k, icount-i-count, j);
02841 #else
02842 printf("[%3d] %3d %3d", k, icount-i-count, j);
02843 #endif
02844 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02845 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02846 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02847 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02848 printf(" %3.0f %3.0f\n", iopc*255.,
02849 ipixel->clrflt);
02850
02851
02852 }
02853 #endif
02854 ;
02855 # ifndef SKIP_ERT
02856 if (iopc >= max_opacity) {
02857 ASSERT(ipixel->lnk == 0);
02858 ipixel->lnk = 1;
02859 }
02860 # endif
02861 };
02862 ipixel += 1;
02863 ;
02864 botRLEdata += 1 * voxel_istride;
02865 count--;
02866 SET_VOXELS_LOADED;
02867 }
02868 break;
02869 case ALL_NONZERO__BOT_NONZERO:
02870
02871
02872 if (!voxels_loaded) {
02873
02874 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02875
02876
02877 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02878 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02879
02880
02881
02882 top_clr =
02883 shade_table[shade_index + 1*0 + 0] *
02884 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02885 ;
02886 for (m = 1; m < num_materials; m++) {
02887
02888
02889 top_clr +=
02890 shade_table[shade_index + 1*m + 0] *
02891 weight_table[weight_index + m];
02892 ;
02893 };
02894 shade_factor = top_opc * slice_depth_cueing;
02895
02896 top_clr *= shade_factor;
02897 ;
02898
02899 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02900
02901
02902 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02903 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02904
02905
02906
02907 bot_clr =
02908 shade_table[shade_index + 1*0 + 0] *
02909 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02910 ;
02911 for (m = 1; m < num_materials; m++) {
02912
02913
02914 bot_clr +=
02915 shade_table[shade_index + 1*m + 0] *
02916 weight_table[weight_index + m];
02917 ;
02918 };
02919 shade_factor = bot_opc * slice_depth_cueing;
02920
02921 bot_clr *= shade_factor;
02922 ;
02923 }
02924
02925 #ifdef DEBUG
02926 if (ipixel == trace_pixel_ptr) {
02927 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02928 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02929 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02930 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02931 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02932 }
02933 #endif
02934 ;
02935
02936 acc_opc = top_opc * wgtTL;
02937 acc_clr = top_clr * wgtTL;
02938
02939 #ifdef DEBUG
02940 if (ipixel == trace_pixel_ptr) {
02941 trace_opcTL = top_opc;
02942 trace_rclrTL = top_clr;
02943
02944 }
02945 #endif
02946 ;
02947
02948 acc_opc += bot_opc * wgtBL;
02949 acc_clr += bot_clr * wgtBL;
02950
02951 #ifdef DEBUG
02952 if (ipixel == trace_pixel_ptr) {
02953 trace_opcBL = bot_opc;
02954 trace_rclrBL = bot_clr;
02955
02956 }
02957 #endif
02958 ;
02959
02960 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02961
02962
02963 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02964 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02965
02966
02967
02968 bot_clr =
02969 shade_table[shade_index + 1*0 + 0] *
02970 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02971 ;
02972 for (m = 1; m < num_materials; m++) {
02973
02974
02975 bot_clr +=
02976 shade_table[shade_index + 1*m + 0] *
02977 weight_table[weight_index + m];
02978 ;
02979 };
02980 shade_factor = bot_opc * slice_depth_cueing;
02981
02982 bot_clr *= shade_factor;
02983 ;
02984
02985 acc_opc += bot_opc * wgtBR;
02986 acc_clr += bot_clr * wgtBR;
02987
02988 #ifdef DEBUG
02989 if (ipixel == trace_pixel_ptr) {
02990 trace_opcBR = bot_opc;
02991 trace_rclrBR = bot_clr;
02992
02993 }
02994 #endif
02995 ;
02996
02997 COUNT_RESAMPLE;
02998 if (acc_opc > min_opacity) {
02999 COUNT_COMPOSITE;
03000 iopc = ipixel->opcflt;
03001 # ifndef SKIP_ERT
03002 ASSERT(iopc < max_opacity);
03003 # endif
03004 iopc_inv = (float)1. - iopc;
03005 ipixel->clrflt += acc_clr * iopc_inv;
03006 iopc += acc_opc * iopc_inv;
03007 ipixel->opcflt = iopc;
03008
03009 #ifdef DEBUG
03010 if (ipixel == trace_pixel_ptr) {
03011 #ifdef COMPUTE_SHADOW_BUFFER
03012 printf("{%3d} %3d %3d", k, icount-i-count, j);
03013 #else
03014 printf("[%3d] %3d %3d", k, icount-i-count, j);
03015 #endif
03016 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03017 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03018 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03019 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03020 printf(" %3.0f %3.0f\n", iopc*255.,
03021 ipixel->clrflt);
03022
03023
03024 }
03025 #endif
03026 ;
03027 # ifndef SKIP_ERT
03028 if (iopc >= max_opacity) {
03029 ASSERT(ipixel->lnk == 0);
03030 ipixel->lnk = 1;
03031 }
03032 # endif
03033 };
03034 ipixel += 1;
03035 ;
03036 botRLEdata += 1 * voxel_istride;
03037 count--;
03038 SET_VOXELS_LOADED;
03039
03040
03041
03042 while (count > 0) {
03043 if (PIXEL_IS_OPAQUE(ipixel))
03044 break;
03045 if (!voxels_loaded) {
03046
03047 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03048
03049
03050 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03051 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03052
03053
03054
03055 bot_clr =
03056 shade_table[shade_index + 1*0 + 0] *
03057 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03058 ;
03059 for (m = 1; m < num_materials; m++) {
03060
03061
03062 bot_clr +=
03063 shade_table[shade_index + 1*m + 0] *
03064 weight_table[weight_index + m];
03065 ;
03066 };
03067 shade_factor = bot_opc * slice_depth_cueing;
03068
03069 bot_clr *= shade_factor;
03070 ;
03071 }
03072
03073 #ifdef DEBUG
03074 if (ipixel == trace_pixel_ptr) {
03075 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03076 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03077 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03078 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03079 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03080 }
03081 #endif
03082 ;
03083
03084 acc_opc = bot_opc * wgtBL;
03085 acc_clr = bot_clr * wgtBL;
03086
03087 #ifdef DEBUG
03088 if (ipixel == trace_pixel_ptr) {
03089 trace_opcBL = bot_opc;
03090 trace_rclrBL = bot_clr;
03091
03092 }
03093 #endif
03094 ;
03095
03096 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03097
03098
03099 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03100 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03101
03102
03103
03104 bot_clr =
03105 shade_table[shade_index + 1*0 + 0] *
03106 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03107 ;
03108 for (m = 1; m < num_materials; m++) {
03109
03110
03111 bot_clr +=
03112 shade_table[shade_index + 1*m + 0] *
03113 weight_table[weight_index + m];
03114 ;
03115 };
03116 shade_factor = bot_opc * slice_depth_cueing;
03117
03118 bot_clr *= shade_factor;
03119 ;
03120
03121 acc_opc += bot_opc * wgtBR;
03122 acc_clr += bot_clr * wgtBR;
03123
03124 #ifdef DEBUG
03125 if (ipixel == trace_pixel_ptr) {
03126 trace_opcBR = bot_opc;
03127 trace_rclrBR = bot_clr;
03128
03129 }
03130 #endif
03131 ;
03132
03133 COUNT_RESAMPLE;
03134 if (acc_opc > min_opacity) {
03135 COUNT_COMPOSITE;
03136 iopc = ipixel->opcflt;
03137 # ifndef SKIP_ERT
03138 ASSERT(iopc < max_opacity);
03139 # endif
03140 iopc_inv = (float)1. - iopc;
03141 ipixel->clrflt += acc_clr * iopc_inv;
03142 iopc += acc_opc * iopc_inv;
03143 ipixel->opcflt = iopc;
03144
03145 #ifdef DEBUG
03146 if (ipixel == trace_pixel_ptr) {
03147 #ifdef COMPUTE_SHADOW_BUFFER
03148 printf("{%3d} %3d %3d", k, icount-i-count, j);
03149 #else
03150 printf("[%3d] %3d %3d", k, icount-i-count, j);
03151 #endif
03152 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03153 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03154 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03155 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03156 printf(" %3.0f %3.0f\n", iopc*255.,
03157 ipixel->clrflt);
03158
03159
03160 }
03161 #endif
03162 ;
03163 # ifndef SKIP_ERT
03164 if (iopc >= max_opacity) {
03165 ASSERT(ipixel->lnk == 0);
03166 ipixel->lnk = 1;
03167 }
03168 # endif
03169 };
03170 ipixel += 1;
03171 ;
03172 botRLEdata += 1 * voxel_istride;
03173 count--;
03174 SET_VOXELS_LOADED;
03175 }
03176 break;
03177 case ALL_ZERO__ALL_NONZERO:
03178
03179
03180 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03181
03182
03183 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03184 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03185
03186
03187
03188 top_clr =
03189 shade_table[shade_index + 1*0 + 0] *
03190 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03191 ;
03192 for (m = 1; m < num_materials; m++) {
03193
03194
03195 top_clr +=
03196 shade_table[shade_index + 1*m + 0] *
03197 weight_table[weight_index + m];
03198 ;
03199 };
03200 shade_factor = top_opc * slice_depth_cueing;
03201
03202 top_clr *= shade_factor;
03203 ;
03204
03205 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03206
03207
03208 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03209 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03210
03211
03212
03213 bot_clr =
03214 shade_table[shade_index + 1*0 + 0] *
03215 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03216 ;
03217 for (m = 1; m < num_materials; m++) {
03218
03219
03220 bot_clr +=
03221 shade_table[shade_index + 1*m + 0] *
03222 weight_table[weight_index + m];
03223 ;
03224 };
03225 shade_factor = bot_opc * slice_depth_cueing;
03226
03227 bot_clr *= shade_factor;
03228 ;
03229
03230 #ifdef DEBUG
03231 if (ipixel == trace_pixel_ptr) {
03232 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03233 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03234 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03235 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03236 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03237 }
03238 #endif
03239 ;
03240
03241 acc_opc = top_opc * wgtTR;
03242 acc_clr = top_clr * wgtTR;
03243
03244 #ifdef DEBUG
03245 if (ipixel == trace_pixel_ptr) {
03246 trace_opcTR = top_opc;
03247 trace_rclrTR = top_clr;
03248
03249 }
03250 #endif
03251 ;
03252
03253 acc_opc += bot_opc * wgtBR;
03254 acc_clr += bot_clr * wgtBR;
03255
03256 #ifdef DEBUG
03257 if (ipixel == trace_pixel_ptr) {
03258 trace_opcBR = bot_opc;
03259 trace_rclrBR = bot_clr;
03260
03261 }
03262 #endif
03263 ;
03264
03265 COUNT_RESAMPLE;
03266 if (acc_opc > min_opacity) {
03267 COUNT_COMPOSITE;
03268 iopc = ipixel->opcflt;
03269 # ifndef SKIP_ERT
03270 ASSERT(iopc < max_opacity);
03271 # endif
03272 iopc_inv = (float)1. - iopc;
03273 ipixel->clrflt += acc_clr * iopc_inv;
03274 iopc += acc_opc * iopc_inv;
03275 ipixel->opcflt = iopc;
03276
03277 #ifdef DEBUG
03278 if (ipixel == trace_pixel_ptr) {
03279 #ifdef COMPUTE_SHADOW_BUFFER
03280 printf("{%3d} %3d %3d", k, icount-i-count, j);
03281 #else
03282 printf("[%3d] %3d %3d", k, icount-i-count, j);
03283 #endif
03284 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03285 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03286 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03287 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03288 printf(" %3.0f %3.0f\n", iopc*255.,
03289 ipixel->clrflt);
03290
03291
03292 }
03293 #endif
03294 ;
03295 # ifndef SKIP_ERT
03296 if (iopc >= max_opacity) {
03297 ASSERT(ipixel->lnk == 0);
03298 ipixel->lnk = 1;
03299 }
03300 # endif
03301 };
03302 ipixel += 1;
03303 topRLEdata += 1 * voxel_istride;
03304 botRLEdata += 1 * voxel_istride;
03305 count--;
03306 SET_VOXELS_LOADED;
03307
03308
03309
03310 while (count > 0) {
03311 if (PIXEL_IS_OPAQUE(ipixel))
03312 break;
03313 if (!voxels_loaded) {
03314
03315 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03316
03317
03318 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03319 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03320
03321
03322
03323 top_clr =
03324 shade_table[shade_index + 1*0 + 0] *
03325 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03326 ;
03327 for (m = 1; m < num_materials; m++) {
03328
03329
03330 top_clr +=
03331 shade_table[shade_index + 1*m + 0] *
03332 weight_table[weight_index + m];
03333 ;
03334 };
03335 shade_factor = top_opc * slice_depth_cueing;
03336
03337 top_clr *= shade_factor;
03338 ;
03339
03340 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03341
03342
03343 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03344 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03345
03346
03347
03348 bot_clr =
03349 shade_table[shade_index + 1*0 + 0] *
03350 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03351 ;
03352 for (m = 1; m < num_materials; m++) {
03353
03354
03355 bot_clr +=
03356 shade_table[shade_index + 1*m + 0] *
03357 weight_table[weight_index + m];
03358 ;
03359 };
03360 shade_factor = bot_opc * slice_depth_cueing;
03361
03362 bot_clr *= shade_factor;
03363 ;
03364 }
03365
03366 #ifdef DEBUG
03367 if (ipixel == trace_pixel_ptr) {
03368 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03369 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03370 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03371 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03372 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03373 }
03374 #endif
03375 ;
03376
03377 acc_opc = top_opc * wgtTL;
03378 acc_clr = top_clr * wgtTL;
03379
03380 #ifdef DEBUG
03381 if (ipixel == trace_pixel_ptr) {
03382 trace_opcTL = top_opc;
03383 trace_rclrTL = top_clr;
03384
03385 }
03386 #endif
03387 ;
03388
03389 acc_opc += bot_opc * wgtBL;
03390 acc_clr += bot_clr * wgtBL;
03391
03392 #ifdef DEBUG
03393 if (ipixel == trace_pixel_ptr) {
03394 trace_opcBL = bot_opc;
03395 trace_rclrBL = bot_clr;
03396
03397 }
03398 #endif
03399 ;
03400
03401 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03402
03403
03404 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03405 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03406
03407
03408
03409 top_clr =
03410 shade_table[shade_index + 1*0 + 0] *
03411 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03412 ;
03413 for (m = 1; m < num_materials; m++) {
03414
03415
03416 top_clr +=
03417 shade_table[shade_index + 1*m + 0] *
03418 weight_table[weight_index + m];
03419 ;
03420 };
03421 shade_factor = top_opc * slice_depth_cueing;
03422
03423 top_clr *= shade_factor;
03424 ;
03425
03426 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03427
03428
03429 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03430 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03431
03432
03433
03434 bot_clr =
03435 shade_table[shade_index + 1*0 + 0] *
03436 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03437 ;
03438 for (m = 1; m < num_materials; m++) {
03439
03440
03441 bot_clr +=
03442 shade_table[shade_index + 1*m + 0] *
03443 weight_table[weight_index + m];
03444 ;
03445 };
03446 shade_factor = bot_opc * slice_depth_cueing;
03447
03448 bot_clr *= shade_factor;
03449 ;
03450
03451 acc_opc += top_opc * wgtTR;
03452 acc_clr += top_clr * wgtTR;
03453
03454 #ifdef DEBUG
03455 if (ipixel == trace_pixel_ptr) {
03456 trace_opcTR = top_opc;
03457 trace_rclrTR = top_clr;
03458
03459 }
03460 #endif
03461 ;
03462
03463 acc_opc += bot_opc * wgtBR;
03464 acc_clr += bot_clr * wgtBR;
03465
03466 #ifdef DEBUG
03467 if (ipixel == trace_pixel_ptr) {
03468 trace_opcBR = bot_opc;
03469 trace_rclrBR = bot_clr;
03470
03471 }
03472 #endif
03473 ;
03474
03475 COUNT_RESAMPLE;
03476 if (acc_opc > min_opacity) {
03477 COUNT_COMPOSITE;
03478 iopc = ipixel->opcflt;
03479 # ifndef SKIP_ERT
03480 ASSERT(iopc < max_opacity);
03481 # endif
03482 iopc_inv = (float)1. - iopc;
03483 ipixel->clrflt += acc_clr * iopc_inv;
03484 iopc += acc_opc * iopc_inv;
03485 ipixel->opcflt = iopc;
03486
03487 #ifdef DEBUG
03488 if (ipixel == trace_pixel_ptr) {
03489 #ifdef COMPUTE_SHADOW_BUFFER
03490 printf("{%3d} %3d %3d", k, icount-i-count, j);
03491 #else
03492 printf("[%3d] %3d %3d", k, icount-i-count, j);
03493 #endif
03494 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03495 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03496 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03497 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03498 printf(" %3.0f %3.0f\n", iopc*255.,
03499 ipixel->clrflt);
03500
03501
03502 }
03503 #endif
03504 ;
03505 # ifndef SKIP_ERT
03506 if (iopc >= max_opacity) {
03507 ASSERT(ipixel->lnk == 0);
03508 ipixel->lnk = 1;
03509 }
03510 # endif
03511 };
03512 ipixel += 1;
03513 topRLEdata += 1 * voxel_istride;
03514 botRLEdata += 1 * voxel_istride;
03515 count--;
03516 SET_VOXELS_LOADED;
03517 }
03518 break;
03519 case TOP_NONZERO__ALL_NONZERO:
03520
03521
03522 if (!voxels_loaded) {
03523
03524 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03525
03526
03527 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03528 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03529
03530
03531
03532 top_clr =
03533 shade_table[shade_index + 1*0 + 0] *
03534 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03535 ;
03536 for (m = 1; m < num_materials; m++) {
03537
03538
03539 top_clr +=
03540 shade_table[shade_index + 1*m + 0] *
03541 weight_table[weight_index + m];
03542 ;
03543 };
03544 shade_factor = top_opc * slice_depth_cueing;
03545
03546 top_clr *= shade_factor;
03547 ;
03548 }
03549
03550 #ifdef DEBUG
03551 if (ipixel == trace_pixel_ptr) {
03552 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03553 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03554 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03555 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03556 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03557 }
03558 #endif
03559 ;
03560
03561 acc_opc = top_opc * wgtTL;
03562 acc_clr = top_clr * wgtTL;
03563
03564 #ifdef DEBUG
03565 if (ipixel == trace_pixel_ptr) {
03566 trace_opcTL = top_opc;
03567 trace_rclrTL = top_clr;
03568
03569 }
03570 #endif
03571 ;
03572
03573 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03574
03575
03576 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03577 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03578
03579
03580
03581 top_clr =
03582 shade_table[shade_index + 1*0 + 0] *
03583 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03584 ;
03585 for (m = 1; m < num_materials; m++) {
03586
03587
03588 top_clr +=
03589 shade_table[shade_index + 1*m + 0] *
03590 weight_table[weight_index + m];
03591 ;
03592 };
03593 shade_factor = top_opc * slice_depth_cueing;
03594
03595 top_clr *= shade_factor;
03596 ;
03597
03598 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03599
03600
03601 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03602 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03603
03604
03605
03606 bot_clr =
03607 shade_table[shade_index + 1*0 + 0] *
03608 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03609 ;
03610 for (m = 1; m < num_materials; m++) {
03611
03612
03613 bot_clr +=
03614 shade_table[shade_index + 1*m + 0] *
03615 weight_table[weight_index + m];
03616 ;
03617 };
03618 shade_factor = bot_opc * slice_depth_cueing;
03619
03620 bot_clr *= shade_factor;
03621 ;
03622
03623 acc_opc += top_opc * wgtTR;
03624 acc_clr += top_clr * wgtTR;
03625
03626 #ifdef DEBUG
03627 if (ipixel == trace_pixel_ptr) {
03628 trace_opcTR = top_opc;
03629 trace_rclrTR = top_clr;
03630
03631 }
03632 #endif
03633 ;
03634
03635 acc_opc += bot_opc * wgtBR;
03636 acc_clr += bot_clr * wgtBR;
03637
03638 #ifdef DEBUG
03639 if (ipixel == trace_pixel_ptr) {
03640 trace_opcBR = bot_opc;
03641 trace_rclrBR = bot_clr;
03642
03643 }
03644 #endif
03645 ;
03646
03647 COUNT_RESAMPLE;
03648 if (acc_opc > min_opacity) {
03649 COUNT_COMPOSITE;
03650 iopc = ipixel->opcflt;
03651 # ifndef SKIP_ERT
03652 ASSERT(iopc < max_opacity);
03653 # endif
03654 iopc_inv = (float)1. - iopc;
03655 ipixel->clrflt += acc_clr * iopc_inv;
03656 iopc += acc_opc * iopc_inv;
03657 ipixel->opcflt = iopc;
03658
03659 #ifdef DEBUG
03660 if (ipixel == trace_pixel_ptr) {
03661 #ifdef COMPUTE_SHADOW_BUFFER
03662 printf("{%3d} %3d %3d", k, icount-i-count, j);
03663 #else
03664 printf("[%3d] %3d %3d", k, icount-i-count, j);
03665 #endif
03666 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03667 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03668 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03669 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03670 printf(" %3.0f %3.0f\n", iopc*255.,
03671 ipixel->clrflt);
03672
03673
03674 }
03675 #endif
03676 ;
03677 # ifndef SKIP_ERT
03678 if (iopc >= max_opacity) {
03679 ASSERT(ipixel->lnk == 0);
03680 ipixel->lnk = 1;
03681 }
03682 # endif
03683 };
03684 ipixel += 1;
03685 topRLEdata += 1 * voxel_istride;
03686 botRLEdata += 1 * voxel_istride;
03687 count--;
03688 SET_VOXELS_LOADED;
03689
03690
03691
03692 while (count > 0) {
03693 if (PIXEL_IS_OPAQUE(ipixel))
03694 break;
03695 if (!voxels_loaded) {
03696
03697 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03698
03699
03700 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03701 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03702
03703
03704
03705 top_clr =
03706 shade_table[shade_index + 1*0 + 0] *
03707 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03708 ;
03709 for (m = 1; m < num_materials; m++) {
03710
03711
03712 top_clr +=
03713 shade_table[shade_index + 1*m + 0] *
03714 weight_table[weight_index + m];
03715 ;
03716 };
03717 shade_factor = top_opc * slice_depth_cueing;
03718
03719 top_clr *= shade_factor;
03720 ;
03721
03722 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03723
03724
03725 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03726 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03727
03728
03729
03730 bot_clr =
03731 shade_table[shade_index + 1*0 + 0] *
03732 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03733 ;
03734 for (m = 1; m < num_materials; m++) {
03735
03736
03737 bot_clr +=
03738 shade_table[shade_index + 1*m + 0] *
03739 weight_table[weight_index + m];
03740 ;
03741 };
03742 shade_factor = bot_opc * slice_depth_cueing;
03743
03744 bot_clr *= shade_factor;
03745 ;
03746 }
03747
03748 #ifdef DEBUG
03749 if (ipixel == trace_pixel_ptr) {
03750 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03751 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03752 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03753 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03754 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03755 }
03756 #endif
03757 ;
03758
03759 acc_opc = top_opc * wgtTL;
03760 acc_clr = top_clr * wgtTL;
03761
03762 #ifdef DEBUG
03763 if (ipixel == trace_pixel_ptr) {
03764 trace_opcTL = top_opc;
03765 trace_rclrTL = top_clr;
03766
03767 }
03768 #endif
03769 ;
03770
03771 acc_opc += bot_opc * wgtBL;
03772 acc_clr += bot_clr * wgtBL;
03773
03774 #ifdef DEBUG
03775 if (ipixel == trace_pixel_ptr) {
03776 trace_opcBL = bot_opc;
03777 trace_rclrBL = bot_clr;
03778
03779 }
03780 #endif
03781 ;
03782
03783 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03784
03785
03786 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03787 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03788
03789
03790
03791 top_clr =
03792 shade_table[shade_index + 1*0 + 0] *
03793 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03794 ;
03795 for (m = 1; m < num_materials; m++) {
03796
03797
03798 top_clr +=
03799 shade_table[shade_index + 1*m + 0] *
03800 weight_table[weight_index + m];
03801 ;
03802 };
03803 shade_factor = top_opc * slice_depth_cueing;
03804
03805 top_clr *= shade_factor;
03806 ;
03807
03808 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03809
03810
03811 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03812 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03813
03814
03815
03816 bot_clr =
03817 shade_table[shade_index + 1*0 + 0] *
03818 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03819 ;
03820 for (m = 1; m < num_materials; m++) {
03821
03822
03823 bot_clr +=
03824 shade_table[shade_index + 1*m + 0] *
03825 weight_table[weight_index + m];
03826 ;
03827 };
03828 shade_factor = bot_opc * slice_depth_cueing;
03829
03830 bot_clr *= shade_factor;
03831 ;
03832
03833 acc_opc += top_opc * wgtTR;
03834 acc_clr += top_clr * wgtTR;
03835
03836 #ifdef DEBUG
03837 if (ipixel == trace_pixel_ptr) {
03838 trace_opcTR = top_opc;
03839 trace_rclrTR = top_clr;
03840
03841 }
03842 #endif
03843 ;
03844
03845 acc_opc += bot_opc * wgtBR;
03846 acc_clr += bot_clr * wgtBR;
03847
03848 #ifdef DEBUG
03849 if (ipixel == trace_pixel_ptr) {
03850 trace_opcBR = bot_opc;
03851 trace_rclrBR = bot_clr;
03852
03853 }
03854 #endif
03855 ;
03856
03857 COUNT_RESAMPLE;
03858 if (acc_opc > min_opacity) {
03859 COUNT_COMPOSITE;
03860 iopc = ipixel->opcflt;
03861 # ifndef SKIP_ERT
03862 ASSERT(iopc < max_opacity);
03863 # endif
03864 iopc_inv = (float)1. - iopc;
03865 ipixel->clrflt += acc_clr * iopc_inv;
03866 iopc += acc_opc * iopc_inv;
03867 ipixel->opcflt = iopc;
03868
03869 #ifdef DEBUG
03870 if (ipixel == trace_pixel_ptr) {
03871 #ifdef COMPUTE_SHADOW_BUFFER
03872 printf("{%3d} %3d %3d", k, icount-i-count, j);
03873 #else
03874 printf("[%3d] %3d %3d", k, icount-i-count, j);
03875 #endif
03876 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03877 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03878 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03879 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03880 printf(" %3.0f %3.0f\n", iopc*255.,
03881 ipixel->clrflt);
03882
03883
03884 }
03885 #endif
03886 ;
03887 # ifndef SKIP_ERT
03888 if (iopc >= max_opacity) {
03889 ASSERT(ipixel->lnk == 0);
03890 ipixel->lnk = 1;
03891 }
03892 # endif
03893 };
03894 ipixel += 1;
03895 topRLEdata += 1 * voxel_istride;
03896 botRLEdata += 1 * voxel_istride;
03897 count--;
03898 SET_VOXELS_LOADED;
03899 }
03900 break;
03901 case BOT_NONZERO__ALL_NONZERO:
03902
03903
03904 if (!voxels_loaded) {
03905
03906 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03907
03908
03909 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03910 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03911
03912
03913
03914 bot_clr =
03915 shade_table[shade_index + 1*0 + 0] *
03916 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03917 ;
03918 for (m = 1; m < num_materials; m++) {
03919
03920
03921 bot_clr +=
03922 shade_table[shade_index + 1*m + 0] *
03923 weight_table[weight_index + m];
03924 ;
03925 };
03926 shade_factor = bot_opc * slice_depth_cueing;
03927
03928 bot_clr *= shade_factor;
03929 ;
03930 }
03931
03932 #ifdef DEBUG
03933 if (ipixel == trace_pixel_ptr) {
03934 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03935 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03936 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03937 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03938 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03939 }
03940 #endif
03941 ;
03942
03943 acc_opc = bot_opc * wgtBL;
03944 acc_clr = bot_clr * wgtBL;
03945
03946 #ifdef DEBUG
03947 if (ipixel == trace_pixel_ptr) {
03948 trace_opcBL = bot_opc;
03949 trace_rclrBL = bot_clr;
03950
03951 }
03952 #endif
03953 ;
03954
03955 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03956
03957
03958 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03959 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03960
03961
03962
03963 top_clr =
03964 shade_table[shade_index + 1*0 + 0] *
03965 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03966 ;
03967 for (m = 1; m < num_materials; m++) {
03968
03969
03970 top_clr +=
03971 shade_table[shade_index + 1*m + 0] *
03972 weight_table[weight_index + m];
03973 ;
03974 };
03975 shade_factor = top_opc * slice_depth_cueing;
03976
03977 top_clr *= shade_factor;
03978 ;
03979
03980 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03981
03982
03983 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03984 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03985
03986
03987
03988 bot_clr =
03989 shade_table[shade_index + 1*0 + 0] *
03990 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03991 ;
03992 for (m = 1; m < num_materials; m++) {
03993
03994
03995 bot_clr +=
03996 shade_table[shade_index + 1*m + 0] *
03997 weight_table[weight_index + m];
03998 ;
03999 };
04000 shade_factor = bot_opc * slice_depth_cueing;
04001
04002 bot_clr *= shade_factor;
04003 ;
04004
04005 acc_opc += top_opc * wgtTR;
04006 acc_clr += top_clr * wgtTR;
04007
04008 #ifdef DEBUG
04009 if (ipixel == trace_pixel_ptr) {
04010 trace_opcTR = top_opc;
04011 trace_rclrTR = top_clr;
04012
04013 }
04014 #endif
04015 ;
04016
04017 acc_opc += bot_opc * wgtBR;
04018 acc_clr += bot_clr * wgtBR;
04019
04020 #ifdef DEBUG
04021 if (ipixel == trace_pixel_ptr) {
04022 trace_opcBR = bot_opc;
04023 trace_rclrBR = bot_clr;
04024
04025 }
04026 #endif
04027 ;
04028
04029 COUNT_RESAMPLE;
04030 if (acc_opc > min_opacity) {
04031 COUNT_COMPOSITE;
04032 iopc = ipixel->opcflt;
04033 # ifndef SKIP_ERT
04034 ASSERT(iopc < max_opacity);
04035 # endif
04036 iopc_inv = (float)1. - iopc;
04037 ipixel->clrflt += acc_clr * iopc_inv;
04038 iopc += acc_opc * iopc_inv;
04039 ipixel->opcflt = iopc;
04040
04041 #ifdef DEBUG
04042 if (ipixel == trace_pixel_ptr) {
04043 #ifdef COMPUTE_SHADOW_BUFFER
04044 printf("{%3d} %3d %3d", k, icount-i-count, j);
04045 #else
04046 printf("[%3d] %3d %3d", k, icount-i-count, j);
04047 #endif
04048 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04049 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04050 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04051 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04052 printf(" %3.0f %3.0f\n", iopc*255.,
04053 ipixel->clrflt);
04054
04055
04056 }
04057 #endif
04058 ;
04059 # ifndef SKIP_ERT
04060 if (iopc >= max_opacity) {
04061 ASSERT(ipixel->lnk == 0);
04062 ipixel->lnk = 1;
04063 }
04064 # endif
04065 };
04066 ipixel += 1;
04067 topRLEdata += 1 * voxel_istride;
04068 botRLEdata += 1 * voxel_istride;
04069 count--;
04070 SET_VOXELS_LOADED;
04071
04072
04073
04074 while (count > 0) {
04075 if (PIXEL_IS_OPAQUE(ipixel))
04076 break;
04077 if (!voxels_loaded) {
04078
04079 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04080
04081
04082 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04083 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04084
04085
04086
04087 top_clr =
04088 shade_table[shade_index + 1*0 + 0] *
04089 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04090 ;
04091 for (m = 1; m < num_materials; m++) {
04092
04093
04094 top_clr +=
04095 shade_table[shade_index + 1*m + 0] *
04096 weight_table[weight_index + m];
04097 ;
04098 };
04099 shade_factor = top_opc * slice_depth_cueing;
04100
04101 top_clr *= shade_factor;
04102 ;
04103
04104 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04105
04106
04107 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04108 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04109
04110
04111
04112 bot_clr =
04113 shade_table[shade_index + 1*0 + 0] *
04114 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04115 ;
04116 for (m = 1; m < num_materials; m++) {
04117
04118
04119 bot_clr +=
04120 shade_table[shade_index + 1*m + 0] *
04121 weight_table[weight_index + m];
04122 ;
04123 };
04124 shade_factor = bot_opc * slice_depth_cueing;
04125
04126 bot_clr *= shade_factor;
04127 ;
04128 }
04129
04130 #ifdef DEBUG
04131 if (ipixel == trace_pixel_ptr) {
04132 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04133 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04134 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04135 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04136 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04137 }
04138 #endif
04139 ;
04140
04141 acc_opc = top_opc * wgtTL;
04142 acc_clr = top_clr * wgtTL;
04143
04144 #ifdef DEBUG
04145 if (ipixel == trace_pixel_ptr) {
04146 trace_opcTL = top_opc;
04147 trace_rclrTL = top_clr;
04148
04149 }
04150 #endif
04151 ;
04152
04153 acc_opc += bot_opc * wgtBL;
04154 acc_clr += bot_clr * wgtBL;
04155
04156 #ifdef DEBUG
04157 if (ipixel == trace_pixel_ptr) {
04158 trace_opcBL = bot_opc;
04159 trace_rclrBL = bot_clr;
04160
04161 }
04162 #endif
04163 ;
04164
04165 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04166
04167
04168 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04169 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04170
04171
04172
04173 top_clr =
04174 shade_table[shade_index + 1*0 + 0] *
04175 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04176 ;
04177 for (m = 1; m < num_materials; m++) {
04178
04179
04180 top_clr +=
04181 shade_table[shade_index + 1*m + 0] *
04182 weight_table[weight_index + m];
04183 ;
04184 };
04185 shade_factor = top_opc * slice_depth_cueing;
04186
04187 top_clr *= shade_factor;
04188 ;
04189
04190 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04191
04192
04193 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04194 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04195
04196
04197
04198 bot_clr =
04199 shade_table[shade_index + 1*0 + 0] *
04200 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04201 ;
04202 for (m = 1; m < num_materials; m++) {
04203
04204
04205 bot_clr +=
04206 shade_table[shade_index + 1*m + 0] *
04207 weight_table[weight_index + m];
04208 ;
04209 };
04210 shade_factor = bot_opc * slice_depth_cueing;
04211
04212 bot_clr *= shade_factor;
04213 ;
04214
04215 acc_opc += top_opc * wgtTR;
04216 acc_clr += top_clr * wgtTR;
04217
04218 #ifdef DEBUG
04219 if (ipixel == trace_pixel_ptr) {
04220 trace_opcTR = top_opc;
04221 trace_rclrTR = top_clr;
04222
04223 }
04224 #endif
04225 ;
04226
04227 acc_opc += bot_opc * wgtBR;
04228 acc_clr += bot_clr * wgtBR;
04229
04230 #ifdef DEBUG
04231 if (ipixel == trace_pixel_ptr) {
04232 trace_opcBR = bot_opc;
04233 trace_rclrBR = bot_clr;
04234
04235 }
04236 #endif
04237 ;
04238
04239 COUNT_RESAMPLE;
04240 if (acc_opc > min_opacity) {
04241 COUNT_COMPOSITE;
04242 iopc = ipixel->opcflt;
04243 # ifndef SKIP_ERT
04244 ASSERT(iopc < max_opacity);
04245 # endif
04246 iopc_inv = (float)1. - iopc;
04247 ipixel->clrflt += acc_clr * iopc_inv;
04248 iopc += acc_opc * iopc_inv;
04249 ipixel->opcflt = iopc;
04250
04251 #ifdef DEBUG
04252 if (ipixel == trace_pixel_ptr) {
04253 #ifdef COMPUTE_SHADOW_BUFFER
04254 printf("{%3d} %3d %3d", k, icount-i-count, j);
04255 #else
04256 printf("[%3d] %3d %3d", k, icount-i-count, j);
04257 #endif
04258 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04259 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04260 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04261 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04262 printf(" %3.0f %3.0f\n", iopc*255.,
04263 ipixel->clrflt);
04264
04265
04266 }
04267 #endif
04268 ;
04269 # ifndef SKIP_ERT
04270 if (iopc >= max_opacity) {
04271 ASSERT(ipixel->lnk == 0);
04272 ipixel->lnk = 1;
04273 }
04274 # endif
04275 };
04276 ipixel += 1;
04277 topRLEdata += 1 * voxel_istride;
04278 botRLEdata += 1 * voxel_istride;
04279 count--;
04280 SET_VOXELS_LOADED;
04281 }
04282 break;
04283 case ALL_NONZERO__ALL_NONZERO:
04284
04285 while (count > 0) {
04286 if (PIXEL_IS_OPAQUE(ipixel))
04287 break;
04288 if (!voxels_loaded) {
04289
04290 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04291
04292
04293 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04294 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04295
04296
04297
04298 top_clr =
04299 shade_table[shade_index + 1*0 + 0] *
04300 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04301 ;
04302 for (m = 1; m < num_materials; m++) {
04303
04304
04305 top_clr +=
04306 shade_table[shade_index + 1*m + 0] *
04307 weight_table[weight_index + m];
04308 ;
04309 };
04310 shade_factor = top_opc * slice_depth_cueing;
04311
04312 top_clr *= shade_factor;
04313 ;
04314
04315 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04316
04317
04318 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04319 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04320
04321
04322
04323 bot_clr =
04324 shade_table[shade_index + 1*0 + 0] *
04325 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04326 ;
04327 for (m = 1; m < num_materials; m++) {
04328
04329
04330 bot_clr +=
04331 shade_table[shade_index + 1*m + 0] *
04332 weight_table[weight_index + m];
04333 ;
04334 };
04335 shade_factor = bot_opc * slice_depth_cueing;
04336
04337 bot_clr *= shade_factor;
04338 ;
04339 }
04340
04341 #ifdef DEBUG
04342 if (ipixel == trace_pixel_ptr) {
04343 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04344 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04345 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04346 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04347 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04348 }
04349 #endif
04350 ;
04351
04352 acc_opc = top_opc * wgtTL;
04353 acc_clr = top_clr * wgtTL;
04354
04355 #ifdef DEBUG
04356 if (ipixel == trace_pixel_ptr) {
04357 trace_opcTL = top_opc;
04358 trace_rclrTL = top_clr;
04359
04360 }
04361 #endif
04362 ;
04363
04364 acc_opc += bot_opc * wgtBL;
04365 acc_clr += bot_clr * wgtBL;
04366
04367 #ifdef DEBUG
04368 if (ipixel == trace_pixel_ptr) {
04369 trace_opcBL = bot_opc;
04370 trace_rclrBL = bot_clr;
04371
04372 }
04373 #endif
04374 ;
04375
04376 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04377
04378
04379 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04380 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04381
04382
04383
04384 top_clr =
04385 shade_table[shade_index + 1*0 + 0] *
04386 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04387 ;
04388 for (m = 1; m < num_materials; m++) {
04389
04390
04391 top_clr +=
04392 shade_table[shade_index + 1*m + 0] *
04393 weight_table[weight_index + m];
04394 ;
04395 };
04396 shade_factor = top_opc * slice_depth_cueing;
04397
04398 top_clr *= shade_factor;
04399 ;
04400
04401 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04402
04403
04404 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04405 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04406
04407
04408
04409 bot_clr =
04410 shade_table[shade_index + 1*0 + 0] *
04411 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04412 ;
04413 for (m = 1; m < num_materials; m++) {
04414
04415
04416 bot_clr +=
04417 shade_table[shade_index + 1*m + 0] *
04418 weight_table[weight_index + m];
04419 ;
04420 };
04421 shade_factor = bot_opc * slice_depth_cueing;
04422
04423 bot_clr *= shade_factor;
04424 ;
04425
04426 acc_opc += top_opc * wgtTR;
04427 acc_clr += top_clr * wgtTR;
04428
04429 #ifdef DEBUG
04430 if (ipixel == trace_pixel_ptr) {
04431 trace_opcTR = top_opc;
04432 trace_rclrTR = top_clr;
04433
04434 }
04435 #endif
04436 ;
04437
04438 acc_opc += bot_opc * wgtBR;
04439 acc_clr += bot_clr * wgtBR;
04440
04441 #ifdef DEBUG
04442 if (ipixel == trace_pixel_ptr) {
04443 trace_opcBR = bot_opc;
04444 trace_rclrBR = bot_clr;
04445
04446 }
04447 #endif
04448 ;
04449
04450 COUNT_RESAMPLE;
04451 if (acc_opc > min_opacity) {
04452 COUNT_COMPOSITE;
04453 iopc = ipixel->opcflt;
04454 # ifndef SKIP_ERT
04455 ASSERT(iopc < max_opacity);
04456 # endif
04457 iopc_inv = (float)1. - iopc;
04458 ipixel->clrflt += acc_clr * iopc_inv;
04459 iopc += acc_opc * iopc_inv;
04460 ipixel->opcflt = iopc;
04461
04462 #ifdef DEBUG
04463 if (ipixel == trace_pixel_ptr) {
04464 #ifdef COMPUTE_SHADOW_BUFFER
04465 printf("{%3d} %3d %3d", k, icount-i-count, j);
04466 #else
04467 printf("[%3d] %3d %3d", k, icount-i-count, j);
04468 #endif
04469 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04470 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04471 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04472 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04473 printf(" %3.0f %3.0f\n", iopc*255.,
04474 ipixel->clrflt);
04475
04476
04477 }
04478 #endif
04479 ;
04480 # ifndef SKIP_ERT
04481 if (iopc >= max_opacity) {
04482 ASSERT(ipixel->lnk == 0);
04483 ipixel->lnk = 1;
04484 }
04485 # endif
04486 };
04487 ipixel += 1;
04488 topRLEdata += 1 * voxel_istride;
04489 botRLEdata += 1 * voxel_istride;
04490 count--;
04491 SET_VOXELS_LOADED;
04492 }
04493 break;
04494 default:
04495 VPBug("illegal value for run states in compositing loop");
04496 }
04497 #else
04498
04499 while (count > 0) {
04500 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
04501 ipixel += count;
04502 if (i != -1) {
04503 ;
04504 ;
04505 }
04506 count = 0;
04507 break;
04508 }
04509 if (ipixel->lnk != 0)
04510 break;
04511
04512 #ifdef DEBUG
04513 if (ipixel == trace_pixel_ptr) {
04514 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04515 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04516 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04517 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04518 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04519 }
04520 #endif
04521 ;
04522
04523 acc_opc = 0;
04524 acc_clr = 0;
04525 if (last_run_state & TOP_NONZERO) {
04526 if (!voxels_loaded) {
04527
04528 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04529
04530
04531 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04532 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04533
04534
04535
04536 top_clr =
04537 shade_table[shade_index + 1*0 + 0] *
04538 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04539 ;
04540 for (m = 1; m < num_materials; m++) {
04541
04542
04543 top_clr +=
04544 shade_table[shade_index + 1*m + 0] *
04545 weight_table[weight_index + m];
04546 ;
04547 };
04548 shade_factor = top_opc * slice_depth_cueing;
04549
04550 top_clr *= shade_factor;
04551 ;
04552 }
04553
04554 acc_opc += top_opc * wgtTL;
04555 acc_clr += top_clr * wgtTL;
04556
04557 #ifdef DEBUG
04558 if (ipixel == trace_pixel_ptr) {
04559 trace_opcTL = top_opc;
04560 trace_rclrTL = top_clr;
04561
04562 }
04563 #endif
04564 ;
04565 }
04566 if (last_run_state & BOT_NONZERO) {
04567 if (!voxels_loaded) {
04568
04569 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04570
04571
04572 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04573 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04574
04575
04576
04577 bot_clr =
04578 shade_table[shade_index + 1*0 + 0] *
04579 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04580 ;
04581 for (m = 1; m < num_materials; m++) {
04582
04583
04584 bot_clr +=
04585 shade_table[shade_index + 1*m + 0] *
04586 weight_table[weight_index + m];
04587 ;
04588 };
04589 shade_factor = bot_opc * slice_depth_cueing;
04590
04591 bot_clr *= shade_factor;
04592 ;
04593 }
04594
04595 acc_opc += bot_opc * wgtBL;
04596 acc_clr += bot_clr * wgtBL;
04597
04598 #ifdef DEBUG
04599 if (ipixel == trace_pixel_ptr) {
04600 trace_opcBL = bot_opc;
04601 trace_rclrBL = bot_clr;
04602
04603 }
04604 #endif
04605 ;
04606 }
04607 if (run_state & TOP_NONZERO) {
04608
04609 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04610
04611
04612 shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04613 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04614
04615
04616
04617 top_clr =
04618 shade_table[shade_index + 1*0 + 0] *
04619 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04620 ;
04621 for (m = 1; m < num_materials; m++) {
04622
04623
04624 top_clr +=
04625 shade_table[shade_index + 1*m + 0] *
04626 weight_table[weight_index + m];
04627 ;
04628 };
04629 shade_factor = top_opc * slice_depth_cueing;
04630
04631 top_clr *= shade_factor;
04632 ;
04633
04634 acc_opc += top_opc * wgtTR;
04635 acc_clr += top_clr * wgtTR;
04636
04637 #ifdef DEBUG
04638 if (ipixel == trace_pixel_ptr) {
04639 trace_opcTR = top_opc;
04640 trace_rclrTR = top_clr;
04641
04642 }
04643 #endif
04644 ;
04645 topRLEdata += 1 * voxel_istride;
04646 } else {
04647 if (i != -1) {
04648 ;
04649 }
04650 }
04651 if (run_state & BOT_NONZERO) {
04652
04653 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04654
04655
04656 shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04657 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04658
04659
04660
04661 bot_clr =
04662 shade_table[shade_index + 1*0 + 0] *
04663 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04664 ;
04665 for (m = 1; m < num_materials; m++) {
04666
04667
04668 bot_clr +=
04669 shade_table[shade_index + 1*m + 0] *
04670 weight_table[weight_index + m];
04671 ;
04672 };
04673 shade_factor = bot_opc * slice_depth_cueing;
04674
04675 bot_clr *= shade_factor;
04676 ;
04677
04678 acc_opc += bot_opc * wgtBR;
04679 acc_clr += bot_clr * wgtBR;
04680
04681 #ifdef DEBUG
04682 if (ipixel == trace_pixel_ptr) {
04683 trace_opcBR = bot_opc;
04684 trace_rclrBR = bot_clr;
04685
04686 }
04687 #endif
04688 ;
04689 botRLEdata += 1 * voxel_istride;
04690 } else {
04691 if (i != -1) {
04692 ;
04693 }
04694 }
04695
04696 COUNT_RESAMPLE;
04697 if (acc_opc > min_opacity) {
04698 COUNT_COMPOSITE;
04699 iopc = ipixel->opcflt;
04700 # ifndef SKIP_ERT
04701 ASSERT(iopc < max_opacity);
04702 # endif
04703 iopc_inv = (float)1. - iopc;
04704 ipixel->clrflt += acc_clr * iopc_inv;
04705 iopc += acc_opc * iopc_inv;
04706 ipixel->opcflt = iopc;
04707
04708 #ifdef DEBUG
04709 if (ipixel == trace_pixel_ptr) {
04710 #ifdef COMPUTE_SHADOW_BUFFER
04711 printf("{%3d} %3d %3d", k, icount-i-count, j);
04712 #else
04713 printf("[%3d] %3d %3d", k, icount-i-count, j);
04714 #endif
04715 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04716 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04717 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04718 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04719 printf(" %3.0f %3.0f\n", iopc*255.,
04720 ipixel->clrflt);
04721
04722
04723 }
04724 #endif
04725 ;
04726 # ifndef SKIP_ERT
04727 if (iopc >= max_opacity) {
04728 ASSERT(ipixel->lnk == 0);
04729 ipixel->lnk = 1;
04730 }
04731 # endif
04732 };
04733 ipixel += 1;
04734 count--;
04735 SET_VOXELS_LOADED;
04736 last_run_state = run_state;
04737 }
04738 #endif
04739
04740 GET_HIRES_TIME(vpc, t1);
04741 STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
04742 COPY_HIRES_TIME(t0, t1);
04743
04744 if (count > 0) {
04745 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
04746 toprun_count += count;
04747 botrun_count += count;
04748 i += count;
04749 }
04750 #endif
04751
04752
04753
04754
04755
04756 last_run_state = run_state;
04757 }
04758
04759
04760
04761
04762
04763 #ifdef UNROLL_RUN_LOOP
04764 ASSERT(i == 0);
04765 #else
04766 ASSERT(i == -1);
04767 #endif
04768
04769 #ifndef SKIP_COMPOSITE
04770 #ifdef UNROLL_RUN_LOOP
04771
04772 if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
04773
04774
04775 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
04776 switch (last_run_state) {
04777 case TOP_NONZERO:
04778
04779 if (!voxels_loaded) {
04780
04781 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04782
04783
04784 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04785 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04786
04787
04788
04789 top_clr =
04790 shade_table[shade_index + 1*0 + 0] *
04791 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04792 ;
04793 for (m = 1; m < num_materials; m++) {
04794
04795
04796 top_clr +=
04797 shade_table[shade_index + 1*m + 0] *
04798 weight_table[weight_index + m];
04799 ;
04800 };
04801 shade_factor = top_opc * slice_depth_cueing;
04802
04803 top_clr *= shade_factor;
04804 ;
04805 }
04806
04807 #ifdef DEBUG
04808 if (ipixel == trace_pixel_ptr) {
04809 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04810 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04811 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04812 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04813 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04814 }
04815 #endif
04816 ;
04817
04818 acc_opc = top_opc * wgtTL;
04819 acc_clr = top_clr * wgtTL;
04820
04821 #ifdef DEBUG
04822 if (ipixel == trace_pixel_ptr) {
04823 trace_opcTL = top_opc;
04824 trace_rclrTL = top_clr;
04825
04826 }
04827 #endif
04828 ;
04829
04830 COUNT_RESAMPLE;
04831 if (acc_opc > min_opacity) {
04832 COUNT_COMPOSITE;
04833 iopc = ipixel->opcflt;
04834 # ifndef SKIP_ERT
04835 ASSERT(iopc < max_opacity);
04836 # endif
04837 iopc_inv = (float)1. - iopc;
04838 ipixel->clrflt += acc_clr * iopc_inv;
04839 iopc += acc_opc * iopc_inv;
04840 ipixel->opcflt = iopc;
04841
04842 #ifdef DEBUG
04843 if (ipixel == trace_pixel_ptr) {
04844 #ifdef COMPUTE_SHADOW_BUFFER
04845 printf("{%3d} %3d %3d", k, icount-i-count, j);
04846 #else
04847 printf("[%3d] %3d %3d", k, icount-i-count, j);
04848 #endif
04849 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04850 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04851 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04852 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04853 printf(" %3.0f %3.0f\n", iopc*255.,
04854 ipixel->clrflt);
04855
04856
04857 }
04858 #endif
04859 ;
04860 # ifndef SKIP_ERT
04861 if (iopc >= max_opacity) {
04862 ASSERT(ipixel->lnk == 0);
04863 ipixel->lnk = 1;
04864 }
04865 # endif
04866 };
04867 break;
04868 case BOT_NONZERO:
04869
04870 if (!voxels_loaded) {
04871
04872 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04873
04874
04875 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04876 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04877
04878
04879
04880 bot_clr =
04881 shade_table[shade_index + 1*0 + 0] *
04882 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04883 ;
04884 for (m = 1; m < num_materials; m++) {
04885
04886
04887 bot_clr +=
04888 shade_table[shade_index + 1*m + 0] *
04889 weight_table[weight_index + m];
04890 ;
04891 };
04892 shade_factor = bot_opc * slice_depth_cueing;
04893
04894 bot_clr *= shade_factor;
04895 ;
04896 }
04897
04898 #ifdef DEBUG
04899 if (ipixel == trace_pixel_ptr) {
04900 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04901 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04902 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04903 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04904 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04905 }
04906 #endif
04907 ;
04908
04909 acc_opc = bot_opc * wgtBL;
04910 acc_clr = bot_clr * wgtBL;
04911
04912 #ifdef DEBUG
04913 if (ipixel == trace_pixel_ptr) {
04914 trace_opcBL = bot_opc;
04915 trace_rclrBL = bot_clr;
04916
04917 }
04918 #endif
04919 ;
04920
04921 COUNT_RESAMPLE;
04922 if (acc_opc > min_opacity) {
04923 COUNT_COMPOSITE;
04924 iopc = ipixel->opcflt;
04925 # ifndef SKIP_ERT
04926 ASSERT(iopc < max_opacity);
04927 # endif
04928 iopc_inv = (float)1. - iopc;
04929 ipixel->clrflt += acc_clr * iopc_inv;
04930 iopc += acc_opc * iopc_inv;
04931 ipixel->opcflt = iopc;
04932
04933 #ifdef DEBUG
04934 if (ipixel == trace_pixel_ptr) {
04935 #ifdef COMPUTE_SHADOW_BUFFER
04936 printf("{%3d} %3d %3d", k, icount-i-count, j);
04937 #else
04938 printf("[%3d] %3d %3d", k, icount-i-count, j);
04939 #endif
04940 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04941 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04942 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04943 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04944 printf(" %3.0f %3.0f\n", iopc*255.,
04945 ipixel->clrflt);
04946
04947
04948 }
04949 #endif
04950 ;
04951 # ifndef SKIP_ERT
04952 if (iopc >= max_opacity) {
04953 ASSERT(ipixel->lnk == 0);
04954 ipixel->lnk = 1;
04955 }
04956 # endif
04957 };
04958 break;
04959 case ALL_NONZERO:
04960
04961 if (!voxels_loaded) {
04962
04963 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04964
04965
04966 shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04967 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04968
04969
04970
04971 top_clr =
04972 shade_table[shade_index + 1*0 + 0] *
04973 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04974 ;
04975 for (m = 1; m < num_materials; m++) {
04976
04977
04978 top_clr +=
04979 shade_table[shade_index + 1*m + 0] *
04980 weight_table[weight_index + m];
04981 ;
04982 };
04983 shade_factor = top_opc * slice_depth_cueing;
04984
04985 top_clr *= shade_factor;
04986 ;
04987
04988 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04989
04990
04991 shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04992 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04993
04994
04995
04996 bot_clr =
04997 shade_table[shade_index + 1*0 + 0] *
04998 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04999 ;
05000 for (m = 1; m < num_materials; m++) {
05001
05002
05003 bot_clr +=
05004 shade_table[shade_index + 1*m + 0] *
05005 weight_table[weight_index + m];
05006 ;
05007 };
05008 shade_factor = bot_opc * slice_depth_cueing;
05009
05010 bot_clr *= shade_factor;
05011 ;
05012 }
05013
05014 #ifdef DEBUG
05015 if (ipixel == trace_pixel_ptr) {
05016 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05017 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05018 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05019 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05020 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05021 }
05022 #endif
05023 ;
05024
05025 acc_opc = top_opc * wgtTL;
05026 acc_clr = top_clr * wgtTL;
05027
05028 #ifdef DEBUG
05029 if (ipixel == trace_pixel_ptr) {
05030 trace_opcTL = top_opc;
05031 trace_rclrTL = top_clr;
05032
05033 }
05034 #endif
05035 ;
05036
05037 acc_opc += bot_opc * wgtBL;
05038 acc_clr += bot_clr * wgtBL;
05039
05040 #ifdef DEBUG
05041 if (ipixel == trace_pixel_ptr) {
05042 trace_opcBL = bot_opc;
05043 trace_rclrBL = bot_clr;
05044
05045 }
05046 #endif
05047 ;
05048
05049 COUNT_RESAMPLE;
05050 if (acc_opc > min_opacity) {
05051 COUNT_COMPOSITE;
05052 iopc = ipixel->opcflt;
05053 # ifndef SKIP_ERT
05054 ASSERT(iopc < max_opacity);
05055 # endif
05056 iopc_inv = (float)1. - iopc;
05057 ipixel->clrflt += acc_clr * iopc_inv;
05058 iopc += acc_opc * iopc_inv;
05059 ipixel->opcflt = iopc;
05060
05061 #ifdef DEBUG
05062 if (ipixel == trace_pixel_ptr) {
05063 #ifdef COMPUTE_SHADOW_BUFFER
05064 printf("{%3d} %3d %3d", k, icount-i-count, j);
05065 #else
05066 printf("[%3d] %3d %3d", k, icount-i-count, j);
05067 #endif
05068 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05069 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05070 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05071 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05072 printf(" %3.0f %3.0f\n", iopc*255.,
05073 ipixel->clrflt);
05074
05075
05076 }
05077 #endif
05078 ;
05079 # ifndef SKIP_ERT
05080 if (iopc >= max_opacity) {
05081 ASSERT(ipixel->lnk == 0);
05082 ipixel->lnk = 1;
05083 }
05084 # endif
05085 };
05086 break;
05087 default:
05088 VPBug("illegal value for run state at end of scanline");
05089 }
05090 } else if (last_run_state == ALL_ZERO) {
05091 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
05092 } else {
05093 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
05094 }
05095 #endif
05096 #endif
05097
05098 #ifndef UNROLL_RUN_LOOP
05099 run_state = final_run_state;
05100 #endif
05101
05102 if (j != 0 && ((run_state & 1) == 0)) {
05103 toprun_count = *topRLElen++;
05104 ASSERT(toprun_count == 0);
05105 }
05106 if (j != jcount && ((run_state & 2) == 0)) {
05107 botrun_count = *botRLElen++;
05108 ASSERT(botrun_count == 0);
05109 }
05110
05111
05112 #ifdef UNROLL_RUN_LOOP
05113 ipixel += intermediate_width - icount;
05114 #ifdef USE_SHADOW_BUFFER
05115 shadow_pixel += shadow_width - icount;
05116 #endif
05117 #else
05118 ipixel += intermediate_width - (icount+1);
05119 #ifdef USE_SHADOW_BUFFER
05120 shadow_pixel += shadow_width - (icount+1);
05121 #endif
05122 #endif
05123
05124 Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
05125 }
05126
05127
05128
05129
05130
05131 GET_HIRES_TIME(vpc, t1);
05132 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
05133
05134 Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
05135 }