--- ray/src/ot/writeoct.c 2003/02/22 02:07:26 2.3 +++ ray/src/ot/writeoct.c 2004/03/27 12:41:45 2.5 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: writeoct.c,v 2.3 2003/02/22 02:07:26 greg Exp $"; +static const char RCSid[] = "$Id: writeoct.c,v 2.5 2004/03/27 12:41:45 schorsch Exp $"; #endif /* * writeoct.c - routines for writing octree information to stdout. @@ -10,21 +10,26 @@ static const char RCSid[] = "$Id: writeoct.c,v 2.3 200 #include "standard.h" #include "octree.h" - #include "object.h" +#include "oconv.h" -#include "otypes.h" -static int oputint(), oputstr(), puttree(), putobj(); +static void oputstr(char *s); +static void putfullnode(OCTREE fn); +static void oputint(long i, int siz); +static void oputflt(double f); +static void puttree(OCTREE ot); -writeoct(store, scene, ofn) /* write octree structures to stdout */ -int store; -CUBE *scene; -char *ofn[]; +void +writeoct( /* write octree structures to stdout */ + int store, + CUBE *scene, + char *ofn[] +) { char sbuf[64]; - register int i; + int i; /* write format number */ oputint((long)(OCTMAGIC+sizeof(OBJECT)), 2); @@ -53,18 +58,14 @@ char *ofn[]; if (store & IO_FILES || !(store & IO_SCENE)) return; /* write the scene */ - for (i = 0; i < NUMOTYPE; i++) - oputstr(ofun[i].funame); - oputstr(""); - for (i = 0; i < nobjects; i++) - putobj(objptr(i)); - putobj(NULL); + writescene(0, nobjects, stdout); } -static -oputstr(s) /* write null-terminated string to stdout */ -register char *s; +static void +oputstr( /* write null-terminated string to stdout */ + register char *s +) { putstr(s, stdout); if (ferror(stdout)) @@ -72,9 +73,10 @@ register char *s; } -static -putfullnode(fn) /* write out a full node */ -OCTREE fn; +static void +putfullnode( /* write out a full node */ + OCTREE fn +) { OBJECT oset[MAXSET+1]; register int i; @@ -85,10 +87,11 @@ OCTREE fn; } -static -oputint(i, siz) /* write a siz-byte integer to stdout */ -register long i; -register int siz; +static void +oputint( /* write a siz-byte integer to stdout */ + register long i, + register int siz +) { putint(i, siz, stdout); if (ferror(stdout)) @@ -96,9 +99,10 @@ register int siz; } -static -oputflt(f) /* put out floating point number */ -double f; +static void +oputflt( /* put out floating point number */ + double f +) { putflt(f, stdout); if (ferror(stdout)) @@ -106,9 +110,10 @@ double f; } -static -puttree(ot) /* write octree to stdout in pre-order form */ -register OCTREE ot; +static void +puttree( /* write octree to stdout in pre-order form */ + register OCTREE ot +) { register int i; @@ -121,31 +126,4 @@ register OCTREE ot; putfullnode(ot); /* write fullnode */ } else putc(OT_EMPTY, stdout); /* indicate empty */ -} - - -static -putobj(o) /* write out object */ -register OBJREC *o; -{ - register int i; - - if (o == NULL) { /* terminator */ - oputint(-1L, 1); - return; - } - oputint((long)o->otype, 1); - oputint((long)o->omod, sizeof(OBJECT)); - oputstr(o->oname); - oputint((long)o->oargs.nsargs, 2); - for (i = 0; i < o->oargs.nsargs; i++) - oputstr(o->oargs.sarg[i]); -#ifdef IARGS - oputint((long)o->oargs.niargs, 2); - for (i = 0; i < o->oargs.niargs; i++) - oputint((long)o->oargs.iarg[i], 4); -#endif - oputint((long)o->oargs.nfargs, 2); - for (i = 0; i < o->oargs.nfargs; i++) - oputflt(o->oargs.farg[i]); }