--- ray/src/cv/mgflib/mgf2inv.c 1995/12/05 10:59:27 1.4 +++ ray/src/cv/mgflib/mgf2inv.c 2003/07/27 22:12:02 1.9 @@ -1,9 +1,6 @@ -/* Copyright (c) 1995 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: mgf2inv.c,v 1.9 2003/07/27 22:12:02 schorsch Exp $"; #endif - /* * Convert MGF to Inventor file. * @@ -12,17 +9,21 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + #include #include +#include + #include "parser.h" #include "lookup.h" #define O_INV1 1 /* Inventor 1.0 output */ #define O_INV2 2 /* Inventor 2.0 output */ -#define O_VRML 3 /* VRML output */ +#define O_VRML1 3 /* VRML 1.0 output */ #define MAXID 48 /* maximum identifier length */ @@ -97,7 +98,7 @@ char *argv[]; /* get options and print format line */ for (i = 1; i < argc && argv[i][0] == '-'; i++) if (!strcmp(argv[i], "-vrml")) - outtype = O_VRML; + outtype = O_VRML1; else if (!strcmp(argv[i], "-1")) outtype = O_INV1; else if (!strcmp(argv[i], "-2")) @@ -111,8 +112,8 @@ char *argv[]; case O_INV2: printf("#Inventor V2.0 ascii\n"); break; - case O_VRML: - printf("#VRML 1.0 ascii\n"); + case O_VRML1: + printf("#VRML V1.0 ascii\n"); break; } printf("## Translated from MGF Version %d.%d\n", MG_VMAJOR, MG_VMINOR); @@ -458,7 +459,7 @@ char **av; if (put_material() < 0) return(MG_EBADMAT); /* get endpoints */ - if ((v1 = c_getvert(av[1])) == NULL | (v2 = c_getvert(av[3])) == NULL) + if (((v1 = c_getvert(av[1])) == NULL) | ((v2 = c_getvert(av[3])) == NULL)) return(MG_EUNDEF); /* get radius */ if (!isflt(av[2])) @@ -468,7 +469,12 @@ char **av; va[1] = v2->p[1] - v1->p[1]; va[2] = v2->p[2] - v1->p[2]; length = sqrt(DOT(va,va)); - angle = acos(va[1]/length); + if (va[1] >= length) + angle = 0.; + else if (va[1] <= -length) + angle = PI; + else + angle = acos(va[1]/length); printf("%sTranslation { translation %13.9g %13.9g %13.9g }\n", tabs, .5*(v1->p[0]+v2->p[0]), .5*(v1->p[1]+v2->p[1]), .5*(v1->p[2]+v2->p[2]));