ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/getbbox.c
Revision: 1.1
Committed: Wed May 29 17:33:17 1991 UTC (32 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 /* Copyright (c) 1991 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * getbbox.c - compute bounding box for scene files
9 *
10 * Adapted from oconv.c 29 May 1991
11 */
12
13 #include "standard.h"
14
15 #include "octree.h"
16
17 #include "object.h"
18
19 #ifndef DEFPATH
20 #define DEFPATH ":/usr/local/lib/ray"
21 #endif
22
23 char *progname; /* argv[0] */
24
25 char *libpath; /* library search path */
26
27 int nowarn = 0; /* supress warnings? */
28
29 int (*addobjnotify[])() = {NULL}; /* new object notifier functions */
30
31 FVECT bbmin, bbmax; /* bounding box */
32
33 addobject(o) /* add object to bounding box */
34 OBJREC *o;
35 {
36 add2bbox(o, bbmin, bbmax);
37 }
38
39
40 main(argc, argv) /* read object files and compute bounds */
41 int argc;
42 char **argv;
43 {
44 char *getenv();
45 double atof();
46 int i;
47
48 progname = argv[0];
49
50 if ((libpath = getenv("RAYPATH")) == NULL)
51 libpath = DEFPATH;
52
53 for (i = 1; i < argc && argv[i][0] == '-'; i++)
54 switch (argv[i][1]) {
55 case '\0': /* scene from stdin */
56 goto breakopt;
57 case 'w': /* supress warnings */
58 nowarn = 1;
59 break;
60 default:
61 sprintf(errmsg, "unknown option: '%s'", argv[i]);
62 error(USER, errmsg);
63 break;
64 }
65 breakopt:
66 /* find bounding box */
67 bbmin[0] = bbmin[1] = bbmin[2] = FHUGE;
68 bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE;
69 /* read input */
70 for ( ; i < argc; i++)
71 if (!strcmp(argv[i], "-")) /* from stdin */
72 readobj(NULL, addobject);
73 else /* from file */
74 readobj(argv[i], addobject);
75 /* print it out */
76 printf(" xmin xmax ymin ymax zmin zmax\n");
77 printf("%9g %9g %9g %9g %9g %9g\n", bbmin[0], bbmax[0],
78 bbmin[1], bbmax[1], bbmin[2], bbmax[2]);
79 quit(0);
80 }
81
82
83 quit(code) /* exit program */
84 int code;
85 {
86 exit(code);
87 }
88
89
90 cputs() /* interactive error */
91 {
92 /* referenced, but not used */
93 }
94
95
96 wputs(s) /* warning message */
97 char *s;
98 {
99 if (!nowarn)
100 eputs(s);
101 }
102
103
104 eputs(s) /* put string to stderr */
105 register char *s;
106 {
107 static int inln = 0;
108
109 if (!inln++) {
110 fputs(progname, stderr);
111 fputs(": ", stderr);
112 }
113 fputs(s, stderr);
114 if (*s && s[strlen(s)-1] == '\n')
115 inln = 0;
116 }