--- ray/src/common/cone.c 1992/09/06 11:53:47 2.2 +++ ray/src/common/cone.c 2003/07/27 22:12:01 2.9 @@ -1,15 +1,12 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: cone.c,v 2.9 2003/07/27 22:12:01 schorsch Exp $"; #endif - /* * cone.c - routines for making cones - * - * 2/12/86 */ +#include "copyright.h" + #include "standard.h" #include "object.h" @@ -48,7 +45,6 @@ getcone(o, getxf) /* get cone structure */ register OBJREC *o; int getxf; { - extern double sqrt(); int sgn0, sgn1; register CONE *co; @@ -60,7 +56,7 @@ int getxf; co->ca = o->oargs.farg; /* get radii */ - if (o->otype == OBJ_CYLINDER | o->otype == OBJ_TUBE) { + if ((o->otype == OBJ_CYLINDER) | (o->otype == OBJ_TUBE)) { if (o->oargs.nfargs != 7) goto argcerr; if (co->ca[6] < -FTINY) { @@ -83,7 +79,7 @@ int getxf; else sgn1 = 0; if (sgn0+sgn1 == 0) goto raderr; - if (sgn0 < 0 | sgn1 < 0) { + if ((sgn0 < 0) | (sgn1 < 0)) { objerror(o, o->otype==OBJ_RING?USER:WARNING, "negative radii"); o->otype = o->otype == OBJ_CONE ? @@ -130,7 +126,7 @@ int getxf; if (o->otype == OBJ_RING) { co->al = 0.0; co->sl = CO_R1(co) - CO_R0(co); - } else if (o->otype == OBJ_CONE | o->otype == OBJ_CUP) { + } else if ((o->otype == OBJ_CONE) | (o->otype == OBJ_CUP)) { co->sl = co->ca[7] - co->ca[6]; co->sl = sqrt(co->sl*co->sl + co->al*co->al); } else { /* OBJ_CYLINDER or OBJ_TUBE */ @@ -147,32 +143,34 @@ argcerr: objerror(o, USER, "bad # arguments"); raderr: objerror(o, USER, "illegal radii"); + return NULL; /* pro forma return */ } +void freecone(o) /* free memory associated with cone */ OBJREC *o; { register CONE *co = (CONE *)o->os; - if (o->os == NULL) + if (co == NULL) return; if (co->tm != NULL) - free((char *)co->tm); - free(o->os); + free((void *)co->tm); + free((void *)co); o->os = NULL; } +void conexform(co) /* get cone transformation matrix */ register CONE *co; { - extern double sqrt(); MAT4 m4; register double d; register int i; - co->tm = (FLOAT (*)[4])malloc(sizeof(MAT4)); + co->tm = (RREAL (*)[4])malloc(sizeof(MAT4)); if (co->tm == NULL) error(SYSTEM, "out of memory in conexform"); @@ -208,7 +206,7 @@ register CONE *co; multmat4(co->tm, co->tm, m4); /* scale z-axis */ - if (co->p0 != co->p1 & co->r0 != co->r1) { + if ((co->p0 != co->p1) & (co->r0 != co->r1)) { setident4(m4); m4[2][2] = (CO_R1(co) - CO_R0(co)) / co->al; multmat4(co->tm, co->tm, m4);