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. |
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 |
> |
#define putc putc_unlocked |
18 |
> |
#endif |
19 |
|
|
20 |
< |
static int oputint(), oputstr(), puttree(), putobj(); |
20 |
> |
static void oputstr(char *s); |
21 |
> |
static void putfullnode(OCTREE fn); |
22 |
> |
static void oputint(long i, int siz); |
23 |
> |
static void oputflt(double f); |
24 |
> |
static void puttree(OCTREE ot); |
25 |
|
|
26 |
|
|
27 |
< |
writeoct(store, scene, ofn) /* write octree structures to stdout */ |
28 |
< |
int store; |
29 |
< |
CUBE *scene; |
30 |
< |
char *ofn[]; |
27 |
> |
void |
28 |
> |
writeoct( /* write octree structures to stdout */ |
29 |
> |
int store, |
30 |
> |
CUBE *scene, |
31 |
> |
char *ofn[] |
32 |
> |
) |
33 |
|
{ |
34 |
|
char sbuf[64]; |
35 |
< |
register int i; |
35 |
> |
int i; |
36 |
|
/* write format number */ |
37 |
|
oputint((long)(OCTMAGIC+sizeof(OBJECT)), 2); |
38 |
|
|
61 |
|
if (store & IO_FILES || !(store & IO_SCENE)) |
62 |
|
return; |
63 |
|
/* write the scene */ |
64 |
< |
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); |
64 |
> |
writescene(0, nobjects, stdout); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
< |
static |
69 |
< |
oputstr(s) /* write null-terminated string to stdout */ |
70 |
< |
register char *s; |
68 |
> |
static void |
69 |
> |
oputstr( /* write null-terminated string to stdout */ |
70 |
> |
register char *s |
71 |
> |
) |
72 |
|
{ |
73 |
|
putstr(s, stdout); |
74 |
|
if (ferror(stdout)) |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
< |
static |
80 |
< |
putfullnode(fn) /* write out a full node */ |
81 |
< |
OCTREE fn; |
79 |
> |
static void |
80 |
> |
putfullnode( /* write out a full node */ |
81 |
> |
OCTREE fn |
82 |
> |
) |
83 |
|
{ |
84 |
|
OBJECT oset[MAXSET+1]; |
85 |
|
register int i; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
< |
static |
94 |
< |
oputint(i, siz) /* write a siz-byte integer to stdout */ |
95 |
< |
register long i; |
96 |
< |
register int siz; |
93 |
> |
static void |
94 |
> |
oputint( /* write a siz-byte integer to stdout */ |
95 |
> |
register long i, |
96 |
> |
register int siz |
97 |
> |
) |
98 |
|
{ |
99 |
|
putint(i, siz, stdout); |
100 |
|
if (ferror(stdout)) |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
< |
static |
106 |
< |
oputflt(f) /* put out floating point number */ |
107 |
< |
double f; |
105 |
> |
static void |
106 |
> |
oputflt( /* put out floating point number */ |
107 |
> |
double f |
108 |
> |
) |
109 |
|
{ |
110 |
|
putflt(f, stdout); |
111 |
|
if (ferror(stdout)) |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
< |
static |
117 |
< |
puttree(ot) /* write octree to stdout in pre-order form */ |
118 |
< |
register OCTREE ot; |
116 |
> |
static void |
117 |
> |
puttree( /* write octree to stdout in pre-order form */ |
118 |
> |
register OCTREE ot |
119 |
> |
) |
120 |
|
{ |
121 |
|
register int i; |
122 |
|
|
129 |
|
putfullnode(ot); /* write fullnode */ |
130 |
|
} else |
131 |
|
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]); |
132 |
|
} |