--- ray/src/ot/obj2mesh.c 2003/04/18 21:47:45 2.4 +++ ray/src/ot/obj2mesh.c 2004/04/22 17:33:48 2.9 @@ -1,16 +1,18 @@ #ifndef lint -static const char RCSid[] = "$Id: obj2mesh.c,v 2.4 2003/04/18 21:47:45 greg Exp $"; +static const char RCSid[] = "$Id: obj2mesh.c,v 2.9 2004/04/22 17:33:48 greg Exp $"; #endif /* * Main program to compile a Wavefront .OBJ file into a Radiance mesh */ #include "copyright.h" +#include "platform.h" #include "standard.h" +#include "resolu.h" #include "cvmesh.h" #include "otypes.h" -extern int o_face(); +extern int o_face(); /* XXX should go to a header file */ int o_default() { return(O_MISS); } @@ -26,10 +28,15 @@ int resolu = 16384; /* octree resolution limit */ double mincusize; /* minimum cube size from resolu */ +static void addface(CUBE *cu, OBJECT obj); +static void add2full(CUBE *cu, OBJECT obj); -main(argc, argv) /* compile a .OBJ file into a mesh */ -int argc; -char *argv[]; + +int +main( /* compile a .OBJ file into a mesh */ + int argc, + char *argv[] +) { int nmatf = 0; char *matinp[32]; @@ -57,6 +64,9 @@ char *argv[]; error(USER, errmsg); break; } + + if (i < argc-2) + error(USER, "too many file arguments"); /* initialize mesh */ cvinit(i==argc-2 ? argv[i+1] : ""); /* load material input */ @@ -73,9 +83,7 @@ char *argv[]; if (i == argc-2) /* open output file */ if (freopen(argv[i+1], "w", stdout) == NULL) error(SYSTEM, "cannot open output file"); -#ifdef MSDOS - setmode(fileno(stdout), O_BINARY); -#endif + SET_FILE_BINARY(stdout); newheader("RADIANCE", stdout); /* new binary file header */ printargs(icutree); cukid.cusize = cu->cusize * 0.5; - if (oset[0] < objlim || cukid.cusize < mincusize) { + if (inc==O_IN || oset[0] < objlim || cukid.cusize < + (oset[0] < MAXSET ? mincusize : mincusize/256.0)) { /* add to set */ if (oset[0] >= MAXSET) { sprintf(errmsg, "set overflow in addobject (%s)",