int main(int argc, char *argv) { int fd; t_scene scene; //prepscene(scene); if (argc < 1) { fd = open(argv[1]); if (fd = -1) ft_puterror("Could Not Open File"); else if (-1 = readscene(fd, scene)) ft_puterror("Invalid Scene"); //drawscene //showscene } else ft_puterror("No Arguements Given"); }
int readoct( /* read in octree file or stream */ char *inpspec, int load, CUBE *scene, char *ofn[] ) { char sbuf[512]; int nf; int i; long m; if (inpspec == NULL) { infn = "standard input"; infp = stdin; } else if (inpspec[0] == '!') { infn = inpspec; if ((infp = popen(inpspec+1, "r")) == NULL) { sprintf(errmsg, "cannot execute \"%s\"", inpspec); error(SYSTEM, errmsg); } } else { infn = inpspec; if ((infp = fopen(inpspec, "r")) == NULL) { sprintf(errmsg, "cannot open octree file \"%s\"", inpspec); error(SYSTEM, errmsg); } } SET_FILE_BINARY(infp); /* get header */ if (checkheader(infp, OCTFMT, load&IO_INFO ? stdout : (FILE *)NULL) < 0) octerror(USER, "not an octree"); /* check format */ if ((objsize = ogetint(2)-OCTMAGIC) <= 0 || objsize > MAXOBJSIZ || objsize > sizeof(long)) octerror(USER, "incompatible octree format"); /* get boundaries */ if (load & IO_BOUNDS) { for (i = 0; i < 3; i++) scene->cuorg[i] = atof(ogetstr(sbuf)); scene->cusize = atof(ogetstr(sbuf)); } else { for (i = 0; i < 4; i++) ogetstr(sbuf); } objorig = nobjects; /* set object offset */ nf = 0; /* get object files */ while (*ogetstr(sbuf)) { if (load & IO_SCENE) readobj(sbuf); if (load & IO_FILES) ofn[nf] = savqstr(sbuf); nf++; } if (load & IO_FILES) ofn[nf] = NULL; /* get number of objects */ fnobjects = m = ogetint(objsize); if (fnobjects != m) octerror(USER, "too many objects"); if (load & IO_TREE) /* get the octree */ scene->cutree = gettree(); else if (load & IO_SCENE && nf == 0) skiptree(); if (load & IO_SCENE) { /* get the scene */ if (nf == 0) { /* load binary scene data */ readscene(infp, objsize); } else { /* consistency checks */ /* check object count */ if (nobjects != objorig+fnobjects) octerror(USER, "bad object count; octree stale?"); /* check for non-surfaces */ if (nonsurfintree(scene->cutree)) octerror(USER, "modifier in tree; octree stale?"); } } /* close the input */ if (infn[0] == '!') pclose(infp); else fclose(infp); return(nf); }