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

Comparing ray/src/ot/writemesh.c (file contents):
Revision 2.1 by greg, Tue Mar 11 17:08:55 2003 UTC vs.
Revision 2.6 by greg, Thu Apr 29 14:36:49 2004 UTC

# Line 10 | Line 10 | static const char RCSid[] = "$Id$";
10   #include  "object.h"
11   #include  "mesh.h"
12  
13 + #ifdef putc_unlocked            /* avoid horrendous overhead of flockfile */
14 + #define putc    putc_unlocked
15 + #endif
16  
17 + static void putfullnode(OCTREE fn, FILE *fp);
18 + static void puttree(OCTREE ot, FILE *fp);
19 + static void putpatch(MESHPATCH *pp, FILE *fp);
20 +
21 +
22   static void
23 < putfullnode(fn, fp)             /* write out a full node */
24 < OCTREE  fn;
25 < FILE    *fp;
23 > putfullnode(            /* write out a full node */
24 >        OCTREE  fn,
25 >        FILE    *fp
26 > )
27   {
28          OBJECT  oset[MAXSET+1];
29          register int  i;
# Line 26 | Line 35 | FILE   *fp;
35  
36  
37   static void
38 < puttree(ot, fp)                 /* write octree to fp in pre-order form */
39 < register OCTREE ot;
40 < FILE            *fp;
38 > puttree(                        /* write octree to fp in pre-order form */
39 >        register OCTREE ot,
40 >        FILE            *fp
41 > )
42   {
43          
44          if (istree(ot)) {
# Line 48 | Line 58 | FILE           *fp;
58  
59  
60   static void
61 < putpatch(pp, fp)                        /* write out a mesh patch */
62 < register MESHPATCH      *pp;
63 < FILE                    *fp;
61 > putpatch(                       /* write out a mesh patch */
62 >        register MESHPATCH      *pp,
63 >        FILE                    *fp
64 > )
65   {
66          int     flags = MT_V;
67          int     i, j;
# Line 82 | Line 93 | FILE                   *fp;
93                  putint((long)pp->tri[i].v2, 1, fp);
94                  putint((long)pp->tri[i].v3, 1, fp);
95          }
96 +                                        /* local triangle material(s) */
97 +        if (pp->trimat == NULL) {
98 +                putint(1L, 2, fp);
99 +                putint((long)pp->solemat, 2, fp);
100 +        } else {
101 +                putint((long)pp->ntris, 2, fp);
102 +                for (i = 0; i < pp->ntris; i++)
103 +                        putint((long)pp->trimat[i], 2, fp);
104 +        }
105                                          /* joiner triangles */
106          putint((long)pp->nj1tris, 2, fp);
107          for (i = 0; i < pp->nj1tris; i++) {
108                  putint((long)pp->j1tri[i].v1j, 4, fp);
109                  putint((long)pp->j1tri[i].v2, 1, fp);
110                  putint((long)pp->j1tri[i].v3, 1, fp);
111 +                putint((long)pp->j1tri[i].mat, 2, fp);
112          }
113                                          /* double joiner triangles */
114          putint((long)pp->nj2tris, 2, fp);
# Line 95 | Line 116 | FILE                   *fp;
116                  putint((long)pp->j2tri[i].v1j, 4, fp);
117                  putint((long)pp->j2tri[i].v2j, 4, fp);
118                  putint((long)pp->j2tri[i].v3, 1, fp);
119 +                putint((long)pp->j2tri[i].mat, 2, fp);
120          }
121   }
122  
# Line 104 | Line 126 | writemesh(mp, fp)                      /* write mesh structures to fp */
126   MESH    *mp;
127   FILE    *fp;
128   {
129 +        char    *err;
130          char    sbuf[64];
131          int     i;
132 <                                        /* check that we have everything */
132 >                                        /* do we have everything? */
133          if ((mp->ldflags & (IO_SCENE|IO_TREE|IO_BOUNDS)) !=
134                          (IO_SCENE|IO_TREE|IO_BOUNDS))
135                  error(INTERNAL, "missing data in writemesh");
136 +                                        /* validate mesh data */
137 +        if ((err = checkmesh(mp)) != NULL)
138 +                error(USER, err);
139                                          /* write format number */
140          putint((long)(MESHMAGIC+sizeof(OBJECT)), 2, fp);
141                                          /* write boundaries */
# Line 125 | Line 151 | FILE   *fp;
151          }
152                                          /* write the octree */
153          puttree(mp->mcube.cutree, fp);
154 +                                        /* write the materials */
155 +        writescene(mp->mat0, mp->nmats, fp);
156                                          /* write the patches */
157          putint((long)mp->npatches, 4, fp);
158          for (i = 0; i < mp->npatches; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines