ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/getbbox.c
Revision: 1.2
Committed: Wed May 29 17:51:44 1991 UTC (32 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.1: +14 -18 lines
Log Message:
made getbbox read from stdin if no files present

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