home *** CD-ROM | disk | FTP | other *** search
- /* tddd2mif.c - convert TTDDD file to FrameMaker MIF format
- * - written by Glenn M. Lewis - 7/24/91
- */
-
- static char rcs_id[] = "$Id: tddd2mif.c,v 1.7 1993/02/14 17:44:16 glewis Exp glewis $";
-
- #include <stdio.h>
- #include "t3dlib.h"
- #ifdef __STDC__
- #include <stdlib.h>
- #include <strings.h>
- #include "tddd2mif_protos.h"
- #endif
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- char filename[256], rootname[256], *c1, *c2;
- int i, view;
- WORLD *world;
- FILE *inp, *out;
-
- view = VIEW_ALL_FOUR;
- rootname[0] = filename[0] = '\0';
- /* strcpy(rootname, "model"); ** The default for reading stdin */
- for (i=1; i<argc; i++) {
- if (argv[i][0] == '-') {
- switch(argv[i][1]) {
- case 'a': view=VIEW_ALL_FOUR; break;
- case 't': view=VIEW_TOP; break;
- case 'f': view=VIEW_FRONT; break;
- case 'r': view=VIEW_RIGHT; break;
- case 'i': view=VIEW_ISO; break;
- case 'h':
- default:
- fprintf(stderr, "Usage: %s [-all|-top|-front|-right|-iso] [infile] [outfile]\n", argv[0]);
- exit(-1);
- }
- } else if (filename[0]) {
- strcpy(rootname, argv[i]);
- } else {
- strcpy(filename, argv[i]); /* Make root of filename the default */
- for (c1=rootname,c2=argv[i]; (*c1 = *c2++) && *c1!='.'; c1++) ;
- *c1 = '\0';
- strcat(rootname, ".mif");
- }
- }
-
- if (!filename[0]) inp = stdin;
- else if (!(inp = fopen(filename, "r"))) {
- fprintf(stderr, "Can't open '%s' for input.\n", filename);
- exit(-1);
- }
- if (!rootname[0]) out = stdout;
- else if (!(out = fopen(rootname, "w"))) {
- fprintf(stderr, "Can't open '%s' for output.\n", rootname);
- exit(-1);
- }
-
- world = read_World(inp);
- write_MIF(world, out, view);
- free_World(world);
- exit(0);
- }
-
-