ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/writeoct.c
(Generate patch)

Comparing ray/src/ot/writeoct.c (file contents):
Revision 1.4 by greg, Wed Dec 12 22:46:35 1990 UTC vs.
Revision 2.4 by greg, Fri Mar 14 21:27:46 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1986 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  writeoct.c - routines for writing octree information to stdout.
6   *
# Line 16 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13  
14   #include  "object.h"
15  
16 < #include  "otypes.h"
16 > static int  oputint(), oputstr(), puttree();
17  
18  
19   writeoct(store, scene, ofn)             /* write octree structures to stdout */
# Line 25 | Line 22 | CUBE  *scene;
22   char  *ofn[];
23   {
24          char  sbuf[64];
25 <        register int  i;
25 >        int  i;
26                                          /* write format number */
27 <        putint((long)OCTMAGIC, 2);
27 >        oputint((long)(OCTMAGIC+sizeof(OBJECT)), 2);
28  
29          if (!(store & IO_BOUNDS))
30                  return;
31                                          /* write boundaries */
32          for (i = 0; i < 3; i++) {
33                  sprintf(sbuf, "%.12g", scene->cuorg[i]);
34 <                putstr(sbuf);
34 >                oputstr(sbuf);
35          }
36          sprintf(sbuf, "%.12g", scene->cusize);
37 <        putstr(sbuf);
37 >        oputstr(sbuf);
38                                          /* write object file names */
39          if (store & IO_FILES)
40                  for (i = 0; ofn[i] != NULL; i++)
41 <                        putstr(ofn[i]);
42 <        putstr("");
41 >                        oputstr(ofn[i]);
42 >        oputstr("");
43                                          /* write number of objects */
44 <        putint((long)nobjects, sizeof(OBJECT));
44 >        oputint((long)nobjects, sizeof(OBJECT));
45  
46          if (!(store & IO_TREE))
47                  return;
# Line 54 | Line 51 | char  *ofn[];
51          if (store & IO_FILES || !(store & IO_SCENE))
52                  return;
53                                          /* write the scene */
54 <        for (i = 0; i < NUMOTYPE; i++)
58 <                putstr(ofun[i].funame);
59 <        putstr("");
60 <        for (i = 0; i < nobjects; i++)
61 <                putobj(objptr(i));
62 <        putobj(NULL);
54 >        writescene(0, nobjects, stdout);
55   }
56  
57  
58   static
59 < putstr(s)                       /* write null-terminated string to stdout */
59 > oputstr(s)                      /* write null-terminated string to stdout */
60   register char  *s;
61   {
62 <        do
71 <                putc(*s, stdout);
72 <        while (*s++);
62 >        putstr(s, stdout);
63          if (ferror(stdout))
64                  error(SYSTEM, "write error in putstr");
65   }
# Line 84 | Line 74 | OCTREE  fn;
74  
75          objset(oset, fn);
76          for (i = 0; i <= oset[0]; i++)
77 <                putint((long)oset[i], sizeof(OBJECT));
77 >                oputint((long)oset[i], sizeof(OBJECT));
78   }
79  
80  
81   static
82 < putint(i, siz)                  /* write a siz-byte integer to stdout */
82 > oputint(i, siz)                 /* write a siz-byte integer to stdout */
83   register long  i;
84   register int  siz;
85   {
86 <        while (siz--)
97 <                putc(i>>(siz<<3) & 0xff, stdout);
86 >        putint(i, siz, stdout);
87          if (ferror(stdout))
88                  error(SYSTEM, "write error in putint");
89   }
90  
91  
92   static
93 < putflt(f)                       /* put out floating point number */
93 > oputflt(f)                      /* put out floating point number */
94   double  f;
95   {
96 <        extern double  frexp();
97 <        int  e;
98 <
110 <        putint((long)(frexp(f,&e)*0x7fffffff), 4);
111 <        putint((long)e, 1);
96 >        putflt(f, stdout);
97 >        if (ferror(stdout))
98 >                error(SYSTEM, "write error in putflt");
99   }
100  
101  
# Line 127 | Line 114 | register OCTREE  ot;
114                  putfullnode(ot);                /* write fullnode */
115          } else
116                  putc(OT_EMPTY, stdout);         /* indicate empty */
130 }
131
132
133 static
134 putobj(o)                       /* write out object */
135 register OBJREC  *o;
136 {
137        register int  i;
138
139        if (o == NULL) {                /* terminator */
140                putint(-1L, 1);
141                return;
142        }
143        putint((long)o->otype, 1);
144        putint((long)o->omod, sizeof(OBJECT));
145        putstr(o->oname);
146        putint((long)o->oargs.nsargs, 2);
147        for (i = 0; i < o->oargs.nsargs; i++)
148                putstr(o->oargs.sarg[i]);
149 #ifdef  IARGS
150        putint((long)o->oargs.niargs, 2);
151        for (i = 0; i < o->oargs.niargs; i++)
152                putint((long)o->oargs.iarg[i], 4);
153 #endif
154        putint((long)o->oargs.nfargs, 2);
155        for (i = 0; i < o->oargs.nfargs; i++)
156                putflt(o->oargs.farg[i]);
117   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines