--- ray/src/common/readoct.c 1990/12/12 22:43:57 1.10 +++ ray/src/common/readoct.c 1991/08/05 08:58:52 1.13 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -37,7 +37,8 @@ int load; CUBE *scene; char *ofn[]; { - char sbuf[128]; + extern int fputs(); + char sbuf[512]; int nf; OBJECT fnobjects; register int i; @@ -54,13 +55,11 @@ char *ofn[]; } } /* get header */ - if (load & IO_INFO) - copyheader(infp, stdout); - else - getheader(infp, NULL); + if (checkheader(infp, OCTFMT, load&IO_INFO ? stdout : NULL) < 0) + octerror(USER, "not an octree"); /* check format */ if (getint(2) != OCTMAGIC) - octerror(USER, "invalid octree format"); + octerror(USER, "incompatible octree format"); /* get boundaries */ if (load & IO_BOUNDS) { for (i = 0; i < 3; i++) @@ -97,18 +96,16 @@ char *ofn[]; } while (getobj() != OVOID) ; + } else if (load & IO_SCENE) { /* consistency checks */ + /* check object count */ + if (nobjects != objorig+fnobjects) + octerror(USER, "bad object count; octree stale?"); + /* check for non-surfaces */ + if (nonsurfinset(objorig, fnobjects)) + octerror(USER, "non-surface in set; octree stale?"); } } fclose(infp); - /* consistency checks */ - if (load & IO_SCENE) { - /* check object count */ - if (nobjects != objorig+fnobjects) - octerror(USER, "bad object count; octree stale?"); - /* check for non-surfaces */ - if (nonsurfinset(objorig, fnobjects)) - octerror(USER, "non-surface in set; octree stale?"); - } return(nf); }