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 2.3 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 2.7 by greg, Tue Nov 9 16:09:20 2004 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   *  writeoct.c - routines for writing octree information to stdout.
# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   #include  "standard.h"
11  
12   #include  "octree.h"
13
13   #include  "object.h"
14 + #include  "oconv.h"
15  
16 < #include  "otypes.h"
16 > #ifdef putc_unlocked            /* avoid horrendous overhead of flockfile */
17 > #undef putc
18 > #define putc    putc_unlocked
19 > #endif
20  
21 < static int  oputint(), oputstr(), puttree(), putobj();
21 > static void oputstr(char *s);
22 > static void putfullnode(OCTREE fn);
23 > static void oputint(long i, int siz);
24 > static void oputflt(double f);
25 > static void puttree(OCTREE ot);
26  
27  
28 < writeoct(store, scene, ofn)             /* write octree structures to stdout */
29 < int  store;
30 < CUBE  *scene;
31 < char  *ofn[];
28 > void
29 > writeoct(               /* write octree structures to stdout */
30 >        int  store,
31 >        CUBE  *scene,
32 >        char  *ofn[]
33 > )
34   {
35          char  sbuf[64];
36 <        register int  i;
36 >        int  i;
37                                          /* write format number */
38          oputint((long)(OCTMAGIC+sizeof(OBJECT)), 2);
39  
# Line 53 | Line 62 | char  *ofn[];
62          if (store & IO_FILES || !(store & IO_SCENE))
63                  return;
64                                          /* write the scene */
65 <        for (i = 0; i < NUMOTYPE; i++)
57 <                oputstr(ofun[i].funame);
58 <        oputstr("");
59 <        for (i = 0; i < nobjects; i++)
60 <                putobj(objptr(i));
61 <        putobj(NULL);
65 >        writescene(0, nobjects, stdout);
66   }
67  
68  
69 < static
70 < oputstr(s)                      /* write null-terminated string to stdout */
71 < register char  *s;
69 > static void
70 > oputstr(                        /* write null-terminated string to stdout */
71 >        register char  *s
72 > )
73   {
74          putstr(s, stdout);
75          if (ferror(stdout))
# Line 72 | Line 77 | register char  *s;
77   }
78  
79  
80 < static
81 < putfullnode(fn)                 /* write out a full node */
82 < OCTREE  fn;
80 > static void
81 > putfullnode(                    /* write out a full node */
82 >        OCTREE  fn
83 > )
84   {
85          OBJECT  oset[MAXSET+1];
86          register int  i;
# Line 85 | Line 91 | OCTREE  fn;
91   }
92  
93  
94 < static
95 < oputint(i, siz)                 /* write a siz-byte integer to stdout */
96 < register long  i;
97 < register int  siz;
94 > static void
95 > oputint(                        /* write a siz-byte integer to stdout */
96 >        register long  i,
97 >        register int  siz
98 > )
99   {
100          putint(i, siz, stdout);
101          if (ferror(stdout))
# Line 96 | Line 103 | register int  siz;
103   }
104  
105  
106 < static
107 < oputflt(f)                      /* put out floating point number */
108 < double  f;
106 > static void
107 > oputflt(                        /* put out floating point number */
108 >        double  f
109 > )
110   {
111          putflt(f, stdout);
112          if (ferror(stdout))
# Line 106 | Line 114 | double  f;
114   }
115  
116  
117 < static
118 < puttree(ot)                     /* write octree to stdout in pre-order form */
119 < register OCTREE  ot;
117 > static void
118 > puttree(                        /* write octree to stdout in pre-order form */
119 >        register OCTREE  ot
120 > )
121   {
122          register int  i;
123          
# Line 121 | Line 130 | register OCTREE  ot;
130                  putfullnode(ot);                /* write fullnode */
131          } else
132                  putc(OT_EMPTY, stdout);         /* indicate empty */
124 }
125
126
127 static
128 putobj(o)                       /* write out object */
129 register OBJREC  *o;
130 {
131        register int  i;
132
133        if (o == NULL) {                /* terminator */
134                oputint(-1L, 1);
135                return;
136        }
137        oputint((long)o->otype, 1);
138        oputint((long)o->omod, sizeof(OBJECT));
139        oputstr(o->oname);
140        oputint((long)o->oargs.nsargs, 2);
141        for (i = 0; i < o->oargs.nsargs; i++)
142                oputstr(o->oargs.sarg[i]);
143 #ifdef  IARGS
144        oputint((long)o->oargs.niargs, 2);
145        for (i = 0; i < o->oargs.niargs; i++)
146                oputint((long)o->oargs.iarg[i], 4);
147 #endif
148        oputint((long)o->oargs.nfargs, 2);
149        for (i = 0; i < o->oargs.nfargs; i++)
150                oputflt(o->oargs.farg[i]);
133   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines