2017-04-26 17:20:15 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Copyright (c) 1994 Stanford University */
|
|
|
|
/* */
|
|
|
|
/* All rights reserved. */
|
|
|
|
/* */
|
|
|
|
/* Permission is given to use, copy, and modify this software for any */
|
|
|
|
/* non-commercial purpose as long as this copyright notice is not */
|
|
|
|
/* removed. All other uses, including redistribution in whole or in */
|
|
|
|
/* part, are forbidden without prior written permission. */
|
|
|
|
/* */
|
|
|
|
/* This software is provided with absolutely no warranty and no */
|
|
|
|
/* support. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME
|
|
|
|
* huprn.c
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* This file contains routines that walk and print most all data
|
|
|
|
* structures relating to the HU grid.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2017-04-26 17:20:15 +02:00
|
|
|
#include "rt.h"
|
|
|
|
|
|
|
|
VOID prn_voxel(VOXEL *v)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
ELEMENT *pe, **pepa;
|
|
|
|
GRID *g;
|
|
|
|
INT i;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, " Print Voxel id = %ld \n", v->id);
|
|
|
|
fprintf(stderr, " celltype %d \n", v->celltype);
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
if (v->celltype == GSM_VOXEL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, " gsm_voxel \n");
|
|
|
|
fprintf(stderr, " primElement index list:\n");
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
pepa = (ELEMENT**)v->cell;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
for (i=0; i < v->numelements; i++)
|
|
|
|
{
|
|
|
|
pe = pepa[i];
|
|
|
|
fprintf(stderr, " %ld \n", pe->index);
|
|
|
|
}
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
if (v->celltype == GSM_GRID)
|
|
|
|
{
|
|
|
|
g = (GRID *)v->cell;
|
|
|
|
prn_grid(g);
|
|
|
|
fprintf(stderr, " gsm_grid id %ld \n", g->id);
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, " End Voxel \n");
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID prn_grid(GRID *g)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
INT n;
|
|
|
|
GRID *ng;
|
|
|
|
VOXEL *v;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, " Print Grid %ld \n", g->id);
|
|
|
|
fprintf(stderr, " num_prims = %ld \n", g->num_prims);
|
|
|
|
fprintf(stderr, " indx_inc[0,1,2] = %ld, %ld, %ld \n", g->indx_inc[0], g->indx_inc[1], g->indx_inc[2]);
|
|
|
|
fprintf(stderr, " num_buckets = %ld \n", g->num_buckets);
|
|
|
|
fprintf(stderr, " min[0,1,2] = %lf, %lf, %lf \n", g->min[0], g->min[1], g->min[2] );
|
|
|
|
fprintf(stderr, " cellsize[0,1,2] = %lf, %lf, %lf \n", g->cellsize[0], g->cellsize[1], g->cellsize[2]);
|
|
|
|
fprintf(stderr, " subdiv_level = %ld \n", g->subdiv_level);
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
if (g->next != NULL)
|
|
|
|
{
|
|
|
|
ng = g->next;
|
|
|
|
fprintf(stderr, " next grid id %ld \n", ng->id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf(stderr, " next grid id NULL \n");
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, " Voxel List \n");
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
n = g->indx_inc[1] * g->indx_inc[2];
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
if (lookup_emptycells(i, g) == EMPTY)
|
|
|
|
fprintf(stderr, " Voxel %ld is empty. \n", i);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v = lookup_hashtable(i, g);
|
|
|
|
prn_voxel(v);
|
|
|
|
}
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, " End Grid \n");
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID prn_ray(RAY *r)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
RAYINFO *ri;
|
|
|
|
GRID *g;
|
|
|
|
|
|
|
|
fprintf(stderr, " Print Ray id %ld \n", r->id );
|
|
|
|
fprintf(stderr, " origin: ( %lf, %lf, %lf ) \n", r->P[0], r->P[1], r->P[2]);
|
|
|
|
fprintf(stderr, " direction: ( %lf, %lf, %lf ) \n", r->D[0], r->D[1], r->D[2] );
|
|
|
|
fprintf(stderr, " indx_inc3D[0,1,2] = [ %ld, %ld, %ld ] \n", r->indx_inc3D[0],r->indx_inc3D[1],r->indx_inc3D[2] );
|
|
|
|
fprintf(stderr, " ri_indx = %ld \n", r->ri_indx);
|
|
|
|
fprintf(stderr, " rayinfo: \n");
|
|
|
|
|
|
|
|
ri = r->ri;
|
|
|
|
g = ri->grid;
|
|
|
|
|
|
|
|
fprintf(stderr, " ray is in grid %ld \n", g->id );
|
|
|
|
fprintf(stderr, " d[0,1,2] = [ %lf, %lf, %lf ] \n", ri->d[0], ri->d[1], ri->d[2]);
|
|
|
|
fprintf(stderr, " entry_plane %ld \n", ri->entry_plane );
|
|
|
|
fprintf(stderr, " t_in = %lf \n", ri->t_in );
|
|
|
|
fprintf(stderr, " exit_plane %ld \n", ri->exit_plane );
|
|
|
|
fprintf(stderr, " t_out = %lf \n", ri->t_out );
|
|
|
|
fprintf(stderr, " delta[0,1,2] = [ %lf, %lf, %lf ] \n", ri->delta[0], ri->delta[1], ri->delta[2]);
|
|
|
|
fprintf(stderr, " index3D[0,1,2] = [ %ld, %ld, %ld ] \n", ri->index3D[0], ri->index3D[1], ri->index3D[2]);
|
|
|
|
fprintf(stderr, " index1D = %ld \n", ri->index1D );
|
|
|
|
fprintf(stderr, " indx_inc1D[0,1,2] = [ %ld, %ld, %ld ] \n", ri->indx_inc1D[0], ri->indx_inc1D[1], ri->indx_inc1D[2]);
|
|
|
|
fprintf(stderr, " End Ray \n");
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID prn_PrimElem(ELEMENT *p)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
BBOX b;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: prn_PrimElem: Null pointer.\n", ProgName);
|
|
|
|
exit(-1);
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, "PrimElem: index %ld ptr %p, PrimObj index %ld ptr %p \n",
|
|
|
|
p->index, p, p->parent->index, p->parent);
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
b = p->bv;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, " BBox: ( %lf, %lf, %lf ) -> \n ( %lf, %lf, %lf ) \n",
|
|
|
|
b.dnear[0],b.dnear[1],b.dnear[2],b.dfar[0],b.dfar[1],b.dfar[2] );
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID prn_bintree_node(BTNODE *b)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
INT i;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, "Bintree node: \n");
|
|
|
|
fprintf(stderr, " indecies of cell: ( %ld, %ld, %ld ) \n", b->i[0], b->i[1], b->i[2]);
|
|
|
|
fprintf(stderr, " gridsizes: ( %ld, %ld, %ld ) \n", b->n[0], b->n[1], b->n[2]);
|
|
|
|
fprintf(stderr, " minimum point ( %lf, %lf, %lf ) \n", b->p[0], b->p[1], b->p[2]);
|
|
|
|
fprintf(stderr, " subdiv axis %ld \n", b->axis);
|
|
|
|
fprintf(stderr, " number of primitives %ld \n", b->nprims);
|
|
|
|
fprintf(stderr, " Primitive element list: \n");
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
if (b->nprims > 0)
|
|
|
|
for (i = 0; i < b->nprims; i++)
|
|
|
|
{
|
|
|
|
fprintf(stderr, " %ld", b->pe[i]->index);
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
if (i % 8 == 7)
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
fprintf(stderr, "\n End of bintree node \n");
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID prn_bintree_leaves(BTNODE *root)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
BTNODE *b;
|
2017-04-26 17:20:15 +02:00
|
|
|
|
2017-04-26 18:03:02 +02:00
|
|
|
b = root;
|
|
|
|
if (b->axis == -1)
|
|
|
|
prn_bintree_node(b);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prn_bintree_leaves(b->btn[0]);
|
|
|
|
prn_bintree_leaves(b->btn[1]);
|
|
|
|
}
|
|
|
|
}
|
2017-04-26 17:20:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
VOID prn_pepa_prim_list(ELEMENT **pepa, INT nprims)
|
2017-04-26 18:03:02 +02:00
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
if (nprims > 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < nprims; i++)
|
|
|
|
{
|
|
|
|
fprintf(stderr, " %ld", pepa[i]->index);
|
|
|
|
|
|
|
|
if (i % 8 == 7)
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|