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