ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/getbbox.c
Revision: 1.3
Committed: Wed May 29 18:00:29 1991 UTC (32 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +16 -7 lines
Log Message:
added -h option to supress header

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 nohead = 0;
47 int i;
48
49 progname = argv[0];
50
51 if ((libpath = getenv("RAYPATH")) == NULL)
52 libpath = DEFPATH;
53
54 for (i = 1; i < argc && argv[i][0] == '-'; i++) {
55 switch (argv[i][1]) {
56 case 'w':
57 nowarn = 1;
58 continue;
59 case 'h':
60 nohead = 1;
61 continue;
62 }
63 break;
64 }
65 /* find bounding box */
66 bbmin[0] = bbmin[1] = bbmin[2] = FHUGE;
67 bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE;
68 /* read input */
69 if (i >= argc)
70 readobj(NULL, addobject);
71 else
72 for ( ; i < argc; i++)
73 if (!strcmp(argv[i], "-")) /* from stdin */
74 readobj(NULL, addobject);
75 else /* from file */
76 readobj(argv[i], addobject);
77 /* print bounding box */
78 if (!nohead)
79 printf(
80 " xmin xmax ymin ymax zmin zmax\n");
81
82 printf("%9g %9g %9g %9g %9g %9g\n", bbmin[0], bbmax[0],
83 bbmin[1], bbmax[1], bbmin[2], bbmax[2]);
84 quit(0);
85 }
86
87
88 quit(code) /* exit program */
89 int code;
90 {
91 exit(code);
92 }
93
94
95 cputs() /* interactive error */
96 {
97 /* referenced, but not used */
98 }
99
100
101 wputs(s) /* warning message */
102 char *s;
103 {
104 if (!nowarn)
105 eputs(s);
106 }
107
108
109 eputs(s) /* put string to stderr */
110 register char *s;
111 {
112 static int inln = 0;
113
114 if (!inln++) {
115 fputs(progname, stderr);
116 fputs(": ", stderr);
117 }
118 fputs(s, stderr);
119 if (*s && s[strlen(s)-1] == '\n')
120 inln = 0;
121 }