Referência do Arquivo /home/carolina/workspace/spvolren_cpu/preint.c

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "preint.h"

Vá para o código-fonte deste arquivo.

Definições e Macros

#define MIN_INT_STEPS   20
#define ADD_LOOKUP_STEPS   1
#define VAL(s, i)   (g.data[(int)(s) * 4 + i])
#define LERP(x, y, z)   ((x) * (z) + (y) * (1.0 - (z)))

Funções

void calcPreIntTable (int imgsize, float thickness, unsigned char *data, unsigned char *table)

Variáveis

struct {
   unsigned char *   data
g

Definições e macros

#define ADD_LOOKUP_STEPS   1

Definição na linha 10 do arquivo preint.c.

#define LERP ( x,
y,
z   )     ((x) * (z) + (y) * (1.0 - (z)))

Definição na linha 13 do arquivo preint.c.

#define MIN_INT_STEPS   20

Definição na linha 9 do arquivo preint.c.

#define VAL ( s,
 )     (g.data[(int)(s) * 4 + i])

Definição na linha 12 do arquivo preint.c.


Funções

void calcPreIntTable ( int  imgsize,
float  thickness,
unsigned char *  data,
unsigned char *  table 
)

Definição na linha 19 do arquivo preint.c.

00021 {
00022         int sb, sf, i, j, n, base1, base2, offset;
00023         double stepWidth, s, temp;
00024         double rgba[4], rgbac[4];
00025 
00026         g.data = data;
00027 
00028         for (sb = 0; sb < imgsize; sb++) {
00029                 for (sf = 0; sf <= sb; sf++) {
00030                         n = MIN_INT_STEPS + ADD_LOOKUP_STEPS * abs(sb - sf);
00031 
00032                         stepWidth = thickness/n;
00033                         memset(rgba, 0, sizeof(rgba));
00034 
00035                         for (i = 0; i < n; i++) {
00036                                 s = sf + (sb - sf) * (double)i/n;
00037                                 offset = sf != sb;
00038 
00039 #if 0
00040                                 fprintf(stderr, "sb = %i; sf = %i; n = %i; s = %lf\n",
00041                                                 sb, sf, n, s);
00042 #endif
00043 
00044                                 rgbac[3] = stepWidth/255.0 * 
00045                                                    LERP(VAL(s, 3), VAL(s + offset, 3), s - floor(s));
00046 #if 0
00047                                 fprintf(stderr, "%f\n", LERP(VAL(s, 3), VAL(s + 1, 3), s -
00048                                 floor(s))/255.0);
00049 #endif
00050                                 
00051                                 /* Standard optical model: RGB densities are multiplied with
00052                                  * opacity density */ 
00053                                 temp = exp(-rgba[3]) * rgbac[3]/255.0;
00054 #if 0
00055                                 fprintf(stderr, "%f %f\n", exp(-rgba[3]), rgba[3]);
00056 #endif
00057                                 for (j = 0; j < 3; j++) {
00058                                         rgbac[j] = temp * 
00059                                                            LERP(VAL(s, j), VAL(s + offset, j), 
00060                                                                         s - floor(s));
00061                                         rgba[j] += rgbac[j];
00062                                 }
00063                                 rgba[3] += rgbac[3];
00064                         } 
00065                         
00066                         base1 = (sb * imgsize + sf) * 4;
00067                         base2 = (sf * imgsize + sb) * 4;
00068                         for (i = 0; i < 3; i ++) {
00069                                 if (rgba[i] > 1.0) {
00070                                         rgba[i] = 1.0;
00071                                 }
00072                                 table[base1++] = table[base2++] = (unsigned char)(rgba[i] * 255.99);
00073                         }
00074                         table[base1] = table[base2] = (unsigned char)((1.0 - exp(-rgba[3])) * 255.99);
00075                 }
00076         }
00077 }


Variáveis

unsigned char* data

Definição na linha 16 do arquivo preint.c.

struct { ... } g [static]
 Todos Estruturas de Dados Arquivos Funções Variáveis Definições de Tipos Enumerações Valores enumerados Definições e Macros

Gerado em Sat Dec 12 01:59:33 2009 para Carolina Simões Gomes (RA042533). Estudo de um framework para Raycasting em GPU por  doxygen 1.6.1