Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

vp_compAR11B.c

Go to the documentation of this file.
00001 /*
00002  * DO NOT EDIT THIS FILE! It was created automatically by m4.
00003  */
00004 
00005 /*
00006  * Copyright (c) 1994 The Board of Trustees of The Leland Stanford
00007  * Junior University.  All rights reserved.
00008  * 
00009  * Permission to use, copy, modify and distribute this software and its
00010  * documentation for any purpose is hereby granted without fee, provided
00011  * that the above copyright notice and this permission notice appear in
00012  * all copies of this software and that you do not sell the software.
00013  * Commercial licensing is available by contacting the author.
00014  * 
00015  * THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
00016  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
00017  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00018  * 
00019  * Author:
00020  *    Phil Lacroute
00021  *    Computer Systems Laboratory
00022  *    Electrical Engineering Dept.
00023  *    Stanford University
00024  */
00025 /*
00026  * vp_compA.m4
00027  *
00028  * Compositing routine for affine viewing transformations.
00029  *
00030  * Copyright (c) 1994 The Board of Trustees of The Leland Stanford
00031  * Junior University.  All rights reserved.
00032  *
00033  * Permission to use, copy, modify and distribute this software and its
00034  * documentation for any purpose is hereby granted without fee, provided
00035  * that the above copyright notice and this permission notice appear in
00036  * all copies of this software and that you do not sell the software.
00037  * Commercial licensing is available by contacting the author.
00038  * 
00039  * THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
00040  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
00041  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00042  *
00043  * Author:
00044  *    Phil Lacroute
00045  *    Computer Systems Laboratory
00046  *    Electrical Engineering Dept.
00047  *    Stanford University
00048  */
00049 
00050 /*
00051  * $Date: 2001/12/17 16:16:21 $
00052  * $Revision: 1.1 $
00053  */
00054 
00055 #include "vp_global.h"
00056 
00057 
00058 
00059     
00060     
00061     
00062     
00063     
00064 
00065     
00066     
00067     
00068     
00069     
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
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 #define GRAYSCALE
00123     
00124     
00125     
00126     
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 #define RAWVOLUME
00135         
00136         
00137         
00138         
00139         
00140         
00141         
00142 
00143 
00144 #undef INDEX_VOLUME
00145 
00146 
00147 
00148     
00149     
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 /* codes indicating the types of a pair of runs in adjacent scanlines */
00159 #define ALL_ZERO        0       /* both runs are runs of zeros */
00160 #define TOP_NONZERO     1       /* run for top scanline has nonzero data */
00161 #define BOT_NONZERO     2       /* run for bottom scanline has nonzero data */
00162 #define ALL_NONZERO     3       /* both runs have nonzero data */
00163 
00164 /* codes indicating the types for the current left and right voxel pairs */
00165 #define ALL_ZERO__ALL_ZERO              ((ALL_ZERO << 2) | ALL_ZERO)
00166 #define ALL_ZERO__TOP_NONZERO           ((ALL_ZERO << 2) | TOP_NONZERO)
00167 #define ALL_ZERO__BOT_NONZERO           ((ALL_ZERO << 2) | BOT_NONZERO)
00168 #define ALL_ZERO__ALL_NONZERO           ((ALL_ZERO << 2) | ALL_NONZERO)
00169 #define TOP_NONZERO__ALL_ZERO           ((TOP_NONZERO << 2) | ALL_ZERO)
00170 #define TOP_NONZERO__TOP_NONZERO        ((TOP_NONZERO << 2) | TOP_NONZERO)
00171 #define TOP_NONZERO__BOT_NONZERO        ((TOP_NONZERO << 2) | BOT_NONZERO)
00172 #define TOP_NONZERO__ALL_NONZERO        ((TOP_NONZERO << 2) | ALL_NONZERO)
00173 #define BOT_NONZERO__ALL_ZERO           ((BOT_NONZERO << 2) | ALL_ZERO)
00174 #define BOT_NONZERO__TOP_NONZERO        ((BOT_NONZERO << 2) | TOP_NONZERO)
00175 #define BOT_NONZERO__BOT_NONZERO        ((BOT_NONZERO << 2) | BOT_NONZERO)
00176 #define BOT_NONZERO__ALL_NONZERO        ((BOT_NONZERO << 2) | ALL_NONZERO)
00177 #define ALL_NONZERO__ALL_ZERO           ((ALL_NONZERO << 2) | ALL_ZERO)
00178 #define ALL_NONZERO__TOP_NONZERO        ((ALL_NONZERO << 2) | TOP_NONZERO)
00179 #define ALL_NONZERO__BOT_NONZERO        ((ALL_NONZERO << 2) | BOT_NONZERO)
00180 #define ALL_NONZERO__ALL_NONZERO        ((ALL_NONZERO << 2) | ALL_NONZERO)
00181 
00182 #ifdef SKIP_ERT
00183 #define PIXEL_IS_OPAQUE(ipixel) 0
00184 #else
00185 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00186 #endif
00187 
00188 #ifdef STATISTICS
00189 extern int vpResampleCount;
00190 extern int vpCompositeCount;
00191 extern int vpERTSkipCount;
00192 extern int vpERTSkipAgainCount;
00193 extern int vpERTUpdateCount;
00194 extern int vpSpecialZeroSkipCount;
00195 extern int vpRunFragmentCount;
00196 #define COUNT_RESAMPLE          vpResampleCount++
00197 #define COUNT_COMPOSITE         vpCompositeCount++
00198 #define COUNT_ERT_SKIP          vpERTSkipCount++
00199 #define COUNT_ERT_SKIP_AGAIN    vpERTSkipAgainCount++
00200 #define COUNT_ERT_UPDATE        vpERTUpdateCount++
00201 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00202 #define COUNT_RUN_FRAGMENT      vpRunFragmentCount++
00203 #else
00204 #define COUNT_RESAMPLE
00205 #define COUNT_COMPOSITE
00206 #define COUNT_ERT_SKIP
00207 #define COUNT_ERT_SKIP_AGAIN
00208 #define COUNT_ERT_UPDATE
00209 #define COUNT_SPECIAL_ZERO_SKIP
00210 #define COUNT_RUN_FRAGMENT
00211 #endif /* STATISTICS */
00212 
00213 /*
00214  * VPCompAR11B
00215  *
00216  * Compositing routine for run-length encoded volume data slices.
00217  * Decode and resample one slice of volume data, and composite
00218  * it into the intermediate image.  The resampling filter is a bilirp.
00219  */
00220 
00221 void
00222 VPCompAR11B (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00223           weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00224           voxel_data, voxel_istride, voxel_jstride )
00225 vpContext *vpc;                 /* context */
00226 int icount;                     /* slice size */
00227 int jcount;
00228 int k;                          /* slice number */
00229 double slice_depth_cueing_dbl;  /* depth cueing factor for slice */
00230 GrayIntPixel *intimage;         /* intermediate image pixels */
00231 double weightTLdbl;             /* resampling weights */
00232 double weightBLdbl;
00233 double weightTRdbl;
00234 double weightBRdbl;
00235 
00236                 void *voxel_data;               /* voxel data for slice */
00237                 int voxel_istride;              /* strides for voxel data */
00238                 int voxel_jstride;
00239 
00240 {
00241     int i, j;                   /* voxel index in rotated object space */
00242     GrayIntPixel *ipixel;       /* current intermediate image pixel */
00243     GrayIntPixel *ipixel2;      /* another intermediate image pixel */
00244     int update_interval;        /* # of pixels to skip when updating links */
00245     float iopc;                 /* intermediate pixel opacity (0-1) */
00246     float iopc_inv;             /* 1-iopc */
00247     float acc_opc;              /* accumulator for resampled voxel opacity */
00248     float top_opc, bot_opc;     /* voxel opacity (top and bottom scanlines) */
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;          /* if true, top/bot_opc contain valid
00255                                    data loaded during the last resample */
00256 #define CLEAR_VOXELS_LOADED     voxels_loaded = 0
00257 #define SET_VOXELS_LOADED       voxels_loaded = 1
00258 #endif
00259     float wgtTL, wgtBL,         /* weights in the range 0..1 which give the */
00260           wgtTR, wgtBR;         /*   fractional contribution of the */
00261                                 /*   neighboring voxels to the current */
00262                                 /*   intermediate image pixel */
00263     unsigned char *topRLElen;   /* length of current run in top scanline */
00264     unsigned char *botRLElen;   /* length of current run in bottom scanline */
00265     char *topRLEdata;           /* data for current run in top scanline */
00266     char *botRLEdata;           /* data for current run in bottom scanline */
00267     int toprun_count;           /* number of voxels left in top run */
00268     int botrun_count;           /* number of voxels left in bottom run */
00269     int last_run_state;         /* run state code for last resample */
00270     int run_state;              /* run state code for this resample */
00271     int final_run_state;        /* run state code for end of scanline */
00272     float min_opacity;          /* low opacity threshold */
00273     float max_opacity;          /* high opacity threshold */
00274     float slice_depth_cueing;   /* depth cueing factor for slice */
00275     float *opac_correct;        /* opacity correction table */
00276     int ert_skip_count;         /* number of pixels to skip for ERT */
00277     int intermediate_width;     /* width of intermediate image in pixels */
00278     int count;                  /* voxels left in current run */
00279     float *shade_table;         /* shade lookup table */
00280     int norm_offset;            /* byte offset to shade table index in voxel */
00281     int shade_index;            /* shade index */
00282     float shade_factor;         /* attenuation factor for color
00283                                    (voxel opacity * depth cueing) */
00284 
00285 #ifdef MULTIPLE_MATERIALS
00286     float *weight_table;        /* weight lookup table */
00287     int wgt_offset;             /* byte offset to weight table index */
00288     int weight_index;           /* weight index */
00289     int m, num_materials;
00290     float weight1, weight2;
00291 #endif /* MULTIPLE_MATERIALS */
00292 
00293 #ifdef GRAYSCALE
00294     float acc_clr;              /* accumulator for resampled color */
00295     float top_clr, bot_clr;     /* voxel color (top and bottom scanlines) */
00296 #endif /* GRAYSCALE */
00297 
00298 #ifdef RGB
00299     float acc_rclr;             /* accumulator for resampled color */
00300     float acc_gclr;
00301     float acc_bclr;
00302     float top_rclr;             /* voxel color (top and bottom scanlines) */
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;          /* size of a voxel in bytes */
00312 #endif
00313 
00314 #ifdef RAWVOLUME
00315     int use_octree;             /* if true then use the min-max octree */
00316     MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00317                                 /* stack for traversal of min-max octree */
00318     int scans_left;             /* scanlines until next octree traversal */
00319     int best_view_axis;         /* viewing axis */
00320     unsigned char runlen_buf1[VP_MAX_VOLUME_DIM]; /* buffers for run lengths */
00321     unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00322     unsigned char *top_len_base;/* first run length for top scanline */
00323     unsigned char *bot_len_base;/* first run length for bottom scanline */
00324     int opac_param;             /* parameter to opacity transfer function */
00325     float opacity;              /* voxel opacity */
00326     int opacity_int;            /* voxel opacity truncated to an integer */
00327     int param0_offset;          /* offset to first parameter in voxel */
00328     int param0_size;            /* size of first parameter in bytes */
00329     float *param0_table;        /* lookup table for first parameter */
00330     int param1_offset;          /* offset to second parameter in voxel */
00331     int param1_size;            /* size of second parameter in bytes */
00332     float *param1_table;        /* lookup table for second parameter */
00333     int param2_offset;          /* offset to third parameter in voxel */
00334     int param2_size;            /* size of third parameter in bytes */
00335     float *param2_table;        /* lookup table for third parameter */
00336 #endif /* RAWVOLUME */
00337 
00338 #ifdef INDEX_VOLUME
00339     unsigned char *scanline_topRLElen; /* first topRLElen in scanline */
00340     unsigned char *scanline_botRLElen; /* first botRLElen in scanline */
00341     char *scanline_topRLEdata;  /* first topRLEdata in scanline */
00342     char *scanline_botRLEdata;  /* first botRLEdata in scanline */
00343     VoxelLocation *top_voxel_index; /* voxel indexes for top scanline */
00344     VoxelLocation *bot_voxel_index; /* voxel indexes for bot scanline */
00345     VoxelLocation *vindex;
00346     int next_i;                 /* i coordinate of voxel to skip to */
00347     int next_scan;              /* true if skipped to next scanline */
00348 #endif /* INDEX_VOLUME */
00349 
00350 #ifdef CALLBACK
00351                                 /* shading callback function */
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;          /* client data handle */
00359 #endif /* CALLBACK */
00360 
00361 #ifdef USE_SHADOW_BUFFER
00362     float *shadow_table;        /* color lookup table for shadows */
00363     int shadow_width;           /* width of shadow buffer */
00364     GrayIntPixel *shadow_pixel; /* current shadow buffer pixel */
00365 #ifdef GRAYSCALE
00366     float top_sclr, bot_sclr;   /* shadow color (top and bottom scanlines) */
00367 #endif /* GRAYSCALE */
00368 #ifdef RGB
00369     float top_rsclr;            /* shadow color (top and bottom scanlines) */
00370     float bot_rsclr;
00371     float top_gsclr;
00372     float bot_gsclr;
00373     float top_bsclr;
00374     float bot_bsclr;
00375 #endif
00376 #endif /* SHADOW_BUFFER */
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 /* DEBUG */
00391 
00392     DECLARE_HIRES_TIME(t0);
00393     DECLARE_HIRES_TIME(t1);
00394 
00395     /*******************************************************************
00396      * Copy parameters from the rendering context into local variables.
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 /* MULTIPLE_MATERIALS */
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 /* RLEVOLUME */
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 /* RAWVOLUME */
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 /* DEBUG */
00509 
00510     /*******************************************************************
00511      * Loop over voxel scanlines.
00512      *******************************************************************/
00513 
00514     for (j = 0; j <= jcount; j++) {
00515 
00516         /***************************************************************
00517          * Initialize counters and flags.
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 /* RAWVOLUME */
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 /* INDEX_VOLUME */
00570 
00571         /***************************************************************
00572          * If the volume is not run-length encoded, use the min-max
00573          * to find run lengths for the current voxel scanline.
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 /* RAWVOLUME */
00607 
00608         /***************************************************************
00609          * Loop over runs in the voxel scanline.
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              * Skip over any empty runs at beginning of scanline.
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;      /* scanline is done */
00635                 }
00636 #endif
00637 
00638                 /* check if this is the start of a new run */
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                     /* find the union of the two runs of voxels */
00651                     count = MIN(toprun_count, botrun_count);
00652                     toprun_count -= count;
00653                     botrun_count -= count;
00654                     ipixel += count;
00655                     topRLEdata += count * voxel_istride;
00656                     botRLEdata += count * voxel_istride;
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              * Skip over opaque pixels (early-ray termination).
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;      /* scanline is done */
00684                 }
00685 #endif
00686 
00687                 /* find out how many pixels to skip */
00688                 if (ert_skip_count < i &&
00689                                 (count = ipixel[ert_skip_count].lnk) != 0) {
00690                     /* follow pointer chain */
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                     /* update some of the lnk pointers in the run of opaque
00698                        pixels; the more links we update the longer it will
00699                        take to perform the update, but we will potentially
00700                        save time in future slices by not having to follow
00701                        long pointer chains */
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                     /* update the current link */
00717                     COUNT_ERT_UPDATE;
00718                     if (ert_skip_count > 255)
00719                         ert_skip_count = 255;
00720                     ipixel->lnk = ert_skip_count;
00721                 }
00722 
00723                 /* skip over the opaque pixels */
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                 /* compute i coordinate of voxel to skip to */
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                 /* skip over voxels in top scanline */
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                 /* skip over voxels in bottom scanline */
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                 /* special case to skip over last voxel in scanline */
00767                 if (next_scan) {
00768                     /* advance to beginning of next top scanline */
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                         topRLEdata += 1 * voxel_istride;
00778                     }
00779 
00780                     /* advance to beginning of next bottom scanline */
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                         botRLEdata += 1 * voxel_istride;
00790                     }
00791                 }
00792 
00793 #else /* !INDEX_VOLUME */
00794                 /* skip over voxels in top scanline */
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                             topRLEdata += count * voxel_istride;
00803                         }
00804                         break;
00805                     } else {
00806                         count -= toprun_count;
00807                         if (run_state & 1) {
00808                             topRLEdata += toprun_count * voxel_istride;
00809                         } else {
00810                             topRLEdata += toprun_count * voxel_istride;
00811                         }
00812                         toprun_count = *topRLElen++;
00813                         if (toprun_count == 0)
00814                             toprun_count = *topRLElen++;
00815                         else
00816                             run_state ^= 1;
00817                     }
00818                 }
00819 
00820                 /* skip over voxels in bottom scanline */
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                             botRLEdata += count * voxel_istride;
00829                         }
00830                         break;
00831                     } else {
00832                         count -= botrun_count;
00833                         if (run_state & 2) {
00834                             botRLEdata += botrun_count * voxel_istride;
00835                         } else {
00836                             botRLEdata += botrun_count * voxel_istride;
00837                         }
00838                         botrun_count = *botRLElen++;
00839                         if (botrun_count == 0)
00840                             botrun_count = *botRLElen++;
00841                         else
00842                             run_state ^= 2;
00843                     }
00844                 }
00845 #endif /* INDEX_VOLUME */
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;  /* scanline is done */
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;  /* scanline is done */
00865                     }
00866 #endif /* UNROLL_RUN_LOOP */
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 /* SKIP_ERT */
00875 
00876             /***********************************************************
00877              * Compute the length of the current run.
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                 /* check if this is the start of a new run */
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                 /* find the union of the two runs of voxels */
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              * composite the voxels in the current run.
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                 topRLEdata += count * voxel_istride;
00924                 botRLEdata += count * voxel_istride;
00925                 count = 0;
00926                 break;
00927             case TOP_NONZERO:
00928                 ipixel += count;
00929                 topRLEdata += count * voxel_istride;
00930                 botRLEdata += count * voxel_istride;
00931                 count = 0;
00932                 break;
00933             case BOT_NONZERO:
00934                 ipixel += count;
00935                 topRLEdata += count * voxel_istride;
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 /* !SKIP_COMPOSITE */
00947 #ifdef UNROLL_RUN_LOOP
00948             /* this run contains pixels, so process them */
00949             switch ((last_run_state << 2) | run_state) {
00950             case ALL_ZERO__ALL_ZERO:
00951                 /* no voxels contribute to the pixels in this run */
00952                 ipixel += count;
00953                 topRLEdata += count * voxel_istride;
00954                 botRLEdata += count * voxel_istride;
00955                 count = 0;
00956                 break;
00957             case TOP_NONZERO__ALL_ZERO:
00958                 /* only the top-left voxel contributes to the first
00959                    pixel of the run, and the rest are zero */
00960                 if (!voxels_loaded) {
00961                     
00962     
00963             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
00964             opacity = param0_table[opac_param];
00965             if (param1_size != 0) {
00966                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
00967                 opacity *= param1_table[opac_param];
00968                 if (param2_size != 0) {
00969                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
00970                     opacity *= param2_table[opac_param];
00971                 }
00972             }
00973             if (opacity > min_opacity) {
00974                 opacity_int = opacity*255.;
00975                 top_opc = opac_correct[opacity_int];
00976             } else {
00977                 top_opc = (float)0.;
00978             };
00979     
00980     
00981     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
00982     ;
00983     
00984         
00985     top_clr = 
00986     shade_table[shade_index + 1*0 + 0] * (float)1.0;
00987         ;
00988     shade_factor = top_opc * slice_depth_cueing;
00989     
00990         top_clr *= shade_factor;
00991     ;
00992                 }
00993                 
00994 #ifdef DEBUG
00995     if (ipixel == trace_pixel_ptr) {
00996         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
00997         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
00998         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
00999         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01000         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01001     }
01002 #endif
01003 ;
01004                 
01005        acc_opc = top_opc * wgtTL;
01006        acc_clr = top_clr * wgtTL;
01007        
01008 #ifdef DEBUG
01009     if (ipixel == trace_pixel_ptr) {
01010         trace_opcTL = top_opc;
01011         trace_rclrTL = top_clr;
01012         
01013     }
01014 #endif
01015 ;
01016                 
01017         COUNT_RESAMPLE;
01018         if (acc_opc > min_opacity) {
01019             COUNT_COMPOSITE;
01020             iopc = ipixel->opcflt;
01021 #           ifndef SKIP_ERT
01022                 ASSERT(iopc < max_opacity);
01023 #           endif
01024             iopc_inv = (float)1. - iopc;
01025             ipixel->clrflt += acc_clr * iopc_inv;
01026             iopc += acc_opc * iopc_inv;
01027             ipixel->opcflt = iopc;
01028             
01029 #ifdef DEBUG
01030     if (ipixel == trace_pixel_ptr) {
01031 #ifdef COMPUTE_SHADOW_BUFFER
01032         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01033 #else
01034         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01035 #endif
01036         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01037         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01038         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01039         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01040         printf("  %3.0f %3.0f\n", iopc*255., 
01041                ipixel->clrflt);
01042         
01043         
01044     }
01045 #endif /* DEBUG */
01046 ;
01047 #           ifndef SKIP_ERT
01048                 if (iopc >= max_opacity) {
01049                     ASSERT(ipixel->lnk == 0);
01050                     ipixel->lnk = 1;
01051                 }
01052 #           endif
01053         };
01054                 ipixel += count;
01055                 topRLEdata += count * voxel_istride;
01056                 botRLEdata += count * voxel_istride;
01057                 count = 0;
01058                 break;
01059             case BOT_NONZERO__ALL_ZERO:
01060                 /* only the bottom left voxel contributes to the first
01061                    pixel of the run, and the rest are zero */
01062                 if (!voxels_loaded) {
01063                     
01064     
01065             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01066             opacity = param0_table[opac_param];
01067             if (param1_size != 0) {
01068                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01069                 opacity *= param1_table[opac_param];
01070                 if (param2_size != 0) {
01071                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01072                     opacity *= param2_table[opac_param];
01073                 }
01074             }
01075             if (opacity > min_opacity) {
01076                 opacity_int = opacity*255.;
01077                 bot_opc = opac_correct[opacity_int];
01078             } else {
01079                 bot_opc = (float)0.;
01080             };
01081     
01082     
01083     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01084     ;
01085     
01086         
01087     bot_clr = 
01088     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01089         ;
01090     shade_factor = bot_opc * slice_depth_cueing;
01091     
01092         bot_clr *= shade_factor;
01093     ;
01094                 }
01095                 
01096 #ifdef DEBUG
01097     if (ipixel == trace_pixel_ptr) {
01098         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01099         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01100         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01101         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01102         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01103     }
01104 #endif
01105 ;
01106                 
01107        acc_opc = bot_opc * wgtBL;
01108        acc_clr = bot_clr * wgtBL;
01109        
01110 #ifdef DEBUG
01111     if (ipixel == trace_pixel_ptr) {
01112         trace_opcBL = bot_opc;
01113         trace_rclrBL = bot_clr;
01114         
01115     }
01116 #endif
01117 ;
01118                 
01119         COUNT_RESAMPLE;
01120         if (acc_opc > min_opacity) {
01121             COUNT_COMPOSITE;
01122             iopc = ipixel->opcflt;
01123 #           ifndef SKIP_ERT
01124                 ASSERT(iopc < max_opacity);
01125 #           endif
01126             iopc_inv = (float)1. - iopc;
01127             ipixel->clrflt += acc_clr * iopc_inv;
01128             iopc += acc_opc * iopc_inv;
01129             ipixel->opcflt = iopc;
01130             
01131 #ifdef DEBUG
01132     if (ipixel == trace_pixel_ptr) {
01133 #ifdef COMPUTE_SHADOW_BUFFER
01134         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01135 #else
01136         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01137 #endif
01138         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01139         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01140         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01141         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01142         printf("  %3.0f %3.0f\n", iopc*255., 
01143                ipixel->clrflt);
01144         
01145         
01146     }
01147 #endif /* DEBUG */
01148 ;
01149 #           ifndef SKIP_ERT
01150                 if (iopc >= max_opacity) {
01151                     ASSERT(ipixel->lnk == 0);
01152                     ipixel->lnk = 1;
01153                 }
01154 #           endif
01155         };
01156                 ipixel += count;
01157                 topRLEdata += count * voxel_istride;
01158                 botRLEdata += count * voxel_istride;
01159                 count = 0;
01160                 break;
01161             case ALL_NONZERO__ALL_ZERO:
01162                 /* the top and bottom left voxels contribute to the
01163                    first pixel of the run, and the rest are zero */
01164                 if (!voxels_loaded) {
01165                     
01166     
01167             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01168             opacity = param0_table[opac_param];
01169             if (param1_size != 0) {
01170                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01171                 opacity *= param1_table[opac_param];
01172                 if (param2_size != 0) {
01173                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01174                     opacity *= param2_table[opac_param];
01175                 }
01176             }
01177             if (opacity > min_opacity) {
01178                 opacity_int = opacity*255.;
01179                 top_opc = opac_correct[opacity_int];
01180             } else {
01181                 top_opc = (float)0.;
01182             };
01183     
01184     
01185     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01186     ;
01187     
01188         
01189     top_clr = 
01190     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01191         ;
01192     shade_factor = top_opc * slice_depth_cueing;
01193     
01194         top_clr *= shade_factor;
01195     ;
01196                     
01197     
01198             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01199             opacity = param0_table[opac_param];
01200             if (param1_size != 0) {
01201                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01202                 opacity *= param1_table[opac_param];
01203                 if (param2_size != 0) {
01204                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01205                     opacity *= param2_table[opac_param];
01206                 }
01207             }
01208             if (opacity > min_opacity) {
01209                 opacity_int = opacity*255.;
01210                 bot_opc = opac_correct[opacity_int];
01211             } else {
01212                 bot_opc = (float)0.;
01213             };
01214     
01215     
01216     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01217     ;
01218     
01219         
01220     bot_clr = 
01221     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01222         ;
01223     shade_factor = bot_opc * slice_depth_cueing;
01224     
01225         bot_clr *= shade_factor;
01226     ;
01227                 }
01228                 
01229 #ifdef DEBUG
01230     if (ipixel == trace_pixel_ptr) {
01231         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01232         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01233         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01234         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01235         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01236     }
01237 #endif
01238 ;
01239                 
01240        acc_opc = top_opc * wgtTL;
01241        acc_clr = top_clr * wgtTL;
01242        
01243 #ifdef DEBUG
01244     if (ipixel == trace_pixel_ptr) {
01245         trace_opcTL = top_opc;
01246         trace_rclrTL = top_clr;
01247         
01248     }
01249 #endif
01250 ;
01251                 
01252        acc_opc += bot_opc * wgtBL;
01253        acc_clr += bot_clr * wgtBL;
01254        
01255 #ifdef DEBUG
01256     if (ipixel == trace_pixel_ptr) {
01257         trace_opcBL = bot_opc;
01258         trace_rclrBL = bot_clr;
01259         
01260     }
01261 #endif
01262 ;
01263                 
01264         COUNT_RESAMPLE;
01265         if (acc_opc > min_opacity) {
01266             COUNT_COMPOSITE;
01267             iopc = ipixel->opcflt;
01268 #           ifndef SKIP_ERT
01269                 ASSERT(iopc < max_opacity);
01270 #           endif
01271             iopc_inv = (float)1. - iopc;
01272             ipixel->clrflt += acc_clr * iopc_inv;
01273             iopc += acc_opc * iopc_inv;
01274             ipixel->opcflt = iopc;
01275             
01276 #ifdef DEBUG
01277     if (ipixel == trace_pixel_ptr) {
01278 #ifdef COMPUTE_SHADOW_BUFFER
01279         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01280 #else
01281         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01282 #endif
01283         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01284         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01285         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01286         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01287         printf("  %3.0f %3.0f\n", iopc*255., 
01288                ipixel->clrflt);
01289         
01290         
01291     }
01292 #endif /* DEBUG */
01293 ;
01294 #           ifndef SKIP_ERT
01295                 if (iopc >= max_opacity) {
01296                     ASSERT(ipixel->lnk == 0);
01297                     ipixel->lnk = 1;
01298                 }
01299 #           endif
01300         };
01301                 ipixel += count;
01302                 topRLEdata += count * voxel_istride;
01303                 botRLEdata += count * voxel_istride;
01304                 count = 0;
01305                 break;
01306             case ALL_ZERO__TOP_NONZERO:
01307                 /* first pixel: only the top-right voxel contributes */
01308                 
01309     
01310             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01311             opacity = param0_table[opac_param];
01312             if (param1_size != 0) {
01313                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01314                 opacity *= param1_table[opac_param];
01315                 if (param2_size != 0) {
01316                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01317                     opacity *= param2_table[opac_param];
01318                 }
01319             }
01320             if (opacity > min_opacity) {
01321                 opacity_int = opacity*255.;
01322                 top_opc = opac_correct[opacity_int];
01323             } else {
01324                 top_opc = (float)0.;
01325             };
01326     
01327     
01328     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01329     ;
01330     
01331         
01332     top_clr = 
01333     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01334         ;
01335     shade_factor = top_opc * slice_depth_cueing;
01336     
01337         top_clr *= shade_factor;
01338     ;
01339                 
01340 #ifdef DEBUG
01341     if (ipixel == trace_pixel_ptr) {
01342         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01343         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01344         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01345         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01346         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01347     }
01348 #endif
01349 ;
01350                 
01351        acc_opc = top_opc * wgtTR;
01352        acc_clr = top_clr * wgtTR;
01353        
01354 #ifdef DEBUG
01355     if (ipixel == trace_pixel_ptr) {
01356         trace_opcTR = top_opc;
01357         trace_rclrTR = top_clr;
01358         
01359     }
01360 #endif
01361 ;
01362                 
01363         COUNT_RESAMPLE;
01364         if (acc_opc > min_opacity) {
01365             COUNT_COMPOSITE;
01366             iopc = ipixel->opcflt;
01367 #           ifndef SKIP_ERT
01368                 ASSERT(iopc < max_opacity);
01369 #           endif
01370             iopc_inv = (float)1. - iopc;
01371             ipixel->clrflt += acc_clr * iopc_inv;
01372             iopc += acc_opc * iopc_inv;
01373             ipixel->opcflt = iopc;
01374             
01375 #ifdef DEBUG
01376     if (ipixel == trace_pixel_ptr) {
01377 #ifdef COMPUTE_SHADOW_BUFFER
01378         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01379 #else
01380         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01381 #endif
01382         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01383         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01384         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01385         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01386         printf("  %3.0f %3.0f\n", iopc*255., 
01387                ipixel->clrflt);
01388         
01389         
01390     }
01391 #endif /* DEBUG */
01392 ;
01393 #           ifndef SKIP_ERT
01394                 if (iopc >= max_opacity) {
01395                     ASSERT(ipixel->lnk == 0);
01396                     ipixel->lnk = 1;
01397                 }
01398 #           endif
01399         };
01400                 ipixel += 1;
01401                 topRLEdata += 1 * voxel_istride;
01402                 botRLEdata += 1 * voxel_istride;
01403                 count--;
01404                 SET_VOXELS_LOADED;
01405 
01406                 /* do the rest of the pixels in this run;
01407                    the top-left and top-right voxels contribute */
01408                 while (count > 0) {
01409                     if (PIXEL_IS_OPAQUE(ipixel))
01410                         break;
01411                     if (!voxels_loaded) {
01412                         
01413     
01414             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01415             opacity = param0_table[opac_param];
01416             if (param1_size != 0) {
01417                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01418                 opacity *= param1_table[opac_param];
01419                 if (param2_size != 0) {
01420                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01421                     opacity *= param2_table[opac_param];
01422                 }
01423             }
01424             if (opacity > min_opacity) {
01425                 opacity_int = opacity*255.;
01426                 top_opc = opac_correct[opacity_int];
01427             } else {
01428                 top_opc = (float)0.;
01429             };
01430     
01431     
01432     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01433     ;
01434     
01435         
01436     top_clr = 
01437     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01438         ;
01439     shade_factor = top_opc * slice_depth_cueing;
01440     
01441         top_clr *= shade_factor;
01442     ;
01443                     }
01444                     
01445 #ifdef DEBUG
01446     if (ipixel == trace_pixel_ptr) {
01447         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01448         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01449         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01450         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01451         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01452     }
01453 #endif
01454 ;
01455                     
01456        acc_opc = top_opc * wgtTL;
01457        acc_clr = top_clr * wgtTL;
01458        
01459 #ifdef DEBUG
01460     if (ipixel == trace_pixel_ptr) {
01461         trace_opcTL = top_opc;
01462         trace_rclrTL = top_clr;
01463         
01464     }
01465 #endif
01466 ;
01467                     
01468     
01469             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01470             opacity = param0_table[opac_param];
01471             if (param1_size != 0) {
01472                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01473                 opacity *= param1_table[opac_param];
01474                 if (param2_size != 0) {
01475                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01476                     opacity *= param2_table[opac_param];
01477                 }
01478             }
01479             if (opacity > min_opacity) {
01480                 opacity_int = opacity*255.;
01481                 top_opc = opac_correct[opacity_int];
01482             } else {
01483                 top_opc = (float)0.;
01484             };
01485     
01486     
01487     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01488     ;
01489     
01490         
01491     top_clr = 
01492     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01493         ;
01494     shade_factor = top_opc * slice_depth_cueing;
01495     
01496         top_clr *= shade_factor;
01497     ;
01498                     
01499        acc_opc += top_opc * wgtTR;
01500        acc_clr += top_clr * wgtTR;
01501        
01502 #ifdef DEBUG
01503     if (ipixel == trace_pixel_ptr) {
01504         trace_opcTR = top_opc;
01505         trace_rclrTR = top_clr;
01506         
01507     }
01508 #endif
01509 ;
01510                     
01511         COUNT_RESAMPLE;
01512         if (acc_opc > min_opacity) {
01513             COUNT_COMPOSITE;
01514             iopc = ipixel->opcflt;
01515 #           ifndef SKIP_ERT
01516                 ASSERT(iopc < max_opacity);
01517 #           endif
01518             iopc_inv = (float)1. - iopc;
01519             ipixel->clrflt += acc_clr * iopc_inv;
01520             iopc += acc_opc * iopc_inv;
01521             ipixel->opcflt = iopc;
01522             
01523 #ifdef DEBUG
01524     if (ipixel == trace_pixel_ptr) {
01525 #ifdef COMPUTE_SHADOW_BUFFER
01526         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01527 #else
01528         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01529 #endif
01530         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01531         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01532         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01533         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01534         printf("  %3.0f %3.0f\n", iopc*255., 
01535                ipixel->clrflt);
01536         
01537         
01538     }
01539 #endif /* DEBUG */
01540 ;
01541 #           ifndef SKIP_ERT
01542                 if (iopc >= max_opacity) {
01543                     ASSERT(ipixel->lnk == 0);
01544                     ipixel->lnk = 1;
01545                 }
01546 #           endif
01547         };
01548                     ipixel += 1;
01549                     topRLEdata += 1 * voxel_istride;
01550                     botRLEdata += 1 * voxel_istride;
01551                     count--;
01552                     SET_VOXELS_LOADED;
01553                 }
01554                 break;
01555             case TOP_NONZERO__TOP_NONZERO:
01556                 /* do the pixels in this run; the top-left and
01557                    top-right voxels contribute */
01558                 while (count > 0) {
01559                     if (PIXEL_IS_OPAQUE(ipixel))
01560                         break;
01561                     if (!voxels_loaded) {
01562                         
01563     
01564             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01565             opacity = param0_table[opac_param];
01566             if (param1_size != 0) {
01567                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01568                 opacity *= param1_table[opac_param];
01569                 if (param2_size != 0) {
01570                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01571                     opacity *= param2_table[opac_param];
01572                 }
01573             }
01574             if (opacity > min_opacity) {
01575                 opacity_int = opacity*255.;
01576                 top_opc = opac_correct[opacity_int];
01577             } else {
01578                 top_opc = (float)0.;
01579             };
01580     
01581     
01582     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01583     ;
01584     
01585         
01586     top_clr = 
01587     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01588         ;
01589     shade_factor = top_opc * slice_depth_cueing;
01590     
01591         top_clr *= shade_factor;
01592     ;
01593                     }
01594                     
01595 #ifdef DEBUG
01596     if (ipixel == trace_pixel_ptr) {
01597         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01598         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01599         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01600         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01601         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01602     }
01603 #endif
01604 ;
01605                     
01606        acc_opc = top_opc * wgtTL;
01607        acc_clr = top_clr * wgtTL;
01608        
01609 #ifdef DEBUG
01610     if (ipixel == trace_pixel_ptr) {
01611         trace_opcTL = top_opc;
01612         trace_rclrTL = top_clr;
01613         
01614     }
01615 #endif
01616 ;
01617                     
01618     
01619             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01620             opacity = param0_table[opac_param];
01621             if (param1_size != 0) {
01622                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01623                 opacity *= param1_table[opac_param];
01624                 if (param2_size != 0) {
01625                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01626                     opacity *= param2_table[opac_param];
01627                 }
01628             }
01629             if (opacity > min_opacity) {
01630                 opacity_int = opacity*255.;
01631                 top_opc = opac_correct[opacity_int];
01632             } else {
01633                 top_opc = (float)0.;
01634             };
01635     
01636     
01637     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01638     ;
01639     
01640         
01641     top_clr = 
01642     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01643         ;
01644     shade_factor = top_opc * slice_depth_cueing;
01645     
01646         top_clr *= shade_factor;
01647     ;
01648                     
01649        acc_opc += top_opc * wgtTR;
01650        acc_clr += top_clr * wgtTR;
01651        
01652 #ifdef DEBUG
01653     if (ipixel == trace_pixel_ptr) {
01654         trace_opcTR = top_opc;
01655         trace_rclrTR = top_clr;
01656         
01657     }
01658 #endif
01659 ;
01660                     
01661         COUNT_RESAMPLE;
01662         if (acc_opc > min_opacity) {
01663             COUNT_COMPOSITE;
01664             iopc = ipixel->opcflt;
01665 #           ifndef SKIP_ERT
01666                 ASSERT(iopc < max_opacity);
01667 #           endif
01668             iopc_inv = (float)1. - iopc;
01669             ipixel->clrflt += acc_clr * iopc_inv;
01670             iopc += acc_opc * iopc_inv;
01671             ipixel->opcflt = iopc;
01672             
01673 #ifdef DEBUG
01674     if (ipixel == trace_pixel_ptr) {
01675 #ifdef COMPUTE_SHADOW_BUFFER
01676         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01677 #else
01678         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01679 #endif
01680         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01681         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01682         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01683         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01684         printf("  %3.0f %3.0f\n", iopc*255., 
01685                ipixel->clrflt);
01686         
01687         
01688     }
01689 #endif /* DEBUG */
01690 ;
01691 #           ifndef SKIP_ERT
01692                 if (iopc >= max_opacity) {
01693                     ASSERT(ipixel->lnk == 0);
01694                     ipixel->lnk = 1;
01695                 }
01696 #           endif
01697         };
01698                     ipixel += 1;
01699                     topRLEdata += 1 * voxel_istride;
01700                     botRLEdata += 1 * voxel_istride;
01701                     count--;
01702                     SET_VOXELS_LOADED;
01703                 }
01704                 break;
01705             case BOT_NONZERO__TOP_NONZERO:
01706                 /* first pixel: bottom-left and top-right voxels
01707                    contribute */
01708                 if (!voxels_loaded) {
01709                     
01710     
01711             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01712             opacity = param0_table[opac_param];
01713             if (param1_size != 0) {
01714                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01715                 opacity *= param1_table[opac_param];
01716                 if (param2_size != 0) {
01717                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01718                     opacity *= param2_table[opac_param];
01719                 }
01720             }
01721             if (opacity > min_opacity) {
01722                 opacity_int = opacity*255.;
01723                 bot_opc = opac_correct[opacity_int];
01724             } else {
01725                 bot_opc = (float)0.;
01726             };
01727     
01728     
01729     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01730     ;
01731     
01732         
01733     bot_clr = 
01734     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01735         ;
01736     shade_factor = bot_opc * slice_depth_cueing;
01737     
01738         bot_clr *= shade_factor;
01739     ;
01740                 }
01741                 
01742 #ifdef DEBUG
01743     if (ipixel == trace_pixel_ptr) {
01744         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01745         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01746         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01747         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01748         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01749     }
01750 #endif
01751 ;
01752                 
01753        acc_opc = bot_opc * wgtBL;
01754        acc_clr = bot_clr * wgtBL;
01755        
01756 #ifdef DEBUG
01757     if (ipixel == trace_pixel_ptr) {
01758         trace_opcBL = bot_opc;
01759         trace_rclrBL = bot_clr;
01760         
01761     }
01762 #endif
01763 ;
01764                 
01765     
01766             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01767             opacity = param0_table[opac_param];
01768             if (param1_size != 0) {
01769                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01770                 opacity *= param1_table[opac_param];
01771                 if (param2_size != 0) {
01772                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01773                     opacity *= param2_table[opac_param];
01774                 }
01775             }
01776             if (opacity > min_opacity) {
01777                 opacity_int = opacity*255.;
01778                 top_opc = opac_correct[opacity_int];
01779             } else {
01780                 top_opc = (float)0.;
01781             };
01782     
01783     
01784     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01785     ;
01786     
01787         
01788     top_clr = 
01789     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01790         ;
01791     shade_factor = top_opc * slice_depth_cueing;
01792     
01793         top_clr *= shade_factor;
01794     ;
01795                 
01796        acc_opc += top_opc * wgtTR;
01797        acc_clr += top_clr * wgtTR;
01798        
01799 #ifdef DEBUG
01800     if (ipixel == trace_pixel_ptr) {
01801         trace_opcTR = top_opc;
01802         trace_rclrTR = top_clr;
01803         
01804     }
01805 #endif
01806 ;
01807                 
01808         COUNT_RESAMPLE;
01809         if (acc_opc > min_opacity) {
01810             COUNT_COMPOSITE;
01811             iopc = ipixel->opcflt;
01812 #           ifndef SKIP_ERT
01813                 ASSERT(iopc < max_opacity);
01814 #           endif
01815             iopc_inv = (float)1. - iopc;
01816             ipixel->clrflt += acc_clr * iopc_inv;
01817             iopc += acc_opc * iopc_inv;
01818             ipixel->opcflt = iopc;
01819             
01820 #ifdef DEBUG
01821     if (ipixel == trace_pixel_ptr) {
01822 #ifdef COMPUTE_SHADOW_BUFFER
01823         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01824 #else
01825         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01826 #endif
01827         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01828         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01829         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01830         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01831         printf("  %3.0f %3.0f\n", iopc*255., 
01832                ipixel->clrflt);
01833         
01834         
01835     }
01836 #endif /* DEBUG */
01837 ;
01838 #           ifndef SKIP_ERT
01839                 if (iopc >= max_opacity) {
01840                     ASSERT(ipixel->lnk == 0);
01841                     ipixel->lnk = 1;
01842                 }
01843 #           endif
01844         };
01845                 ipixel += 1;
01846                 topRLEdata += 1 * voxel_istride;
01847                 botRLEdata += 1 * voxel_istride;
01848                 count--;
01849                 SET_VOXELS_LOADED;
01850 
01851                 /* do the rest of the pixels in this run;
01852                    the top-left and top-right voxels contribute */
01853                 while (count > 0) {
01854                     if (PIXEL_IS_OPAQUE(ipixel))
01855                         break;
01856                     if (!voxels_loaded) {
01857                         
01858     
01859             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01860             opacity = param0_table[opac_param];
01861             if (param1_size != 0) {
01862                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01863                 opacity *= param1_table[opac_param];
01864                 if (param2_size != 0) {
01865                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01866                     opacity *= param2_table[opac_param];
01867                 }
01868             }
01869             if (opacity > min_opacity) {
01870                 opacity_int = opacity*255.;
01871                 top_opc = opac_correct[opacity_int];
01872             } else {
01873                 top_opc = (float)0.;
01874             };
01875     
01876     
01877     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01878     ;
01879     
01880         
01881     top_clr = 
01882     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01883         ;
01884     shade_factor = top_opc * slice_depth_cueing;
01885     
01886         top_clr *= shade_factor;
01887     ;
01888                     }
01889                     
01890 #ifdef DEBUG
01891     if (ipixel == trace_pixel_ptr) {
01892         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01893         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01894         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01895         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01896         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01897     }
01898 #endif
01899 ;
01900                     
01901        acc_opc = top_opc * wgtTL;
01902        acc_clr = top_clr * wgtTL;
01903        
01904 #ifdef DEBUG
01905     if (ipixel == trace_pixel_ptr) {
01906         trace_opcTL = top_opc;
01907         trace_rclrTL = top_clr;
01908         
01909     }
01910 #endif
01911 ;
01912                     
01913     
01914             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01915             opacity = param0_table[opac_param];
01916             if (param1_size != 0) {
01917                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01918                 opacity *= param1_table[opac_param];
01919                 if (param2_size != 0) {
01920                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01921                     opacity *= param2_table[opac_param];
01922                 }
01923             }
01924             if (opacity > min_opacity) {
01925                 opacity_int = opacity*255.;
01926                 top_opc = opac_correct[opacity_int];
01927             } else {
01928                 top_opc = (float)0.;
01929             };
01930     
01931     
01932     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01933     ;
01934     
01935         
01936     top_clr = 
01937     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01938         ;
01939     shade_factor = top_opc * slice_depth_cueing;
01940     
01941         top_clr *= shade_factor;
01942     ;
01943                     
01944        acc_opc += top_opc * wgtTR;
01945        acc_clr += top_clr * wgtTR;
01946        
01947 #ifdef DEBUG
01948     if (ipixel == trace_pixel_ptr) {
01949         trace_opcTR = top_opc;
01950         trace_rclrTR = top_clr;
01951         
01952     }
01953 #endif
01954 ;
01955                     
01956         COUNT_RESAMPLE;
01957         if (acc_opc > min_opacity) {
01958             COUNT_COMPOSITE;
01959             iopc = ipixel->opcflt;
01960 #           ifndef SKIP_ERT
01961                 ASSERT(iopc < max_opacity);
01962 #           endif
01963             iopc_inv = (float)1. - iopc;
01964             ipixel->clrflt += acc_clr * iopc_inv;
01965             iopc += acc_opc * iopc_inv;
01966             ipixel->opcflt = iopc;
01967             
01968 #ifdef DEBUG
01969     if (ipixel == trace_pixel_ptr) {
01970 #ifdef COMPUTE_SHADOW_BUFFER
01971         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01972 #else
01973         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01974 #endif
01975         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01976         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01977         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01978         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01979         printf("  %3.0f %3.0f\n", iopc*255., 
01980                ipixel->clrflt);
01981         
01982         
01983     }
01984 #endif /* DEBUG */
01985 ;
01986 #           ifndef SKIP_ERT
01987                 if (iopc >= max_opacity) {
01988                     ASSERT(ipixel->lnk == 0);
01989                     ipixel->lnk = 1;
01990                 }
01991 #           endif
01992         };
01993                     ipixel += 1;
01994                     topRLEdata += 1 * voxel_istride;
01995                     botRLEdata += 1 * voxel_istride;
01996                     count--;
01997                     SET_VOXELS_LOADED;
01998                 }
01999                 break;
02000             case ALL_NONZERO__TOP_NONZERO:
02001                 /* first pixel: top-left, bottom-left and top-right voxels
02002                    contribute */
02003                 if (!voxels_loaded) {
02004                     
02005     
02006             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02007             opacity = param0_table[opac_param];
02008             if (param1_size != 0) {
02009                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02010                 opacity *= param1_table[opac_param];
02011                 if (param2_size != 0) {
02012                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02013                     opacity *= param2_table[opac_param];
02014                 }
02015             }
02016             if (opacity > min_opacity) {
02017                 opacity_int = opacity*255.;
02018                 top_opc = opac_correct[opacity_int];
02019             } else {
02020                 top_opc = (float)0.;
02021             };
02022     
02023     
02024     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02025     ;
02026     
02027         
02028     top_clr = 
02029     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02030         ;
02031     shade_factor = top_opc * slice_depth_cueing;
02032     
02033         top_clr *= shade_factor;
02034     ;
02035                     
02036     
02037             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02038             opacity = param0_table[opac_param];
02039             if (param1_size != 0) {
02040                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02041                 opacity *= param1_table[opac_param];
02042                 if (param2_size != 0) {
02043                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02044                     opacity *= param2_table[opac_param];
02045                 }
02046             }
02047             if (opacity > min_opacity) {
02048                 opacity_int = opacity*255.;
02049                 bot_opc = opac_correct[opacity_int];
02050             } else {
02051                 bot_opc = (float)0.;
02052             };
02053     
02054     
02055     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02056     ;
02057     
02058         
02059     bot_clr = 
02060     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02061         ;
02062     shade_factor = bot_opc * slice_depth_cueing;
02063     
02064         bot_clr *= shade_factor;
02065     ;
02066                 }
02067                 
02068 #ifdef DEBUG
02069     if (ipixel == trace_pixel_ptr) {
02070         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02071         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02072         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02073         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02074         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02075     }
02076 #endif
02077 ;
02078                 
02079        acc_opc = top_opc * wgtTL;
02080        acc_clr = top_clr * wgtTL;
02081        
02082 #ifdef DEBUG
02083     if (ipixel == trace_pixel_ptr) {
02084         trace_opcTL = top_opc;
02085         trace_rclrTL = top_clr;
02086         
02087     }
02088 #endif
02089 ;
02090                 
02091        acc_opc += bot_opc * wgtBL;
02092        acc_clr += bot_clr * wgtBL;
02093        
02094 #ifdef DEBUG
02095     if (ipixel == trace_pixel_ptr) {
02096         trace_opcBL = bot_opc;
02097         trace_rclrBL = bot_clr;
02098         
02099     }
02100 #endif
02101 ;
02102                 
02103     
02104             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02105             opacity = param0_table[opac_param];
02106             if (param1_size != 0) {
02107                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02108                 opacity *= param1_table[opac_param];
02109                 if (param2_size != 0) {
02110                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02111                     opacity *= param2_table[opac_param];
02112                 }
02113             }
02114             if (opacity > min_opacity) {
02115                 opacity_int = opacity*255.;
02116                 top_opc = opac_correct[opacity_int];
02117             } else {
02118                 top_opc = (float)0.;
02119             };
02120     
02121     
02122     shade_index=1*1*ShortField(topRLEdata,norm_offset);
02123     ;
02124     
02125         
02126     top_clr = 
02127     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02128         ;
02129     shade_factor = top_opc * slice_depth_cueing;
02130     
02131         top_clr *= shade_factor;
02132     ;
02133                 
02134        acc_opc += top_opc * wgtTR;
02135        acc_clr += top_clr * wgtTR;
02136        
02137 #ifdef DEBUG
02138     if (ipixel == trace_pixel_ptr) {
02139         trace_opcTR = top_opc;
02140         trace_rclrTR = top_clr;
02141         
02142     }
02143 #endif
02144 ;
02145                 
02146         COUNT_RESAMPLE;
02147         if (acc_opc > min_opacity) {
02148             COUNT_COMPOSITE;
02149             iopc = ipixel->opcflt;
02150 #           ifndef SKIP_ERT
02151                 ASSERT(iopc < max_opacity);
02152 #           endif
02153             iopc_inv = (float)1. - iopc;
02154             ipixel->clrflt += acc_clr * iopc_inv;
02155             iopc += acc_opc * iopc_inv;
02156             ipixel->opcflt = iopc;
02157             
02158 #ifdef DEBUG
02159     if (ipixel == trace_pixel_ptr) {
02160 #ifdef COMPUTE_SHADOW_BUFFER
02161         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02162 #else
02163         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02164 #endif
02165         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02166         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02167         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02168         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02169         printf("  %3.0f %3.0f\n", iopc*255., 
02170                ipixel->clrflt);
02171         
02172         
02173     }
02174 #endif /* DEBUG */
02175 ;
02176 #           ifndef SKIP_ERT
02177                 if (iopc >= max_opacity) {
02178                     ASSERT(ipixel->lnk == 0);
02179                     ipixel->lnk = 1;
02180                 }
02181 #           endif
02182         };
02183                 ipixel += 1;
02184                 topRLEdata += 1 * voxel_istride;
02185                 botRLEdata += 1 * voxel_istride;
02186                 count--;
02187                 SET_VOXELS_LOADED;
02188 
02189                 /* do the rest of the pixels in this run;
02190                    the top-left and top-right voxels contribute */
02191                 while (count > 0) {
02192                     if (PIXEL_IS_OPAQUE(ipixel))
02193                         break;
02194                     if (!voxels_loaded) {
02195                         
02196     
02197             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02198             opacity = param0_table[opac_param];
02199             if (param1_size != 0) {
02200                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02201                 opacity *= param1_table[opac_param];
02202                 if (param2_size != 0) {
02203                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02204                     opacity *= param2_table[opac_param];
02205                 }
02206             }
02207             if (opacity > min_opacity) {
02208                 opacity_int = opacity*255.;
02209                 top_opc = opac_correct[opacity_int];
02210             } else {
02211                 top_opc = (float)0.;
02212             };
02213     
02214     
02215     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02216     ;
02217     
02218         
02219     top_clr = 
02220     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02221         ;
02222     shade_factor = top_opc * slice_depth_cueing;
02223     
02224         top_clr *= shade_factor;
02225     ;
02226                     }
02227                     
02228 #ifdef DEBUG
02229     if (ipixel == trace_pixel_ptr) {
02230         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02231         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02232         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02233         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02234         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02235     }
02236 #endif
02237 ;
02238                     
02239        acc_opc = top_opc * wgtTL;
02240        acc_clr = top_clr * wgtTL;
02241        
02242 #ifdef DEBUG
02243     if (ipixel == trace_pixel_ptr) {
02244         trace_opcTL = top_opc;
02245         trace_rclrTL = top_clr;
02246         
02247     }
02248 #endif
02249 ;
02250                     
02251     
02252             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02253             opacity = param0_table[opac_param];
02254             if (param1_size != 0) {
02255                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02256                 opacity *= param1_table[opac_param];
02257                 if (param2_size != 0) {
02258                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02259                     opacity *= param2_table[opac_param];
02260                 }
02261             }
02262             if (opacity > min_opacity) {
02263                 opacity_int = opacity*255.;
02264                 top_opc = opac_correct[opacity_int];
02265             } else {
02266                 top_opc = (float)0.;
02267             };
02268     
02269     
02270     shade_index=1*1*ShortField(topRLEdata,norm_offset);
02271     ;
02272     
02273         
02274     top_clr = 
02275     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02276         ;
02277     shade_factor = top_opc * slice_depth_cueing;
02278     
02279         top_clr *= shade_factor;
02280     ;
02281                     
02282        acc_opc += top_opc * wgtTR;
02283        acc_clr += top_clr * wgtTR;
02284        
02285 #ifdef DEBUG
02286     if (ipixel == trace_pixel_ptr) {
02287         trace_opcTR = top_opc;
02288         trace_rclrTR = top_clr;
02289         
02290     }
02291 #endif
02292 ;
02293                     
02294         COUNT_RESAMPLE;
02295         if (acc_opc > min_opacity) {
02296             COUNT_COMPOSITE;
02297             iopc = ipixel->opcflt;
02298 #           ifndef SKIP_ERT
02299                 ASSERT(iopc < max_opacity);
02300 #           endif
02301             iopc_inv = (float)1. - iopc;
02302             ipixel->clrflt += acc_clr * iopc_inv;
02303             iopc += acc_opc * iopc_inv;
02304             ipixel->opcflt = iopc;
02305             
02306 #ifdef DEBUG
02307     if (ipixel == trace_pixel_ptr) {
02308 #ifdef COMPUTE_SHADOW_BUFFER
02309         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02310 #else
02311         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02312 #endif
02313         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02314         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02315         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02316         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02317         printf("  %3.0f %3.0f\n", iopc*255., 
02318                ipixel->clrflt);
02319         
02320         
02321     }
02322 #endif /* DEBUG */
02323 ;
02324 #           ifndef SKIP_ERT
02325                 if (iopc >= max_opacity) {
02326                     ASSERT(ipixel->lnk == 0);
02327                     ipixel->lnk = 1;
02328                 }
02329 #           endif
02330         };
02331                     ipixel += 1;
02332                     topRLEdata += 1 * voxel_istride;
02333                     botRLEdata += 1 * voxel_istride;
02334                     count--;
02335                     SET_VOXELS_LOADED;
02336                 }
02337                 break;
02338             case ALL_ZERO__BOT_NONZERO:
02339                 /* first pixel: only the bottom-right voxel contributes */
02340                 
02341     
02342             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02343             opacity = param0_table[opac_param];
02344             if (param1_size != 0) {
02345                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02346                 opacity *= param1_table[opac_param];
02347                 if (param2_size != 0) {
02348                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02349                     opacity *= param2_table[opac_param];
02350                 }
02351             }
02352             if (opacity > min_opacity) {
02353                 opacity_int = opacity*255.;
02354                 bot_opc = opac_correct[opacity_int];
02355             } else {
02356                 bot_opc = (float)0.;
02357             };
02358     
02359     
02360     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02361     ;
02362     
02363         
02364     bot_clr = 
02365     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02366         ;
02367     shade_factor = bot_opc * slice_depth_cueing;
02368     
02369         bot_clr *= shade_factor;
02370     ;
02371                 
02372 #ifdef DEBUG
02373     if (ipixel == trace_pixel_ptr) {
02374         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02375         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02376         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02377         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02378         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02379     }
02380 #endif
02381 ;
02382                 
02383        acc_opc = bot_opc * wgtBR;
02384        acc_clr = bot_clr * wgtBR;
02385        
02386 #ifdef DEBUG
02387     if (ipixel == trace_pixel_ptr) {
02388         trace_opcBR = bot_opc;
02389         trace_rclrBR = bot_clr;
02390         
02391     }
02392 #endif
02393 ;
02394                 
02395         COUNT_RESAMPLE;
02396         if (acc_opc > min_opacity) {
02397             COUNT_COMPOSITE;
02398             iopc = ipixel->opcflt;
02399 #           ifndef SKIP_ERT
02400                 ASSERT(iopc < max_opacity);
02401 #           endif
02402             iopc_inv = (float)1. - iopc;
02403             ipixel->clrflt += acc_clr * iopc_inv;
02404             iopc += acc_opc * iopc_inv;
02405             ipixel->opcflt = iopc;
02406             
02407 #ifdef DEBUG
02408     if (ipixel == trace_pixel_ptr) {
02409 #ifdef COMPUTE_SHADOW_BUFFER
02410         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02411 #else
02412         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02413 #endif
02414         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02415         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02416         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02417         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02418         printf("  %3.0f %3.0f\n", iopc*255., 
02419                ipixel->clrflt);
02420         
02421         
02422     }
02423 #endif /* DEBUG */
02424 ;
02425 #           ifndef SKIP_ERT
02426                 if (iopc >= max_opacity) {
02427                     ASSERT(ipixel->lnk == 0);
02428                     ipixel->lnk = 1;
02429                 }
02430 #           endif
02431         };      
02432                 ipixel += 1;
02433                 topRLEdata += 1 * voxel_istride;
02434                 botRLEdata += 1 * voxel_istride;
02435                 count--;
02436                 SET_VOXELS_LOADED;
02437 
02438                 /* do the rest of the pixels in this run;
02439                    bottom-left and bottom-right voxels contribute */
02440                 while (count > 0) {
02441                     if (PIXEL_IS_OPAQUE(ipixel))
02442                         break;
02443                     if (!voxels_loaded) {
02444                         
02445     
02446             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02447             opacity = param0_table[opac_param];
02448             if (param1_size != 0) {
02449                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02450                 opacity *= param1_table[opac_param];
02451                 if (param2_size != 0) {
02452                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02453                     opacity *= param2_table[opac_param];
02454                 }
02455             }
02456             if (opacity > min_opacity) {
02457                 opacity_int = opacity*255.;
02458                 bot_opc = opac_correct[opacity_int];
02459             } else {
02460                 bot_opc = (float)0.;
02461             };
02462     
02463     
02464     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02465     ;
02466     
02467         
02468     bot_clr = 
02469     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02470         ;
02471     shade_factor = bot_opc * slice_depth_cueing;
02472     
02473         bot_clr *= shade_factor;
02474     ;
02475                     }
02476                     
02477 #ifdef DEBUG
02478     if (ipixel == trace_pixel_ptr) {
02479         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02480         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02481         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02482         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02483         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02484     }
02485 #endif
02486 ;
02487                     
02488        acc_opc = bot_opc * wgtBL;
02489        acc_clr = bot_clr * wgtBL;
02490        
02491 #ifdef DEBUG
02492     if (ipixel == trace_pixel_ptr) {
02493         trace_opcBL = bot_opc;
02494         trace_rclrBL = bot_clr;
02495         
02496     }
02497 #endif
02498 ;
02499                     
02500     
02501             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02502             opacity = param0_table[opac_param];
02503             if (param1_size != 0) {
02504                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02505                 opacity *= param1_table[opac_param];
02506                 if (param2_size != 0) {
02507                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02508                     opacity *= param2_table[opac_param];
02509                 }
02510             }
02511             if (opacity > min_opacity) {
02512                 opacity_int = opacity*255.;
02513                 bot_opc = opac_correct[opacity_int];
02514             } else {
02515                 bot_opc = (float)0.;
02516             };
02517     
02518     
02519     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02520     ;
02521     
02522         
02523     bot_clr = 
02524     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02525         ;
02526     shade_factor = bot_opc * slice_depth_cueing;
02527     
02528         bot_clr *= shade_factor;
02529     ;
02530                     
02531        acc_opc += bot_opc * wgtBR;
02532        acc_clr += bot_clr * wgtBR;
02533        
02534 #ifdef DEBUG
02535     if (ipixel == trace_pixel_ptr) {
02536         trace_opcBR = bot_opc;
02537         trace_rclrBR = bot_clr;
02538         
02539     }
02540 #endif
02541 ;
02542                     
02543         COUNT_RESAMPLE;
02544         if (acc_opc > min_opacity) {
02545             COUNT_COMPOSITE;
02546             iopc = ipixel->opcflt;
02547 #           ifndef SKIP_ERT
02548                 ASSERT(iopc < max_opacity);
02549 #           endif
02550             iopc_inv = (float)1. - iopc;
02551             ipixel->clrflt += acc_clr * iopc_inv;
02552             iopc += acc_opc * iopc_inv;
02553             ipixel->opcflt = iopc;
02554             
02555 #ifdef DEBUG
02556     if (ipixel == trace_pixel_ptr) {
02557 #ifdef COMPUTE_SHADOW_BUFFER
02558         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02559 #else
02560         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02561 #endif
02562         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02563         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02564         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02565         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02566         printf("  %3.0f %3.0f\n", iopc*255., 
02567                ipixel->clrflt);
02568         
02569         
02570     }
02571 #endif /* DEBUG */
02572 ;
02573 #           ifndef SKIP_ERT
02574                 if (iopc >= max_opacity) {
02575                     ASSERT(ipixel->lnk == 0);
02576                     ipixel->lnk = 1;
02577                 }
02578 #           endif
02579         };
02580                     ipixel += 1;
02581                     topRLEdata += 1 * voxel_istride;
02582                     botRLEdata += 1 * voxel_istride;
02583                     count--;
02584                     SET_VOXELS_LOADED;
02585                 }
02586                 break;
02587             case TOP_NONZERO__BOT_NONZERO:
02588                 /* first pixel: top-left and bottom-right voxels contribute */
02589                 if (!voxels_loaded) {
02590                     
02591     
02592             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02593             opacity = param0_table[opac_param];
02594             if (param1_size != 0) {
02595                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02596                 opacity *= param1_table[opac_param];
02597                 if (param2_size != 0) {
02598                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02599                     opacity *= param2_table[opac_param];
02600                 }
02601             }
02602             if (opacity > min_opacity) {
02603                 opacity_int = opacity*255.;
02604                 top_opc = opac_correct[opacity_int];
02605             } else {
02606                 top_opc = (float)0.;
02607             };
02608     
02609     
02610     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02611     ;
02612     
02613         
02614     top_clr = 
02615     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02616         ;
02617     shade_factor = top_opc * slice_depth_cueing;
02618     
02619         top_clr *= shade_factor;
02620     ;
02621                 }
02622                 
02623 #ifdef DEBUG
02624     if (ipixel == trace_pixel_ptr) {
02625         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02626         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02627         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02628         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02629         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02630     }
02631 #endif
02632 ;
02633                 
02634        acc_opc = top_opc * wgtTL;
02635        acc_clr = top_clr * wgtTL;
02636        
02637 #ifdef DEBUG
02638     if (ipixel == trace_pixel_ptr) {
02639         trace_opcTL = top_opc;
02640         trace_rclrTL = top_clr;
02641         
02642     }
02643 #endif
02644 ;
02645                 
02646     
02647             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02648             opacity = param0_table[opac_param];
02649             if (param1_size != 0) {
02650                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02651                 opacity *= param1_table[opac_param];
02652                 if (param2_size != 0) {
02653                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02654                     opacity *= param2_table[opac_param];
02655                 }
02656             }
02657             if (opacity > min_opacity) {
02658                 opacity_int = opacity*255.;
02659                 bot_opc = opac_correct[opacity_int];
02660             } else {
02661                 bot_opc = (float)0.;
02662             };
02663     
02664     
02665     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02666     ;
02667     
02668         
02669     bot_clr = 
02670     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02671         ;
02672     shade_factor = bot_opc * slice_depth_cueing;
02673     
02674         bot_clr *= shade_factor;
02675     ;
02676                 
02677        acc_opc += bot_opc * wgtBR;
02678        acc_clr += bot_clr * wgtBR;
02679        
02680 #ifdef DEBUG
02681     if (ipixel == trace_pixel_ptr) {
02682         trace_opcBR = bot_opc;
02683         trace_rclrBR = bot_clr;
02684         
02685     }
02686 #endif
02687 ;
02688                 
02689         COUNT_RESAMPLE;
02690         if (acc_opc > min_opacity) {
02691             COUNT_COMPOSITE;
02692             iopc = ipixel->opcflt;
02693 #           ifndef SKIP_ERT
02694                 ASSERT(iopc < max_opacity);
02695 #           endif
02696             iopc_inv = (float)1. - iopc;
02697             ipixel->clrflt += acc_clr * iopc_inv;
02698             iopc += acc_opc * iopc_inv;
02699             ipixel->opcflt = iopc;
02700             
02701 #ifdef DEBUG
02702     if (ipixel == trace_pixel_ptr) {
02703 #ifdef COMPUTE_SHADOW_BUFFER
02704         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02705 #else
02706         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02707 #endif
02708         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02709         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02710         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02711         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02712         printf("  %3.0f %3.0f\n", iopc*255., 
02713                ipixel->clrflt);
02714         
02715         
02716     }
02717 #endif /* DEBUG */
02718 ;
02719 #           ifndef SKIP_ERT
02720                 if (iopc >= max_opacity) {
02721                     ASSERT(ipixel->lnk == 0);
02722                     ipixel->lnk = 1;
02723                 }
02724 #           endif
02725         };
02726                 ipixel += 1;
02727                 topRLEdata += 1 * voxel_istride;
02728                 botRLEdata += 1 * voxel_istride;
02729                 count--;
02730                 SET_VOXELS_LOADED;
02731 
02732                 /* do the rest of the pixels in this run;
02733                    bottom-left and bottom-right voxels contribute */
02734                 while (count > 0) {
02735                     if (PIXEL_IS_OPAQUE(ipixel))
02736                         break;
02737                     if (!voxels_loaded) {
02738                         
02739     
02740             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02741             opacity = param0_table[opac_param];
02742             if (param1_size != 0) {
02743                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02744                 opacity *= param1_table[opac_param];
02745                 if (param2_size != 0) {
02746                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02747                     opacity *= param2_table[opac_param];
02748                 }
02749             }
02750             if (opacity > min_opacity) {
02751                 opacity_int = opacity*255.;
02752                 bot_opc = opac_correct[opacity_int];
02753             } else {
02754                 bot_opc = (float)0.;
02755             };
02756     
02757     
02758     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02759     ;
02760     
02761         
02762     bot_clr = 
02763     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02764         ;
02765     shade_factor = bot_opc * slice_depth_cueing;
02766     
02767         bot_clr *= shade_factor;
02768     ;
02769                     }
02770                     
02771 #ifdef DEBUG
02772     if (ipixel == trace_pixel_ptr) {
02773         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02774         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02775         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02776         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02777         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02778     }
02779 #endif
02780 ;
02781                     
02782        acc_opc = bot_opc * wgtBL;
02783        acc_clr = bot_clr * wgtBL;
02784        
02785 #ifdef DEBUG
02786     if (ipixel == trace_pixel_ptr) {
02787         trace_opcBL = bot_opc;
02788         trace_rclrBL = bot_clr;
02789         
02790     }
02791 #endif
02792 ;
02793                     
02794     
02795             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02796             opacity = param0_table[opac_param];
02797             if (param1_size != 0) {
02798                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02799                 opacity *= param1_table[opac_param];
02800                 if (param2_size != 0) {
02801                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02802                     opacity *= param2_table[opac_param];
02803                 }
02804             }
02805             if (opacity > min_opacity) {
02806                 opacity_int = opacity*255.;
02807                 bot_opc = opac_correct[opacity_int];
02808             } else {
02809                 bot_opc = (float)0.;
02810             };
02811     
02812     
02813     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02814     ;
02815     
02816         
02817     bot_clr = 
02818     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02819         ;
02820     shade_factor = bot_opc * slice_depth_cueing;
02821     
02822         bot_clr *= shade_factor;
02823     ;
02824                     
02825        acc_opc += bot_opc * wgtBR;
02826        acc_clr += bot_clr * wgtBR;
02827        
02828 #ifdef DEBUG
02829     if (ipixel == trace_pixel_ptr) {
02830         trace_opcBR = bot_opc;
02831         trace_rclrBR = bot_clr;
02832         
02833     }
02834 #endif
02835 ;
02836                     
02837         COUNT_RESAMPLE;
02838         if (acc_opc > min_opacity) {
02839             COUNT_COMPOSITE;
02840             iopc = ipixel->opcflt;
02841 #           ifndef SKIP_ERT
02842                 ASSERT(iopc < max_opacity);
02843 #           endif
02844             iopc_inv = (float)1. - iopc;
02845             ipixel->clrflt += acc_clr * iopc_inv;
02846             iopc += acc_opc * iopc_inv;
02847             ipixel->opcflt = iopc;
02848             
02849 #ifdef DEBUG
02850     if (ipixel == trace_pixel_ptr) {
02851 #ifdef COMPUTE_SHADOW_BUFFER
02852         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02853 #else
02854         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02855 #endif
02856         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02857         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02858         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02859         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02860         printf("  %3.0f %3.0f\n", iopc*255., 
02861                ipixel->clrflt);
02862         
02863         
02864     }
02865 #endif /* DEBUG */
02866 ;
02867 #           ifndef SKIP_ERT
02868                 if (iopc >= max_opacity) {
02869                     ASSERT(ipixel->lnk == 0);
02870                     ipixel->lnk = 1;
02871                 }
02872 #           endif
02873         };
02874                     ipixel += 1;
02875                     topRLEdata += 1 * voxel_istride;
02876                     botRLEdata += 1 * voxel_istride;
02877                     count--;
02878                     SET_VOXELS_LOADED;
02879                 }
02880                 break;
02881             case BOT_NONZERO__BOT_NONZERO:
02882                 /* do the pixels in this run; bottom-left and
02883                    bottom-right voxels contribute */
02884                 while (count > 0) {
02885                     if (PIXEL_IS_OPAQUE(ipixel))
02886                         break;
02887                     if (!voxels_loaded) {
02888                         
02889     
02890             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02891             opacity = param0_table[opac_param];
02892             if (param1_size != 0) {
02893                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02894                 opacity *= param1_table[opac_param];
02895                 if (param2_size != 0) {
02896                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02897                     opacity *= param2_table[opac_param];
02898                 }
02899             }
02900             if (opacity > min_opacity) {
02901                 opacity_int = opacity*255.;
02902                 bot_opc = opac_correct[opacity_int];
02903             } else {
02904                 bot_opc = (float)0.;
02905             };
02906     
02907     
02908     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02909     ;
02910     
02911         
02912     bot_clr = 
02913     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02914         ;
02915     shade_factor = bot_opc * slice_depth_cueing;
02916     
02917         bot_clr *= shade_factor;
02918     ;
02919                     }
02920                     
02921 #ifdef DEBUG
02922     if (ipixel == trace_pixel_ptr) {
02923         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02924         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02925         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02926         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02927         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02928     }
02929 #endif
02930 ;
02931                     
02932        acc_opc = bot_opc * wgtBL;
02933        acc_clr = bot_clr * wgtBL;
02934        
02935 #ifdef DEBUG
02936     if (ipixel == trace_pixel_ptr) {
02937         trace_opcBL = bot_opc;
02938         trace_rclrBL = bot_clr;
02939         
02940     }
02941 #endif
02942 ;
02943                     
02944     
02945             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02946             opacity = param0_table[opac_param];
02947             if (param1_size != 0) {
02948                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02949                 opacity *= param1_table[opac_param];
02950                 if (param2_size != 0) {
02951                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02952                     opacity *= param2_table[opac_param];
02953                 }
02954             }
02955             if (opacity > min_opacity) {
02956                 opacity_int = opacity*255.;
02957                 bot_opc = opac_correct[opacity_int];
02958             } else {
02959                 bot_opc = (float)0.;
02960             };
02961     
02962     
02963     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02964     ;
02965     
02966         
02967     bot_clr = 
02968     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02969         ;
02970     shade_factor = bot_opc * slice_depth_cueing;
02971     
02972         bot_clr *= shade_factor;
02973     ;
02974                     
02975        acc_opc += bot_opc * wgtBR;
02976        acc_clr += bot_clr * wgtBR;
02977        
02978 #ifdef DEBUG
02979     if (ipixel == trace_pixel_ptr) {
02980         trace_opcBR = bot_opc;
02981         trace_rclrBR = bot_clr;
02982         
02983     }
02984 #endif
02985 ;
02986                     
02987         COUNT_RESAMPLE;
02988         if (acc_opc > min_opacity) {
02989             COUNT_COMPOSITE;
02990             iopc = ipixel->opcflt;
02991 #           ifndef SKIP_ERT
02992                 ASSERT(iopc < max_opacity);
02993 #           endif
02994             iopc_inv = (float)1. - iopc;
02995             ipixel->clrflt += acc_clr * iopc_inv;
02996             iopc += acc_opc * iopc_inv;
02997             ipixel->opcflt = iopc;
02998             
02999 #ifdef DEBUG
03000     if (ipixel == trace_pixel_ptr) {
03001 #ifdef COMPUTE_SHADOW_BUFFER
03002         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03003 #else
03004         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03005 #endif
03006         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03007         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03008         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03009         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03010         printf("  %3.0f %3.0f\n", iopc*255., 
03011                ipixel->clrflt);
03012         
03013         
03014     }
03015 #endif /* DEBUG */
03016 ;
03017 #           ifndef SKIP_ERT
03018                 if (iopc >= max_opacity) {
03019                     ASSERT(ipixel->lnk == 0);
03020                     ipixel->lnk = 1;
03021                 }
03022 #           endif
03023         };
03024                     ipixel += 1;
03025                     topRLEdata += 1 * voxel_istride;
03026                     botRLEdata += 1 * voxel_istride;
03027                     count--;
03028                     SET_VOXELS_LOADED;
03029                 }
03030                 break;
03031             case ALL_NONZERO__BOT_NONZERO:
03032                 /* first pixel: top-left, bottom-left and bottom-right
03033                    voxels contribute */
03034                 if (!voxels_loaded) {
03035                     
03036     
03037             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03038             opacity = param0_table[opac_param];
03039             if (param1_size != 0) {
03040                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03041                 opacity *= param1_table[opac_param];
03042                 if (param2_size != 0) {
03043                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03044                     opacity *= param2_table[opac_param];
03045                 }
03046             }
03047             if (opacity > min_opacity) {
03048                 opacity_int = opacity*255.;
03049                 top_opc = opac_correct[opacity_int];
03050             } else {
03051                 top_opc = (float)0.;
03052             };
03053     
03054     
03055     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03056     ;
03057     
03058         
03059     top_clr = 
03060     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03061         ;
03062     shade_factor = top_opc * slice_depth_cueing;
03063     
03064         top_clr *= shade_factor;
03065     ;
03066                     
03067     
03068             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03069             opacity = param0_table[opac_param];
03070             if (param1_size != 0) {
03071                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03072                 opacity *= param1_table[opac_param];
03073                 if (param2_size != 0) {
03074                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03075                     opacity *= param2_table[opac_param];
03076                 }
03077             }
03078             if (opacity > min_opacity) {
03079                 opacity_int = opacity*255.;
03080                 bot_opc = opac_correct[opacity_int];
03081             } else {
03082                 bot_opc = (float)0.;
03083             };
03084     
03085     
03086     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03087     ;
03088     
03089         
03090     bot_clr = 
03091     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03092         ;
03093     shade_factor = bot_opc * slice_depth_cueing;
03094     
03095         bot_clr *= shade_factor;
03096     ;
03097                 }
03098                 
03099 #ifdef DEBUG
03100     if (ipixel == trace_pixel_ptr) {
03101         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03102         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03103         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03104         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03105         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03106     }
03107 #endif
03108 ;
03109                 
03110        acc_opc = top_opc * wgtTL;
03111        acc_clr = top_clr * wgtTL;
03112        
03113 #ifdef DEBUG
03114     if (ipixel == trace_pixel_ptr) {
03115         trace_opcTL = top_opc;
03116         trace_rclrTL = top_clr;
03117         
03118     }
03119 #endif
03120 ;
03121                 
03122        acc_opc += bot_opc * wgtBL;
03123        acc_clr += bot_clr * wgtBL;
03124        
03125 #ifdef DEBUG
03126     if (ipixel == trace_pixel_ptr) {
03127         trace_opcBL = bot_opc;
03128         trace_rclrBL = bot_clr;
03129         
03130     }
03131 #endif
03132 ;
03133                 
03134     
03135             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03136             opacity = param0_table[opac_param];
03137             if (param1_size != 0) {
03138                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03139                 opacity *= param1_table[opac_param];
03140                 if (param2_size != 0) {
03141                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03142                     opacity *= param2_table[opac_param];
03143                 }
03144             }
03145             if (opacity > min_opacity) {
03146                 opacity_int = opacity*255.;
03147                 bot_opc = opac_correct[opacity_int];
03148             } else {
03149                 bot_opc = (float)0.;
03150             };
03151     
03152     
03153     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03154     ;
03155     
03156         
03157     bot_clr = 
03158     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03159         ;
03160     shade_factor = bot_opc * slice_depth_cueing;
03161     
03162         bot_clr *= shade_factor;
03163     ;
03164                 
03165        acc_opc += bot_opc * wgtBR;
03166        acc_clr += bot_clr * wgtBR;
03167        
03168 #ifdef DEBUG
03169     if (ipixel == trace_pixel_ptr) {
03170         trace_opcBR = bot_opc;
03171         trace_rclrBR = bot_clr;
03172         
03173     }
03174 #endif
03175 ;
03176                 
03177         COUNT_RESAMPLE;
03178         if (acc_opc > min_opacity) {
03179             COUNT_COMPOSITE;
03180             iopc = ipixel->opcflt;
03181 #           ifndef SKIP_ERT
03182                 ASSERT(iopc < max_opacity);
03183 #           endif
03184             iopc_inv = (float)1. - iopc;
03185             ipixel->clrflt += acc_clr * iopc_inv;
03186             iopc += acc_opc * iopc_inv;
03187             ipixel->opcflt = iopc;
03188             
03189 #ifdef DEBUG
03190     if (ipixel == trace_pixel_ptr) {
03191 #ifdef COMPUTE_SHADOW_BUFFER
03192         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03193 #else
03194         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03195 #endif
03196         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03197         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03198         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03199         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03200         printf("  %3.0f %3.0f\n", iopc*255., 
03201                ipixel->clrflt);
03202         
03203         
03204     }
03205 #endif /* DEBUG */
03206 ;
03207 #           ifndef SKIP_ERT
03208                 if (iopc >= max_opacity) {
03209                     ASSERT(ipixel->lnk == 0);
03210                     ipixel->lnk = 1;
03211                 }
03212 #           endif
03213         };
03214                 ipixel += 1;
03215                 topRLEdata += 1 * voxel_istride;
03216                 botRLEdata += 1 * voxel_istride;
03217                 count--;
03218                 SET_VOXELS_LOADED;
03219 
03220                 /* do the rest of the pixels in this run;
03221                    bottom-left and bottom-right voxels contribute */
03222                 while (count > 0) {
03223                     if (PIXEL_IS_OPAQUE(ipixel))
03224                         break;
03225                     if (!voxels_loaded) {
03226                         
03227     
03228             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03229             opacity = param0_table[opac_param];
03230             if (param1_size != 0) {
03231                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03232                 opacity *= param1_table[opac_param];
03233                 if (param2_size != 0) {
03234                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03235                     opacity *= param2_table[opac_param];
03236                 }
03237             }
03238             if (opacity > min_opacity) {
03239                 opacity_int = opacity*255.;
03240                 bot_opc = opac_correct[opacity_int];
03241             } else {
03242                 bot_opc = (float)0.;
03243             };
03244     
03245     
03246     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03247     ;
03248     
03249         
03250     bot_clr = 
03251     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03252         ;
03253     shade_factor = bot_opc * slice_depth_cueing;
03254     
03255         bot_clr *= shade_factor;
03256     ;
03257                     }
03258                     
03259 #ifdef DEBUG
03260     if (ipixel == trace_pixel_ptr) {
03261         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03262         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03263         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03264         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03265         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03266     }
03267 #endif
03268 ;
03269                     
03270        acc_opc = bot_opc * wgtBL;
03271        acc_clr = bot_clr * wgtBL;
03272        
03273 #ifdef DEBUG
03274     if (ipixel == trace_pixel_ptr) {
03275         trace_opcBL = bot_opc;
03276         trace_rclrBL = bot_clr;
03277         
03278     }
03279 #endif
03280 ;
03281                     
03282     
03283             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03284             opacity = param0_table[opac_param];
03285             if (param1_size != 0) {
03286                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03287                 opacity *= param1_table[opac_param];
03288                 if (param2_size != 0) {
03289                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03290                     opacity *= param2_table[opac_param];
03291                 }
03292             }
03293             if (opacity > min_opacity) {
03294                 opacity_int = opacity*255.;
03295                 bot_opc = opac_correct[opacity_int];
03296             } else {
03297                 bot_opc = (float)0.;
03298             };
03299     
03300     
03301     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03302     ;
03303     
03304         
03305     bot_clr = 
03306     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03307         ;
03308     shade_factor = bot_opc * slice_depth_cueing;
03309     
03310         bot_clr *= shade_factor;
03311     ;
03312                     
03313        acc_opc += bot_opc * wgtBR;
03314        acc_clr += bot_clr * wgtBR;
03315        
03316 #ifdef DEBUG
03317     if (ipixel == trace_pixel_ptr) {
03318         trace_opcBR = bot_opc;
03319         trace_rclrBR = bot_clr;
03320         
03321     }
03322 #endif
03323 ;
03324                     
03325         COUNT_RESAMPLE;
03326         if (acc_opc > min_opacity) {
03327             COUNT_COMPOSITE;
03328             iopc = ipixel->opcflt;
03329 #           ifndef SKIP_ERT
03330                 ASSERT(iopc < max_opacity);
03331 #           endif
03332             iopc_inv = (float)1. - iopc;
03333             ipixel->clrflt += acc_clr * iopc_inv;
03334             iopc += acc_opc * iopc_inv;
03335             ipixel->opcflt = iopc;
03336             
03337 #ifdef DEBUG
03338     if (ipixel == trace_pixel_ptr) {
03339 #ifdef COMPUTE_SHADOW_BUFFER
03340         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03341 #else
03342         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03343 #endif
03344         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03345         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03346         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03347         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03348         printf("  %3.0f %3.0f\n", iopc*255., 
03349                ipixel->clrflt);
03350         
03351         
03352     }
03353 #endif /* DEBUG */
03354 ;
03355 #           ifndef SKIP_ERT
03356                 if (iopc >= max_opacity) {
03357                     ASSERT(ipixel->lnk == 0);
03358                     ipixel->lnk = 1;
03359                 }
03360 #           endif
03361         };
03362                     ipixel += 1;
03363                     topRLEdata += 1 * voxel_istride;
03364                     botRLEdata += 1 * voxel_istride;
03365                     count--;
03366                     SET_VOXELS_LOADED;
03367                 }
03368                 break;
03369             case ALL_ZERO__ALL_NONZERO:
03370                 /* first pixel: top-right and bottom-right voxels contribute */
03371                 
03372     
03373             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
03374             opacity = param0_table[opac_param];
03375             if (param1_size != 0) {
03376                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
03377                 opacity *= param1_table[opac_param];
03378                 if (param2_size != 0) {
03379                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
03380                     opacity *= param2_table[opac_param];
03381                 }
03382             }
03383             if (opacity > min_opacity) {
03384                 opacity_int = opacity*255.;
03385                 top_opc = opac_correct[opacity_int];
03386             } else {
03387                 top_opc = (float)0.;
03388             };
03389     
03390     
03391     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03392     ;
03393     
03394         
03395     top_clr = 
03396     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03397         ;
03398     shade_factor = top_opc * slice_depth_cueing;
03399     
03400         top_clr *= shade_factor;
03401     ;
03402                 
03403     
03404             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03405             opacity = param0_table[opac_param];
03406             if (param1_size != 0) {
03407                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03408                 opacity *= param1_table[opac_param];
03409                 if (param2_size != 0) {
03410                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03411                     opacity *= param2_table[opac_param];
03412                 }
03413             }
03414             if (opacity > min_opacity) {
03415                 opacity_int = opacity*255.;
03416                 bot_opc = opac_correct[opacity_int];
03417             } else {
03418                 bot_opc = (float)0.;
03419             };
03420     
03421     
03422     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03423     ;
03424     
03425         
03426     bot_clr = 
03427     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03428         ;
03429     shade_factor = bot_opc * slice_depth_cueing;
03430     
03431         bot_clr *= shade_factor;
03432     ;
03433                 
03434 #ifdef DEBUG
03435     if (ipixel == trace_pixel_ptr) {
03436         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03437         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03438         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03439         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03440         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03441     }
03442 #endif
03443 ;
03444                 
03445        acc_opc = top_opc * wgtTR;
03446        acc_clr = top_clr * wgtTR;
03447        
03448 #ifdef DEBUG
03449     if (ipixel == trace_pixel_ptr) {
03450         trace_opcTR = top_opc;
03451         trace_rclrTR = top_clr;
03452         
03453     }
03454 #endif
03455 ;
03456                 
03457        acc_opc += bot_opc * wgtBR;
03458        acc_clr += bot_clr * wgtBR;
03459        
03460 #ifdef DEBUG
03461     if (ipixel == trace_pixel_ptr) {
03462         trace_opcBR = bot_opc;
03463         trace_rclrBR = bot_clr;
03464         
03465     }
03466 #endif
03467 ;
03468                 
03469         COUNT_RESAMPLE;
03470         if (acc_opc > min_opacity) {
03471             COUNT_COMPOSITE;
03472             iopc = ipixel->opcflt;
03473 #           ifndef SKIP_ERT
03474                 ASSERT(iopc < max_opacity);
03475 #           endif
03476             iopc_inv = (float)1. - iopc;
03477             ipixel->clrflt += acc_clr * iopc_inv;
03478             iopc += acc_opc * iopc_inv;
03479             ipixel->opcflt = iopc;
03480             
03481 #ifdef DEBUG
03482     if (ipixel == trace_pixel_ptr) {
03483 #ifdef COMPUTE_SHADOW_BUFFER
03484         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03485 #else
03486         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03487 #endif
03488         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03489         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03490         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03491         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03492         printf("  %3.0f %3.0f\n", iopc*255., 
03493                ipixel->clrflt);
03494         
03495         
03496     }
03497 #endif /* DEBUG */
03498 ;
03499 #           ifndef SKIP_ERT
03500                 if (iopc >= max_opacity) {
03501                     ASSERT(ipixel->lnk == 0);
03502                     ipixel->lnk = 1;
03503                 }
03504 #           endif
03505         };
03506                 ipixel += 1;
03507                 topRLEdata += 1 * voxel_istride;
03508                 botRLEdata += 1 * voxel_istride;
03509                 count--;
03510                 SET_VOXELS_LOADED;
03511 
03512                 /* do the rest of the pixels in this run;
03513                    all four voxels contribute */
03514                 while (count > 0) {
03515                     if (PIXEL_IS_OPAQUE(ipixel))
03516                         break;
03517                     if (!voxels_loaded) {
03518                         
03519     
03520             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03521             opacity = param0_table[opac_param];
03522             if (param1_size != 0) {
03523                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03524                 opacity *= param1_table[opac_param];
03525                 if (param2_size != 0) {
03526                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03527                     opacity *= param2_table[opac_param];
03528                 }
03529             }
03530             if (opacity > min_opacity) {
03531                 opacity_int = opacity*255.;
03532                 top_opc = opac_correct[opacity_int];
03533             } else {
03534                 top_opc = (float)0.;
03535             };
03536     
03537     
03538     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03539     ;
03540     
03541         
03542     top_clr = 
03543     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03544         ;
03545     shade_factor = top_opc * slice_depth_cueing;
03546     
03547         top_clr *= shade_factor;
03548     ;
03549                         
03550     
03551             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03552             opacity = param0_table[opac_param];
03553             if (param1_size != 0) {
03554                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03555                 opacity *= param1_table[opac_param];
03556                 if (param2_size != 0) {
03557                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03558                     opacity *= param2_table[opac_param];
03559                 }
03560             }
03561             if (opacity > min_opacity) {
03562                 opacity_int = opacity*255.;
03563                 bot_opc = opac_correct[opacity_int];
03564             } else {
03565                 bot_opc = (float)0.;
03566             };
03567     
03568     
03569     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03570     ;
03571     
03572         
03573     bot_clr = 
03574     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03575         ;
03576     shade_factor = bot_opc * slice_depth_cueing;
03577     
03578         bot_clr *= shade_factor;
03579     ;
03580                     }
03581                     
03582 #ifdef DEBUG
03583     if (ipixel == trace_pixel_ptr) {
03584         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03585         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03586         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03587         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03588         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03589     }
03590 #endif
03591 ;
03592                     
03593        acc_opc = top_opc * wgtTL;
03594        acc_clr = top_clr * wgtTL;
03595        
03596 #ifdef DEBUG
03597     if (ipixel == trace_pixel_ptr) {
03598         trace_opcTL = top_opc;
03599         trace_rclrTL = top_clr;
03600         
03601     }
03602 #endif
03603 ;
03604                     
03605        acc_opc += bot_opc * wgtBL;
03606        acc_clr += bot_clr * wgtBL;
03607        
03608 #ifdef DEBUG
03609     if (ipixel == trace_pixel_ptr) {
03610         trace_opcBL = bot_opc;
03611         trace_rclrBL = bot_clr;
03612         
03613     }
03614 #endif
03615 ;
03616                     
03617     
03618             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
03619             opacity = param0_table[opac_param];
03620             if (param1_size != 0) {
03621                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
03622                 opacity *= param1_table[opac_param];
03623                 if (param2_size != 0) {
03624                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
03625                     opacity *= param2_table[opac_param];
03626                 }
03627             }
03628             if (opacity > min_opacity) {
03629                 opacity_int = opacity*255.;
03630                 top_opc = opac_correct[opacity_int];
03631             } else {
03632                 top_opc = (float)0.;
03633             };
03634     
03635     
03636     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03637     ;
03638     
03639         
03640     top_clr = 
03641     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03642         ;
03643     shade_factor = top_opc * slice_depth_cueing;
03644     
03645         top_clr *= shade_factor;
03646     ;
03647                     
03648     
03649             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03650             opacity = param0_table[opac_param];
03651             if (param1_size != 0) {
03652                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03653                 opacity *= param1_table[opac_param];
03654                 if (param2_size != 0) {
03655                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03656                     opacity *= param2_table[opac_param];
03657                 }
03658             }
03659             if (opacity > min_opacity) {
03660                 opacity_int = opacity*255.;
03661                 bot_opc = opac_correct[opacity_int];
03662             } else {
03663                 bot_opc = (float)0.;
03664             };
03665     
03666     
03667     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03668     ;
03669     
03670         
03671     bot_clr = 
03672     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03673         ;
03674     shade_factor = bot_opc * slice_depth_cueing;
03675     
03676         bot_clr *= shade_factor;
03677     ;
03678                     
03679        acc_opc += top_opc * wgtTR;
03680        acc_clr += top_clr * wgtTR;
03681        
03682 #ifdef DEBUG
03683     if (ipixel == trace_pixel_ptr) {
03684         trace_opcTR = top_opc;
03685         trace_rclrTR = top_clr;
03686         
03687     }
03688 #endif
03689 ;
03690                     
03691        acc_opc += bot_opc * wgtBR;
03692        acc_clr += bot_clr * wgtBR;
03693        
03694 #ifdef DEBUG
03695     if (ipixel == trace_pixel_ptr) {
03696         trace_opcBR = bot_opc;
03697         trace_rclrBR = bot_clr;
03698         
03699     }
03700 #endif
03701 ;
03702                     
03703         COUNT_RESAMPLE;
03704         if (acc_opc > min_opacity) {
03705             COUNT_COMPOSITE;
03706             iopc = ipixel->opcflt;
03707 #           ifndef SKIP_ERT
03708                 ASSERT(iopc < max_opacity);
03709 #           endif
03710             iopc_inv = (float)1. - iopc;
03711             ipixel->clrflt += acc_clr * iopc_inv;
03712             iopc += acc_opc * iopc_inv;
03713             ipixel->opcflt = iopc;
03714             
03715 #ifdef DEBUG
03716     if (ipixel == trace_pixel_ptr) {
03717 #ifdef COMPUTE_SHADOW_BUFFER
03718         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03719 #else
03720         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03721 #endif
03722         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03723         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03724         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03725         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03726         printf("  %3.0f %3.0f\n", iopc*255., 
03727                ipixel->clrflt);
03728         
03729         
03730     }
03731 #endif /* DEBUG */
03732 ;
03733 #           ifndef SKIP_ERT
03734                 if (iopc >= max_opacity) {
03735                     ASSERT(ipixel->lnk == 0);
03736                     ipixel->lnk = 1;
03737                 }
03738 #           endif
03739         };
03740                     ipixel += 1;
03741                     topRLEdata += 1 * voxel_istride;
03742                     botRLEdata += 1 * voxel_istride;
03743                     count--;
03744                     SET_VOXELS_LOADED;
03745                 }
03746                 break;
03747             case TOP_NONZERO__ALL_NONZERO:
03748                 /* first pixel: top-left, top-right and bottom-right
03749                    voxels contribute */
03750                 if (!voxels_loaded) {
03751                     
03752     
03753             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03754             opacity = param0_table[opac_param];
03755             if (param1_size != 0) {
03756                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03757                 opacity *= param1_table[opac_param];
03758                 if (param2_size != 0) {
03759                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03760                     opacity *= param2_table[opac_param];
03761                 }
03762             }
03763             if (opacity > min_opacity) {
03764                 opacity_int = opacity*255.;
03765                 top_opc = opac_correct[opacity_int];
03766             } else {
03767                 top_opc = (float)0.;
03768             };
03769     
03770     
03771     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03772     ;
03773     
03774         
03775     top_clr = 
03776     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03777         ;
03778     shade_factor = top_opc * slice_depth_cueing;
03779     
03780         top_clr *= shade_factor;
03781     ;
03782                 }
03783                 
03784 #ifdef DEBUG
03785     if (ipixel == trace_pixel_ptr) {
03786         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03787         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03788         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03789         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03790         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03791     }
03792 #endif
03793 ;
03794                 
03795        acc_opc = top_opc * wgtTL;
03796        acc_clr = top_clr * wgtTL;
03797        
03798 #ifdef DEBUG
03799     if (ipixel == trace_pixel_ptr) {
03800         trace_opcTL = top_opc;
03801         trace_rclrTL = top_clr;
03802         
03803     }
03804 #endif
03805 ;
03806                 
03807     
03808             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
03809             opacity = param0_table[opac_param];
03810             if (param1_size != 0) {
03811                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
03812                 opacity *= param1_table[opac_param];
03813                 if (param2_size != 0) {
03814                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
03815                     opacity *= param2_table[opac_param];
03816                 }
03817             }
03818             if (opacity > min_opacity) {
03819                 opacity_int = opacity*255.;
03820                 top_opc = opac_correct[opacity_int];
03821             } else {
03822                 top_opc = (float)0.;
03823             };
03824     
03825     
03826     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03827     ;
03828     
03829         
03830     top_clr = 
03831     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03832         ;
03833     shade_factor = top_opc * slice_depth_cueing;
03834     
03835         top_clr *= shade_factor;
03836     ;
03837                 
03838     
03839             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03840             opacity = param0_table[opac_param];
03841             if (param1_size != 0) {
03842                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03843                 opacity *= param1_table[opac_param];
03844                 if (param2_size != 0) {
03845                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03846                     opacity *= param2_table[opac_param];
03847                 }
03848             }
03849             if (opacity > min_opacity) {
03850                 opacity_int = opacity*255.;
03851                 bot_opc = opac_correct[opacity_int];
03852             } else {
03853                 bot_opc = (float)0.;
03854             };
03855     
03856     
03857     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03858     ;
03859     
03860         
03861     bot_clr = 
03862     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03863         ;
03864     shade_factor = bot_opc * slice_depth_cueing;
03865     
03866         bot_clr *= shade_factor;
03867     ;
03868                 
03869        acc_opc += top_opc * wgtTR;
03870        acc_clr += top_clr * wgtTR;
03871        
03872 #ifdef DEBUG
03873     if (ipixel == trace_pixel_ptr) {
03874         trace_opcTR = top_opc;
03875         trace_rclrTR = top_clr;
03876         
03877     }
03878 #endif
03879 ;
03880                 
03881        acc_opc += bot_opc * wgtBR;
03882        acc_clr += bot_clr * wgtBR;
03883        
03884 #ifdef DEBUG
03885     if (ipixel == trace_pixel_ptr) {
03886         trace_opcBR = bot_opc;
03887         trace_rclrBR = bot_clr;
03888         
03889     }
03890 #endif
03891 ;
03892                 
03893         COUNT_RESAMPLE;
03894         if (acc_opc > min_opacity) {
03895             COUNT_COMPOSITE;
03896             iopc = ipixel->opcflt;
03897 #           ifndef SKIP_ERT
03898                 ASSERT(iopc < max_opacity);
03899 #           endif
03900             iopc_inv = (float)1. - iopc;
03901             ipixel->clrflt += acc_clr * iopc_inv;
03902             iopc += acc_opc * iopc_inv;
03903             ipixel->opcflt = iopc;
03904             
03905 #ifdef DEBUG
03906     if (ipixel == trace_pixel_ptr) {
03907 #ifdef COMPUTE_SHADOW_BUFFER
03908         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03909 #else
03910         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03911 #endif
03912         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03913         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03914         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03915         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03916         printf("  %3.0f %3.0f\n", iopc*255., 
03917                ipixel->clrflt);
03918         
03919         
03920     }
03921 #endif /* DEBUG */
03922 ;
03923 #           ifndef SKIP_ERT
03924                 if (iopc >= max_opacity) {
03925                     ASSERT(ipixel->lnk == 0);
03926                     ipixel->lnk = 1;
03927                 }
03928 #           endif
03929         };
03930                 ipixel += 1;
03931                 topRLEdata += 1 * voxel_istride;
03932                 botRLEdata += 1 * voxel_istride;
03933                 count--;
03934                 SET_VOXELS_LOADED;
03935                     
03936                 /* do the rest of the pixels in this run;
03937                    all four voxels contribute */
03938                 while (count > 0) {
03939                     if (PIXEL_IS_OPAQUE(ipixel))
03940                         break;
03941                     if (!voxels_loaded) {
03942                         
03943     
03944             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03945             opacity = param0_table[opac_param];
03946             if (param1_size != 0) {
03947                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03948                 opacity *= param1_table[opac_param];
03949                 if (param2_size != 0) {
03950                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03951                     opacity *= param2_table[opac_param];
03952                 }
03953             }
03954             if (opacity > min_opacity) {
03955                 opacity_int = opacity*255.;
03956                 top_opc = opac_correct[opacity_int];
03957             } else {
03958                 top_opc = (float)0.;
03959             };
03960     
03961     
03962     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03963     ;
03964     
03965         
03966     top_clr = 
03967     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03968         ;
03969     shade_factor = top_opc * slice_depth_cueing;
03970     
03971         top_clr *= shade_factor;
03972     ;
03973                         
03974     
03975             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03976             opacity = param0_table[opac_param];
03977             if (param1_size != 0) {
03978                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03979                 opacity *= param1_table[opac_param];
03980                 if (param2_size != 0) {
03981                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03982                     opacity *= param2_table[opac_param];
03983                 }
03984             }
03985             if (opacity > min_opacity) {
03986                 opacity_int = opacity*255.;
03987                 bot_opc = opac_correct[opacity_int];
03988             } else {
03989                 bot_opc = (float)0.;
03990             };
03991     
03992     
03993     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03994     ;
03995     
03996         
03997     bot_clr = 
03998     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03999         ;
04000     shade_factor = bot_opc * slice_depth_cueing;
04001     
04002         bot_clr *= shade_factor;
04003     ;
04004                     }
04005                     
04006 #ifdef DEBUG
04007     if (ipixel == trace_pixel_ptr) {
04008         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04009         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04010         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04011         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04012         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04013     }
04014 #endif
04015 ;
04016                     
04017        acc_opc = top_opc * wgtTL;
04018        acc_clr = top_clr * wgtTL;
04019        
04020 #ifdef DEBUG
04021     if (ipixel == trace_pixel_ptr) {
04022         trace_opcTL = top_opc;
04023         trace_rclrTL = top_clr;
04024         
04025     }
04026 #endif
04027 ;
04028                     
04029        acc_opc += bot_opc * wgtBL;
04030        acc_clr += bot_clr * wgtBL;
04031        
04032 #ifdef DEBUG
04033     if (ipixel == trace_pixel_ptr) {
04034         trace_opcBL = bot_opc;
04035         trace_rclrBL = bot_clr;
04036         
04037     }
04038 #endif
04039 ;
04040                     
04041     
04042             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04043             opacity = param0_table[opac_param];
04044             if (param1_size != 0) {
04045                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04046                 opacity *= param1_table[opac_param];
04047                 if (param2_size != 0) {
04048                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04049                     opacity *= param2_table[opac_param];
04050                 }
04051             }
04052             if (opacity > min_opacity) {
04053                 opacity_int = opacity*255.;
04054                 top_opc = opac_correct[opacity_int];
04055             } else {
04056                 top_opc = (float)0.;
04057             };
04058     
04059     
04060     shade_index=1*1*ShortField(topRLEdata,norm_offset);
04061     ;
04062     
04063         
04064     top_clr = 
04065     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04066         ;
04067     shade_factor = top_opc * slice_depth_cueing;
04068     
04069         top_clr *= shade_factor;
04070     ;
04071                     
04072     
04073             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04074             opacity = param0_table[opac_param];
04075             if (param1_size != 0) {
04076                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04077                 opacity *= param1_table[opac_param];
04078                 if (param2_size != 0) {
04079                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04080                     opacity *= param2_table[opac_param];
04081                 }
04082             }
04083             if (opacity > min_opacity) {
04084                 opacity_int = opacity*255.;
04085                 bot_opc = opac_correct[opacity_int];
04086             } else {
04087                 bot_opc = (float)0.;
04088             };
04089     
04090     
04091     shade_index=1*1*ShortField(botRLEdata,norm_offset);
04092     ;
04093     
04094         
04095     bot_clr = 
04096     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04097         ;
04098     shade_factor = bot_opc * slice_depth_cueing;
04099     
04100         bot_clr *= shade_factor;
04101     ;
04102                     
04103        acc_opc += top_opc * wgtTR;
04104        acc_clr += top_clr * wgtTR;
04105        
04106 #ifdef DEBUG
04107     if (ipixel == trace_pixel_ptr) {
04108         trace_opcTR = top_opc;
04109         trace_rclrTR = top_clr;
04110         
04111     }
04112 #endif
04113 ;
04114                     
04115        acc_opc += bot_opc * wgtBR;
04116        acc_clr += bot_clr * wgtBR;
04117        
04118 #ifdef DEBUG
04119     if (ipixel == trace_pixel_ptr) {
04120         trace_opcBR = bot_opc;
04121         trace_rclrBR = bot_clr;
04122         
04123     }
04124 #endif
04125 ;
04126                     
04127         COUNT_RESAMPLE;
04128         if (acc_opc > min_opacity) {
04129             COUNT_COMPOSITE;
04130             iopc = ipixel->opcflt;
04131 #           ifndef SKIP_ERT
04132                 ASSERT(iopc < max_opacity);
04133 #           endif
04134             iopc_inv = (float)1. - iopc;
04135             ipixel->clrflt += acc_clr * iopc_inv;
04136             iopc += acc_opc * iopc_inv;
04137             ipixel->opcflt = iopc;
04138             
04139 #ifdef DEBUG
04140     if (ipixel == trace_pixel_ptr) {
04141 #ifdef COMPUTE_SHADOW_BUFFER
04142         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04143 #else
04144         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04145 #endif
04146         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04147         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04148         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04149         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04150         printf("  %3.0f %3.0f\n", iopc*255., 
04151                ipixel->clrflt);
04152         
04153         
04154     }
04155 #endif /* DEBUG */
04156 ;
04157 #           ifndef SKIP_ERT
04158                 if (iopc >= max_opacity) {
04159                     ASSERT(ipixel->lnk == 0);
04160                     ipixel->lnk = 1;
04161                 }
04162 #           endif
04163         };
04164                     ipixel += 1;
04165                     topRLEdata += 1 * voxel_istride;
04166                     botRLEdata += 1 * voxel_istride;
04167                     count--;
04168                     SET_VOXELS_LOADED;
04169                 }
04170                 break;
04171             case BOT_NONZERO__ALL_NONZERO:
04172                 /* first pixel: bottom-left, top-right and bottom-right
04173                    voxels contribute */
04174                 if (!voxels_loaded) {
04175                     
04176     
04177             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04178             opacity = param0_table[opac_param];
04179             if (param1_size != 0) {
04180                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04181                 opacity *= param1_table[opac_param];
04182                 if (param2_size != 0) {
04183                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04184                     opacity *= param2_table[opac_param];
04185                 }
04186             }
04187             if (opacity > min_opacity) {
04188                 opacity_int = opacity*255.;
04189                 bot_opc = opac_correct[opacity_int];
04190             } else {
04191                 bot_opc = (float)0.;
04192             };
04193     
04194     
04195     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04196     ;
04197     
04198         
04199     bot_clr = 
04200     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04201         ;
04202     shade_factor = bot_opc * slice_depth_cueing;
04203     
04204         bot_clr *= shade_factor;
04205     ;
04206                 }
04207                 
04208 #ifdef DEBUG
04209     if (ipixel == trace_pixel_ptr) {
04210         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04211         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04212         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04213         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04214         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04215     }
04216 #endif
04217 ;
04218                 
04219        acc_opc = bot_opc * wgtBL;
04220        acc_clr = bot_clr * wgtBL;
04221        
04222 #ifdef DEBUG
04223     if (ipixel == trace_pixel_ptr) {
04224         trace_opcBL = bot_opc;
04225         trace_rclrBL = bot_clr;
04226         
04227     }
04228 #endif
04229 ;
04230                 
04231     
04232             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04233             opacity = param0_table[opac_param];
04234             if (param1_size != 0) {
04235                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04236                 opacity *= param1_table[opac_param];
04237                 if (param2_size != 0) {
04238                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04239                     opacity *= param2_table[opac_param];
04240                 }
04241             }
04242             if (opacity > min_opacity) {
04243                 opacity_int = opacity*255.;
04244                 top_opc = opac_correct[opacity_int];
04245             } else {
04246                 top_opc = (float)0.;
04247             };
04248     
04249     
04250     shade_index=1*1*ShortField(topRLEdata,norm_offset);
04251     ;
04252     
04253         
04254     top_clr = 
04255     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04256         ;
04257     shade_factor = top_opc * slice_depth_cueing;
04258     
04259         top_clr *= shade_factor;
04260     ;
04261                 
04262     
04263             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04264             opacity = param0_table[opac_param];
04265             if (param1_size != 0) {
04266                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04267                 opacity *= param1_table[opac_param];
04268                 if (param2_size != 0) {
04269                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04270                     opacity *= param2_table[opac_param];
04271                 }
04272             }
04273             if (opacity > min_opacity) {
04274                 opacity_int = opacity*255.;
04275                 bot_opc = opac_correct[opacity_int];
04276             } else {
04277                 bot_opc = (float)0.;
04278             };
04279     
04280     
04281     shade_index=1*1*ShortField(botRLEdata,norm_offset);
04282     ;
04283     
04284         
04285     bot_clr = 
04286     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04287         ;
04288     shade_factor = bot_opc * slice_depth_cueing;
04289     
04290         bot_clr *= shade_factor;
04291     ;
04292                 
04293        acc_opc += top_opc * wgtTR;
04294        acc_clr += top_clr * wgtTR;
04295        
04296 #ifdef DEBUG
04297     if (ipixel == trace_pixel_ptr) {
04298         trace_opcTR = top_opc;
04299         trace_rclrTR = top_clr;
04300         
04301     }
04302 #endif
04303 ;
04304                 
04305        acc_opc += bot_opc * wgtBR;
04306        acc_clr += bot_clr * wgtBR;
04307        
04308 #ifdef DEBUG
04309     if (ipixel == trace_pixel_ptr) {
04310         trace_opcBR = bot_opc;
04311         trace_rclrBR = bot_clr;
04312         
04313     }
04314 #endif
04315 ;
04316                 
04317         COUNT_RESAMPLE;
04318         if (acc_opc > min_opacity) {
04319             COUNT_COMPOSITE;
04320             iopc = ipixel->opcflt;
04321 #           ifndef SKIP_ERT
04322                 ASSERT(iopc < max_opacity);
04323 #           endif
04324             iopc_inv = (float)1. - iopc;
04325             ipixel->clrflt += acc_clr * iopc_inv;
04326             iopc += acc_opc * iopc_inv;
04327             ipixel->opcflt = iopc;
04328             
04329 #ifdef DEBUG
04330     if (ipixel == trace_pixel_ptr) {
04331 #ifdef COMPUTE_SHADOW_BUFFER
04332         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04333 #else
04334         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04335 #endif
04336         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04337         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04338         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04339         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04340         printf("  %3.0f %3.0f\n", iopc*255., 
04341                ipixel->clrflt);
04342         
04343         
04344     }
04345 #endif /* DEBUG */
04346 ;
04347 #           ifndef SKIP_ERT
04348                 if (iopc >= max_opacity) {
04349                     ASSERT(ipixel->lnk == 0);
04350                     ipixel->lnk = 1;
04351                 }
04352 #           endif
04353         };
04354                 ipixel += 1;
04355                 topRLEdata += 1 * voxel_istride;
04356                 botRLEdata += 1 * voxel_istride;
04357                 count--;
04358                 SET_VOXELS_LOADED;
04359                     
04360                 /* do the rest of the pixels in this run;
04361                    all four voxels contribute */
04362                 while (count > 0) {
04363                     if (PIXEL_IS_OPAQUE(ipixel))
04364                         break;
04365                     if (!voxels_loaded) {
04366                         
04367     
04368             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04369             opacity = param0_table[opac_param];
04370             if (param1_size != 0) {
04371                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04372                 opacity *= param1_table[opac_param];
04373                 if (param2_size != 0) {
04374                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04375                     opacity *= param2_table[opac_param];
04376                 }
04377             }
04378             if (opacity > min_opacity) {
04379                 opacity_int = opacity*255.;
04380                 top_opc = opac_correct[opacity_int];
04381             } else {
04382                 top_opc = (float)0.;
04383             };
04384     
04385     
04386     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04387     ;
04388     
04389         
04390     top_clr = 
04391     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04392         ;
04393     shade_factor = top_opc * slice_depth_cueing;
04394     
04395         top_clr *= shade_factor;
04396     ;
04397                         
04398     
04399             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04400             opacity = param0_table[opac_param];
04401             if (param1_size != 0) {
04402                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04403                 opacity *= param1_table[opac_param];
04404                 if (param2_size != 0) {
04405                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04406                     opacity *= param2_table[opac_param];
04407                 }
04408             }
04409             if (opacity > min_opacity) {
04410                 opacity_int = opacity*255.;
04411                 bot_opc = opac_correct[opacity_int];
04412             } else {
04413                 bot_opc = (float)0.;
04414             };
04415     
04416     
04417     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04418     ;
04419     
04420         
04421     bot_clr = 
04422     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04423         ;
04424     shade_factor = bot_opc * slice_depth_cueing;
04425     
04426         bot_clr *= shade_factor;
04427     ;
04428                     }
04429                     
04430 #ifdef DEBUG
04431     if (ipixel == trace_pixel_ptr) {
04432         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04433         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04434         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04435         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04436         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04437     }
04438 #endif
04439 ;
04440                     
04441        acc_opc = top_opc * wgtTL;
04442        acc_clr = top_clr * wgtTL;
04443        
04444 #ifdef DEBUG
04445     if (ipixel == trace_pixel_ptr) {
04446         trace_opcTL = top_opc;
04447         trace_rclrTL = top_clr;
04448         
04449     }
04450 #endif
04451 ;
04452                     
04453        acc_opc += bot_opc * wgtBL;
04454        acc_clr += bot_clr * wgtBL;
04455        
04456 #ifdef DEBUG
04457     if (ipixel == trace_pixel_ptr) {
04458         trace_opcBL = bot_opc;
04459         trace_rclrBL = bot_clr;
04460         
04461     }
04462 #endif
04463 ;
04464                     
04465     
04466             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04467             opacity = param0_table[opac_param];
04468             if (param1_size != 0) {
04469                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04470                 opacity *= param1_table[opac_param];
04471                 if (param2_size != 0) {
04472                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04473                     opacity *= param2_table[opac_param];
04474                 }
04475             }
04476             if (opacity > min_opacity) {
04477                 opacity_int = opacity*255.;
04478                 top_opc = opac_correct[opacity_int];
04479             } else {
04480                 top_opc = (float)0.;
04481             };
04482     
04483     
04484     shade_index=1*1*ShortField(topRLEdata,norm_offset);
04485     ;
04486     
04487         
04488     top_clr = 
04489     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04490         ;
04491     shade_factor = top_opc * slice_depth_cueing;
04492     
04493         top_clr *= shade_factor;
04494     ;
04495                     
04496     
04497             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04498             opacity = param0_table[opac_param];
04499             if (param1_size != 0) {
04500                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04501                 opacity *= param1_table[opac_param];
04502                 if (param2_size != 0) {
04503                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04504                     opacity *= param2_table[opac_param];
04505                 }
04506             }
04507             if (opacity > min_opacity) {
04508                 opacity_int = opacity*255.;
04509                 bot_opc = opac_correct[opacity_int];
04510             } else {
04511                 bot_opc = (float)0.;
04512             };
04513     
04514     
04515     shade_index=1*1*ShortField(botRLEdata,norm_offset);
04516     ;
04517     
04518         
04519     bot_clr = 
04520     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04521         ;
04522     shade_factor = bot_opc * slice_depth_cueing;
04523     
04524         bot_clr *= shade_factor;
04525     ;
04526                     
04527        acc_opc += top_opc * wgtTR;
04528        acc_clr += top_clr * wgtTR;
04529        
04530 #ifdef DEBUG
04531     if (ipixel == trace_pixel_ptr) {
04532         trace_opcTR = top_opc;
04533         trace_rclrTR = top_clr;
04534         
04535     }
04536 #endif
04537 ;
04538                     
04539        acc_opc += bot_opc * wgtBR;
04540        acc_clr += bot_clr * wgtBR;
04541        
04542 #ifdef DEBUG
04543     if (ipixel == trace_pixel_ptr) {
04544         trace_opcBR = bot_opc;
04545         trace_rclrBR = bot_clr;
04546         
04547     }
04548 #endif
04549 ;
04550                     
04551         COUNT_RESAMPLE;
04552         if (acc_opc > min_opacity) {
04553             COUNT_COMPOSITE;
04554             iopc = ipixel->opcflt;
04555 #           ifndef SKIP_ERT
04556                 ASSERT(iopc < max_opacity);
04557 #           endif
04558             iopc_inv = (float)1. - iopc;
04559             ipixel->clrflt += acc_clr * iopc_inv;
04560             iopc += acc_opc * iopc_inv;
04561             ipixel->opcflt = iopc;
04562             
04563 #ifdef DEBUG
04564     if (ipixel == trace_pixel_ptr) {
04565 #ifdef COMPUTE_SHADOW_BUFFER
04566         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04567 #else
04568         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04569 #endif
04570         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04571         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04572         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04573         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04574         printf("  %3.0f %3.0f\n", iopc*255., 
04575                ipixel->clrflt);
04576         
04577         
04578     }
04579 #endif /* DEBUG */
04580 ;
04581 #           ifndef SKIP_ERT
04582                 if (iopc >= max_opacity) {
04583                     ASSERT(ipixel->lnk == 0);
04584                     ipixel->lnk = 1;
04585                 }
04586 #           endif
04587         };
04588                     ipixel += 1;
04589                     topRLEdata += 1 * voxel_istride;
04590                     botRLEdata += 1 * voxel_istride;
04591                     count--;
04592                     SET_VOXELS_LOADED;
04593                 }
04594                 break;
04595             case ALL_NONZERO__ALL_NONZERO:
04596                 /* do the pixels in this run; all four voxels contribute */
04597                 while (count > 0) {
04598                     if (PIXEL_IS_OPAQUE(ipixel))
04599                         break;
04600                     if (!voxels_loaded) {
04601                         
04602     
04603             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04604             opacity = param0_table[opac_param];
04605             if (param1_size != 0) {
04606                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04607                 opacity *= param1_table[opac_param];
04608                 if (param2_size != 0) {
04609                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04610                     opacity *= param2_table[opac_param];
04611                 }
04612             }
04613             if (opacity > min_opacity) {
04614                 opacity_int = opacity*255.;
04615                 top_opc = opac_correct[opacity_int];
04616             } else {
04617                 top_opc = (float)0.;
04618             };
04619     
04620     
04621     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04622     ;
04623     
04624         
04625     top_clr = 
04626     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04627         ;
04628     shade_factor = top_opc * slice_depth_cueing;
04629     
04630         top_clr *= shade_factor;
04631     ;
04632                         
04633     
04634             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04635             opacity = param0_table[opac_param];
04636             if (param1_size != 0) {
04637                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04638                 opacity *= param1_table[opac_param];
04639                 if (param2_size != 0) {
04640                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04641                     opacity *= param2_table[opac_param];
04642                 }
04643             }
04644             if (opacity > min_opacity) {
04645                 opacity_int = opacity*255.;
04646                 bot_opc = opac_correct[opacity_int];
04647             } else {
04648                 bot_opc = (float)0.;
04649             };
04650     
04651     
04652     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04653     ;
04654     
04655         
04656     bot_clr = 
04657     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04658         ;
04659     shade_factor = bot_opc * slice_depth_cueing;
04660     
04661         bot_clr *= shade_factor;
04662     ;
04663                     }
04664                     
04665 #ifdef DEBUG
04666     if (ipixel == trace_pixel_ptr) {
04667         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04668         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04669         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04670         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04671         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04672     }
04673 #endif
04674 ;
04675                     
04676        acc_opc = top_opc * wgtTL;
04677        acc_clr = top_clr * wgtTL;
04678        
04679 #ifdef DEBUG
04680     if (ipixel == trace_pixel_ptr) {
04681         trace_opcTL = top_opc;
04682         trace_rclrTL = top_clr;
04683         
04684     }
04685 #endif
04686 ;
04687                     
04688        acc_opc += bot_opc * wgtBL;
04689        acc_clr += bot_clr * wgtBL;
04690        
04691 #ifdef DEBUG
04692     if (ipixel == trace_pixel_ptr) {
04693         trace_opcBL = bot_opc;
04694         trace_rclrBL = bot_clr;
04695         
04696     }
04697 #endif
04698 ;
04699                     
04700     
04701             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04702             opacity = param0_table[opac_param];
04703             if (param1_size != 0) {
04704                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04705                 opacity *= param1_table[opac_param];
04706                 if (param2_size != 0) {
04707                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04708                     opacity *= param2_table[opac_param];
04709                 }
04710             }
04711             if (opacity > min_opacity) {
04712                 opacity_int = opacity*255.;
04713                 top_opc = opac_correct[opacity_int];
04714             } else {
04715                 top_opc = (float)0.;
04716             };
04717     
04718     
04719     shade_index=1*1*ShortField(topRLEdata,norm_offset);
04720     ;
04721     
04722         
04723     top_clr = 
04724     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04725         ;
04726     shade_factor = top_opc * slice_depth_cueing;
04727     
04728         top_clr *= shade_factor;
04729     ;
04730                     
04731     
04732             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04733             opacity = param0_table[opac_param];
04734             if (param1_size != 0) {
04735                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04736                 opacity *= param1_table[opac_param];
04737                 if (param2_size != 0) {
04738                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04739                     opacity *= param2_table[opac_param];
04740                 }
04741             }
04742             if (opacity > min_opacity) {
04743                 opacity_int = opacity*255.;
04744                 bot_opc = opac_correct[opacity_int];
04745             } else {
04746                 bot_opc = (float)0.;
04747             };
04748     
04749     
04750     shade_index=1*1*ShortField(botRLEdata,norm_offset);
04751     ;
04752     
04753         
04754     bot_clr = 
04755     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04756         ;
04757     shade_factor = bot_opc * slice_depth_cueing;
04758     
04759         bot_clr *= shade_factor;
04760     ;
04761                     
04762        acc_opc += top_opc * wgtTR;
04763        acc_clr += top_clr * wgtTR;
04764        
04765 #ifdef DEBUG
04766     if (ipixel == trace_pixel_ptr) {
04767         trace_opcTR = top_opc;
04768         trace_rclrTR = top_clr;
04769         
04770     }
04771 #endif
04772 ;
04773                     
04774        acc_opc += bot_opc * wgtBR;
04775        acc_clr += bot_clr * wgtBR;
04776        
04777 #ifdef DEBUG
04778     if (ipixel == trace_pixel_ptr) {
04779         trace_opcBR = bot_opc;
04780         trace_rclrBR = bot_clr;
04781         
04782     }
04783 #endif
04784 ;
04785                     
04786         COUNT_RESAMPLE;
04787         if (acc_opc > min_opacity) {
04788             COUNT_COMPOSITE;
04789             iopc = ipixel->opcflt;
04790 #           ifndef SKIP_ERT
04791                 ASSERT(iopc < max_opacity);
04792 #           endif
04793             iopc_inv = (float)1. - iopc;
04794             ipixel->clrflt += acc_clr * iopc_inv;
04795             iopc += acc_opc * iopc_inv;
04796             ipixel->opcflt = iopc;
04797             
04798 #ifdef DEBUG
04799     if (ipixel == trace_pixel_ptr) {
04800 #ifdef COMPUTE_SHADOW_BUFFER
04801         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04802 #else
04803         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04804 #endif
04805         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04806         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04807         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04808         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04809         printf("  %3.0f %3.0f\n", iopc*255., 
04810                ipixel->clrflt);
04811         
04812         
04813     }
04814 #endif /* DEBUG */
04815 ;
04816 #           ifndef SKIP_ERT
04817                 if (iopc >= max_opacity) {
04818                     ASSERT(ipixel->lnk == 0);
04819                     ipixel->lnk = 1;
04820                 }
04821 #           endif
04822         };
04823                     ipixel += 1;
04824                     topRLEdata += 1 * voxel_istride;
04825                     botRLEdata += 1 * voxel_istride;
04826                     count--;
04827                     SET_VOXELS_LOADED;
04828                 }
04829                 break;
04830             default:
04831                 VPBug("illegal value for run states in compositing loop");
04832             }
04833 #else /* UNROLL_RUN_LOOP */
04834             /* this run contains pixels, so process them */
04835             while (count > 0) {
04836                 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
04837                     ipixel += count;
04838                     if (i != -1) {
04839                         topRLEdata += count * voxel_istride;
04840                         botRLEdata += count * voxel_istride;
04841                     }
04842                     count = 0;
04843                     break;
04844                 }
04845                 if (ipixel->lnk != 0)
04846                     break;
04847                 
04848 #ifdef DEBUG
04849     if (ipixel == trace_pixel_ptr) {
04850         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04851         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04852         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04853         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04854         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04855     }
04856 #endif
04857 ;
04858                 
04859        acc_opc = 0;
04860        acc_clr = 0;
04861                 if (last_run_state & TOP_NONZERO) {
04862                     if (!voxels_loaded) {
04863                         
04864     
04865             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04866             opacity = param0_table[opac_param];
04867             if (param1_size != 0) {
04868                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04869                 opacity *= param1_table[opac_param];
04870                 if (param2_size != 0) {
04871                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04872                     opacity *= param2_table[opac_param];
04873                 }
04874             }
04875             if (opacity > min_opacity) {
04876                 opacity_int = opacity*255.;
04877                 top_opc = opac_correct[opacity_int];
04878             } else {
04879                 top_opc = (float)0.;
04880             };
04881     
04882     
04883     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04884     ;
04885     
04886         
04887     top_clr = 
04888     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04889         ;
04890     shade_factor = top_opc * slice_depth_cueing;
04891     
04892         top_clr *= shade_factor;
04893     ;
04894                     }
04895                     
04896        acc_opc += top_opc * wgtTL;
04897        acc_clr += top_clr * wgtTL;
04898        
04899 #ifdef DEBUG
04900     if (ipixel == trace_pixel_ptr) {
04901         trace_opcTL = top_opc;
04902         trace_rclrTL = top_clr;
04903         
04904     }
04905 #endif
04906 ;
04907                 }
04908                 if (last_run_state & BOT_NONZERO) {
04909                     if (!voxels_loaded) {
04910                         
04911     
04912             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04913             opacity = param0_table[opac_param];
04914             if (param1_size != 0) {
04915                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04916                 opacity *= param1_table[opac_param];
04917                 if (param2_size != 0) {
04918                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04919                     opacity *= param2_table[opac_param];
04920                 }
04921             }
04922             if (opacity > min_opacity) {
04923                 opacity_int = opacity*255.;
04924                 bot_opc = opac_correct[opacity_int];
04925             } else {
04926                 bot_opc = (float)0.;
04927             };
04928     
04929     
04930     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04931     ;
04932     
04933         
04934     bot_clr = 
04935     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04936         ;
04937     shade_factor = bot_opc * slice_depth_cueing;
04938     
04939         bot_clr *= shade_factor;
04940     ;
04941                     }
04942                     
04943        acc_opc += bot_opc * wgtBL;
04944        acc_clr += bot_clr * wgtBL;
04945        
04946 #ifdef DEBUG
04947     if (ipixel == trace_pixel_ptr) {
04948         trace_opcBL = bot_opc;
04949         trace_rclrBL = bot_clr;
04950         
04951     }
04952 #endif
04953 ;
04954                 }
04955                 if (run_state & TOP_NONZERO) {
04956                     
04957     
04958             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04959             opacity = param0_table[opac_param];
04960             if (param1_size != 0) {
04961                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04962                 opacity *= param1_table[opac_param];
04963                 if (param2_size != 0) {
04964                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04965                     opacity *= param2_table[opac_param];
04966                 }
04967             }
04968             if (opacity > min_opacity) {
04969                 opacity_int = opacity*255.;
04970                 top_opc = opac_correct[opacity_int];
04971             } else {
04972                 top_opc = (float)0.;
04973             };
04974     
04975     
04976     shade_index=1*1*ShortField(topRLEdata,norm_offset);
04977     ;
04978     
04979         
04980     top_clr = 
04981     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04982         ;
04983     shade_factor = top_opc * slice_depth_cueing;
04984     
04985         top_clr *= shade_factor;
04986     ;
04987                     
04988        acc_opc += top_opc * wgtTR;
04989        acc_clr += top_clr * wgtTR;
04990        
04991 #ifdef DEBUG
04992     if (ipixel == trace_pixel_ptr) {
04993         trace_opcTR = top_opc;
04994         trace_rclrTR = top_clr;
04995         
04996     }
04997 #endif
04998 ;
04999                     topRLEdata += 1 * voxel_istride;
05000                 } else {
05001                     if (i != -1) {
05002                         topRLEdata += 1 * voxel_istride;
05003                     }
05004                 }
05005                 if (run_state & BOT_NONZERO) {
05006                     
05007     
05008             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05009             opacity = param0_table[opac_param];
05010             if (param1_size != 0) {
05011                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
05012                 opacity *= param1_table[opac_param];
05013                 if (param2_size != 0) {
05014                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
05015                     opacity *= param2_table[opac_param];
05016                 }
05017             }
05018             if (opacity > min_opacity) {
05019                 opacity_int = opacity*255.;
05020                 bot_opc = opac_correct[opacity_int];
05021             } else {
05022                 bot_opc = (float)0.;
05023             };
05024     
05025     
05026     shade_index=1*1*ShortField(botRLEdata,norm_offset);
05027     ;
05028     
05029         
05030     bot_clr = 
05031     shade_table[shade_index + 1*0 + 0] * (float)1.0;
05032         ;
05033     shade_factor = bot_opc * slice_depth_cueing;
05034     
05035         bot_clr *= shade_factor;
05036     ;
05037                     
05038        acc_opc += bot_opc * wgtBR;
05039        acc_clr += bot_clr * wgtBR;
05040        
05041 #ifdef DEBUG
05042     if (ipixel == trace_pixel_ptr) {
05043         trace_opcBR = bot_opc;
05044         trace_rclrBR = bot_clr;
05045         
05046     }
05047 #endif
05048 ;
05049                     botRLEdata += 1 * voxel_istride;
05050                 } else {
05051                     if (i != -1) {
05052                         botRLEdata += 1 * voxel_istride;
05053                     }
05054                 }
05055                 
05056         COUNT_RESAMPLE;
05057         if (acc_opc > min_opacity) {
05058             COUNT_COMPOSITE;
05059             iopc = ipixel->opcflt;
05060 #           ifndef SKIP_ERT
05061                 ASSERT(iopc < max_opacity);
05062 #           endif
05063             iopc_inv = (float)1. - iopc;
05064             ipixel->clrflt += acc_clr * iopc_inv;
05065             iopc += acc_opc * iopc_inv;
05066             ipixel->opcflt = iopc;
05067             
05068 #ifdef DEBUG
05069     if (ipixel == trace_pixel_ptr) {
05070 #ifdef COMPUTE_SHADOW_BUFFER
05071         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05072 #else
05073         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05074 #endif
05075         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05076         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05077         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05078         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05079         printf("  %3.0f %3.0f\n", iopc*255., 
05080                ipixel->clrflt);
05081         
05082         
05083     }
05084 #endif /* DEBUG */
05085 ;
05086 #           ifndef SKIP_ERT
05087                 if (iopc >= max_opacity) {
05088                     ASSERT(ipixel->lnk == 0);
05089                     ipixel->lnk = 1;
05090                 }
05091 #           endif
05092         };
05093                 ipixel += 1;
05094                 count--;
05095                 SET_VOXELS_LOADED;
05096                 last_run_state = run_state;
05097             }
05098 #endif /* UNROLL_RUN_LOOP */
05099 
05100             GET_HIRES_TIME(vpc, t1);
05101             STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
05102             COPY_HIRES_TIME(t0, t1);
05103 
05104             if (count > 0) {
05105                 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
05106                 toprun_count += count;
05107                 botrun_count += count;
05108                 i += count;
05109             }
05110 #endif /* SKIP_COMPOSITE */
05111 
05112             /***********************************************************
05113              * Go on to next voxel run.
05114              ***********************************************************/
05115 
05116             last_run_state = run_state;
05117         } /* while (i > 0) */
05118 
05119         /***************************************************************
05120          * Finish processing voxel scanline and go on to next one.
05121          ***************************************************************/
05122 
05123 #ifdef UNROLL_RUN_LOOP
05124         ASSERT(i == 0);
05125 #else
05126         ASSERT(i == -1);
05127 #endif
05128 
05129 #ifndef SKIP_COMPOSITE
05130 #ifdef UNROLL_RUN_LOOP
05131         /* do the last pixel (to the right of the last voxel) */
05132         if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
05133             /* last voxels are nonzero and the pixel is not opaque yet
05134                so there is work to be done */
05135             Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
05136             switch (last_run_state) {
05137             case TOP_NONZERO:
05138                 /* only the top-left voxel contributes */
05139                 if (!voxels_loaded) {
05140                     
05141     
05142             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05143             opacity = param0_table[opac_param];
05144             if (param1_size != 0) {
05145                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05146                 opacity *= param1_table[opac_param];
05147                 if (param2_size != 0) {
05148                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05149                     opacity *= param2_table[opac_param];
05150                 }
05151             }
05152             if (opacity > min_opacity) {
05153                 opacity_int = opacity*255.;
05154                 top_opc = opac_correct[opacity_int];
05155             } else {
05156                 top_opc = (float)0.;
05157             };
05158     
05159     
05160     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
05161     ;
05162     
05163         
05164     top_clr = 
05165     shade_table[shade_index + 1*0 + 0] * (float)1.0;
05166         ;
05167     shade_factor = top_opc * slice_depth_cueing;
05168     
05169         top_clr *= shade_factor;
05170     ;
05171                 }
05172                 
05173 #ifdef DEBUG
05174     if (ipixel == trace_pixel_ptr) {
05175         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05176         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05177         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05178         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05179         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05180     }
05181 #endif
05182 ;
05183                 
05184        acc_opc = top_opc * wgtTL;
05185        acc_clr = top_clr * wgtTL;
05186        
05187 #ifdef DEBUG
05188     if (ipixel == trace_pixel_ptr) {
05189         trace_opcTL = top_opc;
05190         trace_rclrTL = top_clr;
05191         
05192     }
05193 #endif
05194 ;
05195                 
05196         COUNT_RESAMPLE;
05197         if (acc_opc > min_opacity) {
05198             COUNT_COMPOSITE;
05199             iopc = ipixel->opcflt;
05200 #           ifndef SKIP_ERT
05201                 ASSERT(iopc < max_opacity);
05202 #           endif
05203             iopc_inv = (float)1. - iopc;
05204             ipixel->clrflt += acc_clr * iopc_inv;
05205             iopc += acc_opc * iopc_inv;
05206             ipixel->opcflt = iopc;
05207             
05208 #ifdef DEBUG
05209     if (ipixel == trace_pixel_ptr) {
05210 #ifdef COMPUTE_SHADOW_BUFFER
05211         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05212 #else
05213         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05214 #endif
05215         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05216         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05217         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05218         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05219         printf("  %3.0f %3.0f\n", iopc*255., 
05220                ipixel->clrflt);
05221         
05222         
05223     }
05224 #endif /* DEBUG */
05225 ;
05226 #           ifndef SKIP_ERT
05227                 if (iopc >= max_opacity) {
05228                     ASSERT(ipixel->lnk == 0);
05229                     ipixel->lnk = 1;
05230                 }
05231 #           endif
05232         };
05233                 break;
05234             case BOT_NONZERO:
05235                 /* only the bottom left voxel contributes */
05236                 if (!voxels_loaded) {
05237                     
05238     
05239             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05240             opacity = param0_table[opac_param];
05241             if (param1_size != 0) {
05242                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05243                 opacity *= param1_table[opac_param];
05244                 if (param2_size != 0) {
05245                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05246                     opacity *= param2_table[opac_param];
05247                 }
05248             }
05249             if (opacity > min_opacity) {
05250                 opacity_int = opacity*255.;
05251                 bot_opc = opac_correct[opacity_int];
05252             } else {
05253                 bot_opc = (float)0.;
05254             };
05255     
05256     
05257     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
05258     ;
05259     
05260         
05261     bot_clr = 
05262     shade_table[shade_index + 1*0 + 0] * (float)1.0;
05263         ;
05264     shade_factor = bot_opc * slice_depth_cueing;
05265     
05266         bot_clr *= shade_factor;
05267     ;
05268                 }
05269                 
05270 #ifdef DEBUG
05271     if (ipixel == trace_pixel_ptr) {
05272         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05273         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05274         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05275         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05276         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05277     }
05278 #endif
05279 ;
05280                 
05281        acc_opc = bot_opc * wgtBL;
05282        acc_clr = bot_clr * wgtBL;
05283        
05284 #ifdef DEBUG
05285     if (ipixel == trace_pixel_ptr) {
05286         trace_opcBL = bot_opc;
05287         trace_rclrBL = bot_clr;
05288         
05289     }
05290 #endif
05291 ;
05292                 
05293         COUNT_RESAMPLE;
05294         if (acc_opc > min_opacity) {
05295             COUNT_COMPOSITE;
05296             iopc = ipixel->opcflt;
05297 #           ifndef SKIP_ERT
05298                 ASSERT(iopc < max_opacity);
05299 #           endif
05300             iopc_inv = (float)1. - iopc;
05301             ipixel->clrflt += acc_clr * iopc_inv;
05302             iopc += acc_opc * iopc_inv;
05303             ipixel->opcflt = iopc;
05304             
05305 #ifdef DEBUG
05306     if (ipixel == trace_pixel_ptr) {
05307 #ifdef COMPUTE_SHADOW_BUFFER
05308         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05309 #else
05310         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05311 #endif
05312         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05313         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05314         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05315         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05316         printf("  %3.0f %3.0f\n", iopc*255., 
05317                ipixel->clrflt);
05318         
05319         
05320     }
05321 #endif /* DEBUG */
05322 ;
05323 #           ifndef SKIP_ERT
05324                 if (iopc >= max_opacity) {
05325                     ASSERT(ipixel->lnk == 0);
05326                     ipixel->lnk = 1;
05327                 }
05328 #           endif
05329         };
05330                 break;
05331             case ALL_NONZERO:
05332                 /* the top and bottom left voxels contribute */
05333                 if (!voxels_loaded) {
05334                     
05335     
05336             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05337             opacity = param0_table[opac_param];
05338             if (param1_size != 0) {
05339                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05340                 opacity *= param1_table[opac_param];
05341                 if (param2_size != 0) {
05342                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05343                     opacity *= param2_table[opac_param];
05344                 }
05345             }
05346             if (opacity > min_opacity) {
05347                 opacity_int = opacity*255.;
05348                 top_opc = opac_correct[opacity_int];
05349             } else {
05350                 top_opc = (float)0.;
05351             };
05352     
05353     
05354     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
05355     ;
05356     
05357         
05358     top_clr = 
05359     shade_table[shade_index + 1*0 + 0] * (float)1.0;
05360         ;
05361     shade_factor = top_opc * slice_depth_cueing;
05362     
05363         top_clr *= shade_factor;
05364     ;
05365                     
05366     
05367             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05368             opacity = param0_table[opac_param];
05369             if (param1_size != 0) {
05370                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05371                 opacity *= param1_table[opac_param];
05372                 if (param2_size != 0) {
05373                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05374                     opacity *= param2_table[opac_param];
05375                 }
05376             }
05377             if (opacity > min_opacity) {
05378                 opacity_int = opacity*255.;
05379                 bot_opc = opac_correct[opacity_int];
05380             } else {
05381                 bot_opc = (float)0.;
05382             };
05383     
05384     
05385     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
05386     ;
05387     
05388         
05389     bot_clr = 
05390     shade_table[shade_index + 1*0 + 0] * (float)1.0;
05391         ;
05392     shade_factor = bot_opc * slice_depth_cueing;
05393     
05394         bot_clr *= shade_factor;
05395     ;
05396                 }
05397                 
05398 #ifdef DEBUG
05399     if (ipixel == trace_pixel_ptr) {
05400         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05401         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05402         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05403         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05404         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05405     }
05406 #endif
05407 ;
05408                 
05409        acc_opc = top_opc * wgtTL;
05410        acc_clr = top_clr * wgtTL;
05411        
05412 #ifdef DEBUG
05413     if (ipixel == trace_pixel_ptr) {
05414         trace_opcTL = top_opc;
05415         trace_rclrTL = top_clr;
05416         
05417     }
05418 #endif
05419 ;
05420                 
05421        acc_opc += bot_opc * wgtBL;
05422        acc_clr += bot_clr * wgtBL;
05423        
05424 #ifdef DEBUG
05425     if (ipixel == trace_pixel_ptr) {
05426         trace_opcBL = bot_opc;
05427         trace_rclrBL = bot_clr;
05428         
05429     }
05430 #endif
05431 ;
05432                 
05433         COUNT_RESAMPLE;
05434         if (acc_opc > min_opacity) {
05435             COUNT_COMPOSITE;
05436             iopc = ipixel->opcflt;
05437 #           ifndef SKIP_ERT
05438                 ASSERT(iopc < max_opacity);
05439 #           endif
05440             iopc_inv = (float)1. - iopc;
05441             ipixel->clrflt += acc_clr * iopc_inv;
05442             iopc += acc_opc * iopc_inv;
05443             ipixel->opcflt = iopc;
05444             
05445 #ifdef DEBUG
05446     if (ipixel == trace_pixel_ptr) {
05447 #ifdef COMPUTE_SHADOW_BUFFER
05448         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05449 #else
05450         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05451 #endif
05452         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05453         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05454         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05455         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05456         printf("  %3.0f %3.0f\n", iopc*255., 
05457                ipixel->clrflt);
05458         
05459         
05460     }
05461 #endif /* DEBUG */
05462 ;
05463 #           ifndef SKIP_ERT
05464                 if (iopc >= max_opacity) {
05465                     ASSERT(ipixel->lnk == 0);
05466                     ipixel->lnk = 1;
05467                 }
05468 #           endif
05469         };
05470                 break;
05471             default:
05472                 VPBug("illegal value for run state at end of scanline");
05473             }
05474         } else if (last_run_state == ALL_ZERO) {
05475             Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
05476         } else {
05477             Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
05478         }
05479 #endif /* UNROLL_RUN_LOOP */
05480 #endif /* SKIP_COMPOSITE */
05481 
05482 #ifndef UNROLL_RUN_LOOP
05483         run_state = final_run_state;
05484 #endif
05485         /* skip over any zero-length runs remaining in this scanline */
05486         if (j != 0 && ((run_state & 1) == 0)) {
05487             toprun_count = *topRLElen++;
05488             ASSERT(toprun_count == 0);
05489         }
05490         if (j != jcount && ((run_state & 2) == 0)) {
05491             botrun_count = *botRLElen++;
05492             ASSERT(botrun_count == 0);
05493         }
05494 
05495         /* go to next intermediate image scanline */
05496 #ifdef UNROLL_RUN_LOOP
05497         ipixel += intermediate_width - icount;
05498 #ifdef USE_SHADOW_BUFFER
05499         shadow_pixel += shadow_width - icount;
05500 #endif
05501 #else /* UNROLL_RUN_LOOP */
05502         ipixel += intermediate_width - (icount+1);
05503 #ifdef USE_SHADOW_BUFFER
05504         shadow_pixel += shadow_width - (icount+1);
05505 #endif
05506 #endif /* UNROLL_RUN_LOOP */
05507 
05508         Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
05509     } /* for j */
05510 
05511     /***************************************************************
05512      * Finish processing the voxel slice.
05513      ***************************************************************/
05514 
05515     GET_HIRES_TIME(vpc, t1);
05516     STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
05517 
05518     Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
05519 }
 

Powered by Plone

This site conforms to the following standards: