ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/cone.c
(Generate patch)

Comparing ray/src/common/cone.c (file contents):
Revision 2.8 by schorsch, Thu Jun 26 00:58:09 2003 UTC vs.
Revision 2.10 by greg, Thu Apr 21 00:40:35 2016 UTC

# Line 41 | Line 41 | static const char      RCSid[] = "$Id$";
41  
42  
43   CONE *
44 < getcone(o, getxf)                       /* get cone structure */
45 < register OBJREC  *o;
46 < int  getxf;
44 > getcone(                                /* get cone structure */
45 >        OBJREC  *o,
46 >        int  getxf
47 > )
48   {
49          int  sgn0, sgn1;
50 <        register CONE  *co;
50 >        CONE  *co;
51  
52          if ((co = (CONE *)o->os) == NULL) {
53  
# Line 56 | Line 57 | int  getxf;
57  
58                  co->ca = o->oargs.farg;
59                                                  /* get radii */
60 <                if (o->otype == OBJ_CYLINDER | o->otype == OBJ_TUBE) {
60 >                if ((o->otype == OBJ_CYLINDER) | (o->otype == OBJ_TUBE)) {
61                          if (o->oargs.nfargs != 7)
62                                  goto argcerr;
63                          if (co->ca[6] < -FTINY) {
# Line 79 | Line 80 | int  getxf;
80                          else sgn1 = 0;
81                          if (sgn0+sgn1 == 0)
82                                  goto raderr;
83 <                        if (sgn0 < 0 | sgn1 < 0) {
83 >                        if ((sgn0 < 0) | (sgn1 < 0)) {
84                                  objerror(o, o->otype==OBJ_RING?USER:WARNING,
85                                          "negative radii");
86                                  o->otype = o->otype == OBJ_CONE ?
# Line 120 | Line 121 | int  getxf;
121                          co->ad[2] = CO_P1(co)[2] - CO_P0(co)[2];
122                  }
123                  co->al = normalize(co->ad);
124 <                if (co->al == 0.0)
125 <                        objerror(o, USER, "zero orientation");
124 >                if (co->al == 0.0) {
125 >                        objerror(o, WARNING, "unknown orientation");
126 >                        free(co);
127 >                        return(NULL);
128 >                }
129                                          /* compute axis and side lengths */
130                  if (o->otype == OBJ_RING) {
131                          co->al = 0.0;
132                          co->sl = CO_R1(co) - CO_R0(co);
133 <                } else if (o->otype == OBJ_CONE | o->otype == OBJ_CUP) {
133 >                } else if ((o->otype == OBJ_CONE) | (o->otype == OBJ_CUP)) {
134                          co->sl = co->ca[7] - co->ca[6];
135                          co->sl = sqrt(co->sl*co->sl + co->al*co->al);
136                  } else { /* OBJ_CYLINDER or OBJ_TUBE */
# Line 142 | Line 146 | int  getxf;
146   argcerr:
147          objerror(o, USER, "bad # arguments");
148   raderr:
149 <        objerror(o, USER, "illegal radii");
150 <        return NULL; /* pro forma return */
149 >        objerror(o, WARNING, "illegal radii");
150 >        free(co);
151 >        return(NULL);
152   }
153  
154  
155   void
156 < freecone(o)                     /* free memory associated with cone */
152 < OBJREC  *o;
156 > freecone(OBJREC *o)             /* free memory associated with cone */
157   {
158 <        register CONE  *co = (CONE *)o->os;
158 >        CONE  *co = (CONE *)o->os;
159  
160          if (co == NULL)
161                  return;
# Line 163 | Line 167 | OBJREC  *o;
167  
168  
169   void
170 < conexform(co)                   /* get cone transformation matrix */
167 < register CONE  *co;
170 > conexform(CONE *co)                     /* get cone transformation matrix */
171   {
172          MAT4  m4;
173 <        register double  d;
174 <        register int  i;
173 >        double  d;
174 >        int  i;
175  
176          co->tm = (RREAL (*)[4])malloc(sizeof(MAT4));
177          if (co->tm == NULL)
# Line 206 | Line 209 | register CONE  *co;
209          multmat4(co->tm, co->tm, m4);
210  
211                                  /* scale z-axis */
212 <        if (co->p0 != co->p1 & co->r0 != co->r1) {
212 >        if ((co->p0 != co->p1) & (co->r0 != co->r1)) {
213                  setident4(m4);
214                  m4[2][2] = (CO_R1(co) - CO_R0(co)) / co->al;
215                  multmat4(co->tm, co->tm, m4);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines