ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/getbbox.c
Revision: 2.4
Committed: Thu Apr 14 04:56:52 1994 UTC (30 years ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.3: +0 -9 lines
Log Message:
changed libpath to getlibpath()

File Contents

# User Rev Content
1 greg 1.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     char *progname; /* argv[0] */
20    
21     int nowarn = 0; /* supress warnings? */
22    
23     int (*addobjnotify[])() = {NULL}; /* new object notifier functions */
24    
25     FVECT bbmin, bbmax; /* bounding box */
26    
27     addobject(o) /* add object to bounding box */
28     OBJREC *o;
29     {
30     add2bbox(o, bbmin, bbmax);
31     }
32    
33    
34     main(argc, argv) /* read object files and compute bounds */
35     int argc;
36     char **argv;
37     {
38 greg 2.2 extern char *getenv();
39 greg 1.3 int nohead = 0;
40 greg 1.1 int i;
41    
42     progname = argv[0];
43    
44 greg 1.3 for (i = 1; i < argc && argv[i][0] == '-'; i++) {
45     switch (argv[i][1]) {
46     case 'w':
47     nowarn = 1;
48     continue;
49     case 'h':
50     nohead = 1;
51     continue;
52     }
53     break;
54     }
55 greg 1.1 /* find bounding box */
56     bbmin[0] = bbmin[1] = bbmin[2] = FHUGE;
57     bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE;
58     /* read input */
59 greg 1.2 if (i >= argc)
60     readobj(NULL, addobject);
61     else
62     for ( ; i < argc; i++)
63     if (!strcmp(argv[i], "-")) /* from stdin */
64     readobj(NULL, addobject);
65     else /* from file */
66     readobj(argv[i], addobject);
67     /* print bounding box */
68 greg 1.3 if (!nohead)
69     printf(
70 greg 2.3 " xmin xmax ymin ymax zmin zmax\n");
71 greg 1.3
72 greg 1.1 printf("%9g %9g %9g %9g %9g %9g\n", bbmin[0], bbmax[0],
73     bbmin[1], bbmax[1], bbmin[2], bbmax[2]);
74     quit(0);
75     }
76    
77    
78     quit(code) /* exit program */
79     int code;
80     {
81     exit(code);
82     }
83    
84    
85     cputs() /* interactive error */
86     {
87     /* referenced, but not used */
88     }
89    
90    
91     wputs(s) /* warning message */
92     char *s;
93     {
94     if (!nowarn)
95     eputs(s);
96     }
97    
98    
99     eputs(s) /* put string to stderr */
100     register char *s;
101     {
102     static int inln = 0;
103    
104     if (!inln++) {
105     fputs(progname, stderr);
106     fputs(": ", stderr);
107     }
108     fputs(s, stderr);
109     if (*s && s[strlen(s)-1] == '\n')
110     inln = 0;
111     }