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

Comparing ray/src/common/readmesh.c (file contents):
Revision 2.2 by greg, Fri Mar 14 21:27:46 2003 UTC vs.
Revision 2.13 by greg, Tue Sep 14 02:53:50 2004 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   *  Routines for reading a compiled mesh from a file
6   */
7  
8 + #include  <time.h>
9 +
10 + #include  "platform.h"
11   #include  "standard.h"
12   #include  "octree.h"
13   #include  "object.h"
14   #include  "mesh.h"
15 + #include  "resolu.h"
16  
17 + #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */
18 + #undef getc
19 + #define getc    getc_unlocked
20 + #endif
21 +
22   static char     *meshfn;        /* input file name */
23   static FILE     *meshfp;        /* mesh file pointer */
24   static int      objsize;        /* sizeof(OBJECT) from writer */
# Line 73 | Line 82 | gettree()                              /* get a pre-ordered octree */
82          register int  i;
83          
84          switch (getc(meshfp)) {
85 <        case OT_EMPTY:
86 <                return(EMPTY);
87 <        case OT_FULL:
88 <                return(getfullnode());
89 <        case OT_TREE:
90 <                if ((ot = octalloc()) == EMPTY)
91 <                        mesherror(SYSTEM, "out of tree space in readmesh");
92 <                for (i = 0; i < 8; i++)
93 <                        octkid(ot, i) = gettree();
94 <                return(ot);
95 <        case EOF:
96 <                mesherror(USER, "truncated mesh octree");
97 <        default:
98 <                mesherror(USER, "damaged mesh octree");
85 >                case OT_EMPTY:
86 >                        return(EMPTY);
87 >                case OT_FULL:
88 >                        return(getfullnode());
89 >                case OT_TREE:
90 >                        if ((ot = octalloc()) == EMPTY)
91 >                                mesherror(SYSTEM, "out of tree space in readmesh");
92 >                        for (i = 0; i < 8; i++)
93 >                                octkid(ot, i) = gettree();
94 >                        return(ot);
95 >                case EOF:
96 >                        mesherror(USER, "truncated mesh octree");
97 >                default:
98 >                        mesherror(USER, "damaged mesh octree");
99          }
100 +        return (OCTREE)NULL; /* pro forma return */
101   }
102  
103  
# Line 130 | Line 140 | register MESHPATCH     *pp;
140          pp->nverts = mgetint(2);
141          if (pp->nverts <= 0 || pp->nverts > 256)
142                  mesherror(USER, "bad number of patch vertices");
143 <        pp->xyz = (uint4 (*)[3])malloc(pp->nverts*3*sizeof(uint4));
143 >        pp->xyz = (uint32 (*)[3])malloc(pp->nverts*3*sizeof(uint32));
144          if (pp->xyz == NULL)
145                  goto nomem;
146          if (flags & MT_N) {
147 <                pp->norm = (int4 *)calloc(pp->nverts, sizeof(int4));
147 >                pp->norm = (int32 *)calloc(pp->nverts, sizeof(int32));
148                  if (pp->norm == NULL)
149                          goto nomem;
150          } else
151                  pp->norm = NULL;
152          if (flags & MT_UV) {
153 <                pp->uv = (uint4 (*)[2])calloc(pp->nverts, 2*sizeof(uint4));
153 >                pp->uv = (uint32 (*)[2])calloc(pp->nverts, 2*sizeof(uint32));
154                  if (pp->uv == NULL)
155                          goto nomem;
156          } else
# Line 176 | Line 186 | register MESHPATCH     *pp;
186                  pp->tri = NULL;
187                                          /* local triangle material(s) */
188          if (mgetint(2) > 1) {
189 <                pp->trimat = (int2 *)malloc(pp->ntris*sizeof(int2));
189 >                pp->trimat = (int16 *)malloc(pp->ntris*sizeof(int16));
190                  if (pp->trimat == NULL)
191                          goto nomem;
192                  for (i = 0; i < pp->ntris; i++)
# Line 244 | Line 254 | int    flags;
254                  sprintf(errmsg, "cannot open mesh file \"%s\"", path);
255                  error(SYSTEM, errmsg);
256          }
257 < #ifdef MSDOS
248 <        setmode(fileno(meshfp), O_BINARY);
249 < #endif
257 >        SET_FILE_BINARY(meshfp);
258                                          /* read header */
259          checkheader(meshfp, MESHFMT, flags&IO_INFO ? stdout : (FILE *)NULL);
260                                          /* read format number */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines