Back to index

radiance  4R0+20100331
Defines | Functions | Variables
mkillum3.c File Reference
#include "mkillum.h"
#include "paths.h"

Go to the source code of this file.

Defines

#define brt(col)   (.263*(col)[0]+.655*(col)[1]+.082*(col)[2])

Functions

void compinv (COLORV *rinv, COLORV *rp, int m)
void colorout (int p, COLORV *da, int n, int m, double mult, FILE *fp)
void fputnum (double d, FILE *fp)
void brightout (COLORV *da, int n, int m, double mult, FILE *fp)
void fputeol (FILE *fp)
void compavg (COLOR col, COLORV *da, int n)
char * dfname (struct illum_args *il, int c)
FILE * dfopen (struct illum_args *il, int c)
void printobj (char *mod, register OBJREC *obj)
FILE * dfopen (register struct illum_args *il, int c)
void flatout (struct illum_args *il, COLORV *da, int n, int m, FVECT u, FVECT v, FVECT w)
void roundout (struct illum_args *il, COLORV *da, int n, int m)
void illumout (register struct illum_args *il, OBJREC *ob)
void compavg (COLOR col, register COLORV *da, int n)
void compinv (register COLORV *rinv, register COLORV *rp, int m)
int average (register struct illum_args *il, COLORV *da, int n)
void fputeol (register FILE *fp)
void colorout (int p, register COLORV *da, int n, int m, double mult, FILE *fp)
void brightout (register COLORV *da, int n, int m, double mult, FILE *fp)

Variables

static const char RCSid [] = "$Id: mkillum3.c,v 2.12 2007/09/13 17:52:35 greg Exp $"
char DATORD [] = "RGB"
char DATSUF [] = ".dat"
char DSTSUF [] = ".dist"
char FNCFNM [] = "illum.cal"
static int colmcnt = 0

Define Documentation

#define brt (   col)    (.263*(col)[0]+.655*(col)[1]+.082*(col)[2])

Definition at line 11 of file mkillum3.c.


Function Documentation

int average ( register struct illum_args il,
COLORV da,
int  n 
)

Definition at line 284 of file mkillum3.c.

{
       compavg(il->col, da, n);    /* average */
       if (il->nsamps > 1) {
              il->col[0] /= (double)il->nsamps;
              il->col[1] /= (double)il->nsamps;
              il->col[2] /= (double)il->nsamps;
       }
                                   /* brighter than minimum? */
       return(brt(il->col) > il->minbrt+FTINY);
}

Here is the call graph for this function:

void brightout ( COLORV da,
int  n,
int  m,
double  mult,
FILE *  fp 
)

Here is the caller graph for this function:

void brightout ( register COLORV da,
int  n,
int  m,
double  mult,
FILE *  fp 
)

Definition at line 348 of file mkillum3.c.

{
       register int  i, j;

       for (i = 0; i < n; i++) {
              for (j = 0; j < m; j++) {
                     fputnum(mult*brt(da), fp);
                     da += 3;
              }
              fputnum(mult*brt(da-3*m), fp);     /* wrap phi */
       }
}

Here is the call graph for this function:

void colorout ( int  p,
COLORV da,
int  n,
int  m,
double  mult,
FILE *  fp 
)

Here is the caller graph for this function:

void colorout ( int  p,
register COLORV da,
int  n,
int  m,
double  mult,
FILE *  fp 
)

Definition at line 326 of file mkillum3.c.

{
       register int  i, j;

       for (i = 0; i < n; i++) {
              for (j = 0; j < m; j++) {
                     fputnum(mult*da[p], fp);
                     da += 3;
              }
              fputnum(mult*da[p-3*m], fp);       /* wrap phi */
       }
}

Here is the call graph for this function:

void compavg ( COLOR  col,
COLORV da,
int  n 
)

Here is the caller graph for this function:

void compavg ( COLOR  col,
register COLORV da,
int  n 
)

Definition at line 247 of file mkillum3.c.

{
       register int  i;

       setcolor(col, 0.0, 0.0, 0.0);
       i = n;
       while (i-- > 0) {
              addcolor(col, da);
              da += 3;
       }
       scalecolor(col, 1./(double)n);
}
void compinv ( COLORV rinv,
COLORV rp,
int  m 
)

Here is the caller graph for this function:

void compinv ( register COLORV rinv,
register COLORV rp,
int  m 
)

Definition at line 266 of file mkillum3.c.

{
       COLOR  avg;

       compavg(avg, rp, m);        /* row average */
       while (m-- > 0) {
              *rinv++ = 2.*avg[0] - *rp++;
              *rinv++ = 2.*avg[1] - *rp++;
              *rinv++ = 2.*avg[2] - *rp++;
       }
}

Here is the call graph for this function:

char * dfname ( struct illum_args il,
int  c 
)

Definition at line 60 of file mkillum3.c.

{
       char  fname[MAXSTR];
       register char  *s;

       s = strcpy(fname, il->datafile);
       s += strlen(s);
       if (c) *s++ = c;
       if (il->dfnum > 0) {
              sprintf(s, "%d", il->dfnum);
              s += strlen(s);
       }
       strcpy(s, DATSUF);
       return(getpath(fname, NULL, 0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* dfopen ( struct illum_args il,
int  c 
)

Here is the caller graph for this function:

FILE* dfopen ( register struct illum_args il,
int  c 
)

Definition at line 81 of file mkillum3.c.

{
       char  *fn;
       FILE  *fp;
                                   /* get a usable file name */
       for (fn = dfname(il, c);
                     !(il->flags & IL_DATCLB) && access(fn, F_OK) == 0;
                     fn = dfname(il, c))
              il->dfnum++;
                                   /* open it for writing */
       if ((fp = fopen(fn, "w")) == NULL) {
              sprintf(errmsg, "cannot open data file \"%s\"", fn);
              error(SYSTEM, errmsg);
       }
       return(fp);
}

Here is the call graph for this function:

void flatout ( struct illum_args il,
COLORV da,
int  n,
int  m,
FVECT  u,
FVECT  v,
FVECT  w 
)

Definition at line 103 of file mkillum3.c.

{
       COLORV  *Ninv;
       FILE  *dfp;
       int  i;

       if ((Ninv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL)
              error(SYSTEM, "out of memory in flatout");
       compinv(Ninv, da, m);
       if (il->flags & IL_COLDST) {
              printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame,
                            il->matname, DSTSUF);
              printf("\n9 red green blue");
              for (i = 0; i < 3; i++) {
                     dfp = dfopen(il, DATORD[i]);
                     fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
                                   1.+.5/n, .5/n, n+1,
                                   0., 2.*PI, m+1);
                     colorout(i, Ninv, 1, m, 1./il->nsamps/il->col[i], dfp);
                     colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp);
                     fputeol(dfp);
                     fclose(dfp);
                     printf(" %s", dfname(il, DATORD[i]));
              }
       } else {
              printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame,
                            il->matname, DSTSUF);
              printf("\n5 noneg");
              dfp = dfopen(il, 0);
              fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
                            1.+.5/n, .5/n, n+1,
                            0., 2.*PI, m+1);
              brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp);
              brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
              fputeol(dfp);
              fclose(dfp);
              printf(" %s", dfname(il, 0));
       }
       printf("\n\t%s il_alth il_azih", FNCFNM);
       printf("\n0\n9\n");
       printf("\t%f\t%f\t%f\n", u[0], u[1], u[2]);
       printf("\t%f\t%f\t%f\n", v[0], v[1], v[2]);
       printf("\t%f\t%f\t%f\n", w[0], w[1], w[2]);
       il->dfnum++;
       free((void *)Ninv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fputeol ( FILE *  fp)

Here is the caller graph for this function:

void fputeol ( register FILE *  fp)

Definition at line 316 of file mkillum3.c.

{
       putc('\n', fp);
       colmcnt = 0;
}
void fputnum ( double  d,
FILE *  fp 
)

Definition at line 304 of file mkillum3.c.

{
       if (colmcnt++ % 5 == 0)
              putc('\n', fp);
       fprintf(fp, " %11e", d);
}

Here is the caller graph for this function:

void illumout ( register struct illum_args il,
OBJREC ob 
)

Definition at line 216 of file mkillum3.c.

{
       double  cout[3];

       if (il->sampdens <= 0)
              printf("\n%s ", VOIDID);
       else
              printf("\n%s%s ", il->matname, DSTSUF);
       printf("%s %s", ofun[il->flags&IL_LIGHT?MAT_LIGHT:MAT_ILLUM].funame,
                     il->matname);
       if (il->flags & IL_LIGHT || !strcmp(il->altmat,VOIDID))
              printf("\n0");
       else
              printf("\n1 %s", il->altmat);
       if (il->flags & IL_COLAVG) {
              cout[0] = il->col[0];
              cout[1] = il->col[1];
              cout[2] = il->col[2];
       } else {
              cout[0] = cout[1] = cout[2] = brt(il->col);
       }
       printf("\n0\n3 %f %f %f\n", cout[0], cout[1], cout[2]);

       printobj(il->matname, ob);
}

Here is the call graph for this function:

void printobj ( char *  mod,
register OBJREC obj 
)

Definition at line 29 of file mkillum3.c.

{
       register int  i;

       if (issurface(obj->otype) && !strcmp(mod, VOIDID))
              return;              /* don't print void surfaces */
       printf("\n%s %s %s", mod, ofun[obj->otype].funame, obj->oname);
       printf("\n%d", obj->oargs.nsargs);
       for (i = 0; i < obj->oargs.nsargs; i++)
              printf(" %s", obj->oargs.sarg[i]);
#ifdef  IARGS
       printf("\n%d", obj->oargs.niargs);
       for (i = 0; i < obj->oargs.niargs; i++)
              printf(" %d", obj->oargs.iarg[i]);
#else
       printf("\n0");
#endif
       printf("\n%d", obj->oargs.nfargs);
       for (i = 0; i < obj->oargs.nfargs; i++) {
              if (i%3 == 0)
                     putchar('\n');
              printf(" %18.12g", obj->oargs.farg[i]);
       }
       putchar('\n');
}

Here is the call graph for this function:

void roundout ( struct illum_args il,
COLORV da,
int  n,
int  m 
)

Definition at line 160 of file mkillum3.c.

{
       COLORV  *Ninv, *Sinv;
       FILE  *dfp;
       int  i;

       if ((Ninv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL ||
                     (Sinv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL)
              error(SYSTEM, "out of memory in roundout");
       compinv(Ninv, da, m);
       compinv(Sinv, da+3*m*(n-1), m);
       if (il->flags & IL_COLDST) {
              printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame,
                            il->matname, DSTSUF);
              printf("\n9 red green blue");
              for (i = 0; i < 3; i++) {
                     dfp = dfopen(il, DATORD[i]);
                     fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
                                   1.+1./n, -1.-1./n, n+2,
                                   0., 2.*PI, m+1);
                     colorout(i, Ninv, 1, m, 1./il->nsamps/il->col[i], dfp);
                     colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp);
                     colorout(i, Sinv, 1, m, 1./il->nsamps/il->col[i], dfp);
                     fputeol(dfp);
                     fclose(dfp);
                     printf(" %s", dfname(il, DATORD[i]));
              }
       } else {
              printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame,
                            il->matname, DSTSUF);
              printf("\n5 noneg");
              dfp = dfopen(il, 0);
              fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
                            1.+1./n, -1.-1./n, n+2,
                            0., 2.*PI, m+1);
              brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp);
              brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
              brightout(Sinv, 1, m, 1./il->nsamps/brt(il->col), dfp);
              fputeol(dfp);
              fclose(dfp);
              printf(" %s", dfname(il, 0));
       }
       printf("\n\t%s il_alt il_azi", FNCFNM);
       printf("\n0\n0\n");
       il->dfnum++;
       free((void *)Ninv);
       free((void *)Sinv);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int colmcnt = 0 [static]

Definition at line 301 of file mkillum3.c.

char DATORD[] = "RGB"

Definition at line 13 of file mkillum3.c.

char DATSUF[] = ".dat"

Definition at line 14 of file mkillum3.c.

char DSTSUF[] = ".dist"

Definition at line 15 of file mkillum3.c.

char FNCFNM[] = "illum.cal"

Definition at line 16 of file mkillum3.c.

const char RCSid[] = "$Id: mkillum3.c,v 2.12 2007/09/13 17:52:35 greg Exp $" [static]

Definition at line 2 of file mkillum3.c.