Back to index

radiance  4R0+20100331
Functions | Variables
octree.c File Reference
#include "copyright.h"
#include "standard.h"
#include "octree.h"

Go to the source code of this file.

Functions

OCTREE octalloc ()
void octfree (OCTREE ot)
void octdone ()
OCTREE combine (OCTREE ot)
void culocate (CUBE *cu, FVECT pt)
int incube (CUBE *cu, FVECT pt)

Variables

static const char RCSid [] = "$Id: octree.c,v 2.8 2009/11/01 04:41:55 greg Exp $"
OCTREEoctblock [MAXOBLK]
static OCTREE ofreelist = EMPTY
static OCTREE treetop = 0

Function Documentation

Definition at line 74 of file octree.c.

{
       int  i;
       OCTREE  ores;

       if (!istree(ot))     /* not a tree */
              return(ot);
       ores = octkid(ot, 0) = combine(octkid(ot, 0));
       for (i = 1; i < 8; i++)
              if ((octkid(ot, i) = combine(octkid(ot, i))) != ores)
                     ores = ot;
       if (!istree(ores)) { /* all were identical leaves */
              octkid(ot, 0) = ofreelist;
              ofreelist = ot;
       }
       return(ores);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void culocate ( CUBE cu,
FVECT  pt 
)

Definition at line 95 of file octree.c.

{
       int  i;
       int  branch;

       while (istree(cu->cutree)) {
              cu->cusize *= 0.5;
              branch = 0;
              for (i = 0; i < 3; i++)
                     if (cu->cuorg[i] + cu->cusize <= pt[i]) {
                            cu->cuorg[i] += cu->cusize;
                            branch |= 1 << i;
                     }
              cu->cutree = octkid(cu->cutree, branch);
       }
}

Here is the call graph for this function:

int incube ( CUBE cu,
FVECT  pt 
)

Definition at line 116 of file octree.c.

{
       if (cu->cuorg[0] > pt[0] || pt[0] >= cu->cuorg[0] + cu->cusize)
              return(0);
       if (cu->cuorg[1] > pt[1] || pt[1] >= cu->cuorg[1] + cu->cusize)
              return(0);
       if (cu->cuorg[2] > pt[2] || pt[2] >= cu->cuorg[2] + cu->cusize)
              return(0);
       return(1);
}

Here is the caller graph for this function:

OCTREE octalloc ( void  )

Definition at line 20 of file octree.c.

{
       OCTREE  freet;

       if ((freet = ofreelist) != EMPTY) {
              ofreelist = octkid(freet, 0);
              return(freet);
       }
       freet = treetop;
       if (octti(freet) == 0) {
              errno = 0;
              if (octbi(freet) >= MAXOBLK)
                     return(EMPTY);
              if ((octblock[octbi(freet)] = (OCTREE *)malloc(
                            (unsigned)OCTBLKSIZ*8*sizeof(OCTREE))) == NULL)
                     return(EMPTY);
       }
       treetop++;
       return(freet);
}

Here is the caller graph for this function:

void octdone ( void  )

Definition at line 58 of file octree.c.

{
       int    i;

       for (i = 0; i < MAXOBLK; i++) {
              if (octblock[i] == NULL)
                     break;
              free((void *)octblock[i]);
              octblock[i] = NULL;
       }
       ofreelist = EMPTY;
       treetop = 0;
}

Here is the caller graph for this function:

void octfree ( OCTREE  ot)

Definition at line 43 of file octree.c.

{
       int  i;

       if (!istree(ot))
              return;
       for (i = 0; i < 8; i++)
              octfree(octkid(ot, i));
       octkid(ot, 0) = ofreelist;
       ofreelist = ot;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 14 of file octree.c.

OCTREE ofreelist = EMPTY [static]

Definition at line 15 of file octree.c.

const char RCSid[] = "$Id: octree.c,v 2.8 2009/11/01 04:41:55 greg Exp $" [static]

Definition at line 2 of file octree.c.

OCTREE treetop = 0 [static]

Definition at line 16 of file octree.c.