ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/getbbox.c
Revision: 2.2
Committed: Thu Dec 19 15:06:44 1991 UTC (32 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +1 -2 lines
Log Message:
removed atof declaration for NeXT

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