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

Comparing ray/src/cv/mgflib/context.c (file contents):
Revision 1.19 by greg, Mon Mar 13 13:00:34 1995 UTC vs.
Revision 1.23 by greg, Mon Aug 28 16:44:12 1995 UTC

# Line 105 | Line 105 | register char  **av;
105                          c_ccname = NULL;
106                          return(MG_OK);
107                  }
108 +                if (!isname(av[1]))
109 +                        return(MG_EILL);
110                  lp = lu_find(&clr_tab, av[1]);  /* lookup context */
111                  if (lp == NULL)
112                          return(MG_EMEM);
# Line 221 | Line 223 | register char  **av;
223                          c_cmname = NULL;
224                          return(MG_OK);
225                  }
226 +                if (!isname(av[1]))
227 +                        return(MG_EILL);
228                  lp = lu_find(&mat_tab, av[1]);  /* lookup context */
229                  if (lp == NULL)
230                          return(MG_EMEM);
# Line 259 | Line 263 | register char  **av;
263                  *c_cmaterial = *(C_MATERIAL *)lp->data;
264                  c_cmaterial->clock = i + 1;
265                  return(MG_OK);
266 +        case MG_E_IR:           /* set index of refraction */
267 +                if (ac != 3)
268 +                        return(MG_EARGC);
269 +                if (!isflt(av[1]) | !isflt(av[2]))
270 +                        return(MG_ETYPE);
271 +                c_cmaterial->nr = atof(av[1]);
272 +                c_cmaterial->ni = atof(av[2]);
273 +                if (c_cmaterial->nr <= FTINY)
274 +                        return(MG_EILL);
275 +                c_cmaterial->clock++;
276 +                return(MG_OK);
277          case MG_E_RD:           /* set diffuse reflectance */
278                  if (ac != 2)
279                          return(MG_EARGC);
# Line 355 | Line 370 | register char  **av;
370                          c_cvname = NULL;
371                          return(MG_OK);
372                  }
373 +                if (!isname(av[1]))
374 +                        return(MG_EILL);
375                  lp = lu_find(&vtx_tab, av[1]);  /* lookup context */
376                  if (lp == NULL)
377                          return(MG_EMEM);
# Line 554 | Line 571 | char   **av;
571          int     n, imax;
572          int     wl;
573          double  wl0, wlstep;
574 +        double  boxpos, boxstep;
575                                          /* check bounds */
576          if (wlmax <= C_CMINWL | wlmax <= wlmin | wlmin >= C_CMAXWL)
577                  return(MG_EILL);
# Line 566 | Line 584 | char   **av;
584                  wlmax -= wlstep;
585                  ac--;
586          }
569        if (ac < 2)
570                return(MG_EILL);
587          imax = ac;                      /* box filter if necessary */
588 +        boxpos = 0;
589 +        boxstep = 1;
590          if (wlstep < C_CWLI) {
591 +                imax = (wlmax - wlmin)/C_CWLI + (1-FTINY);
592 +                boxpos = (wlmin - C_CMINWL)/C_CWLI;
593 +                boxstep = wlstep/C_CWLI;
594                  wlstep = C_CWLI;
574                imax = (wlmax - wlmin)/wlstep;
595          }
596          scale = 0.;                     /* get values and maximum */
597          pos = 0;
598          for (i = 0; i < imax; i++) {
599                  va[i] = 0.; n = 0;
600 <                while (pos < (i+.5)*ac/imax) {
600 >                while (boxpos < i+.5 && pos < ac) {
601                          if (!isflt(av[pos]))
602                                  return(MG_ETYPE);
603                          va[i] += atof(av[pos++]);
604                          n++;
605 +                        boxpos += boxstep;
606                  }
607                  if (n > 1)
608                          va[i] /= (double)n;
588                if (va[i] < 0.)
589                        return(MG_EILL);
609                  if (va[i] > scale)
610                          scale = va[i];
611 +                else if (va[i] < -scale)
612 +                        scale = -va[i];
613          }
614 <        if (scale == 0.)
614 >        if (scale <= FTINY)
615                  return(MG_EILL);
616          scale = C_CMAXV / scale;
617          clr->ssum = 0;                  /* convert to our spacing */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines