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

Comparing ray/src/common/bsdf.c (file contents):
Revision 2.36 by greg, Sat Sep 17 22:09:33 2011 UTC vs.
Revision 2.39 by greg, Mon Mar 5 00:17:06 2012 UTC

# Line 92 | Line 92 | SDloadGeometry(SDData *sd, ezxml_t wdb)
92  
93          if (wdb == NULL)                /* no geometry section? */
94                  return SDEnone;
95 +        if ((geom = ezxml_child(wdb, "Name")) != NULL) {
96 +                strncpy(sd->matn, ezxml_txt(geom), SDnameLn);
97 +                sd->matn[SDnameLn-1] = '\0';
98 +        }
99 +        if ((geom = ezxml_child(wdb, "Manufacturer")) != NULL) {
100 +                strncpy(sd->makr, ezxml_txt(geom), SDnameLn);
101 +                sd->makr[SDnameLn-1] = '\0';
102 +        }
103          sd->dim[0] = sd->dim[1] = sd->dim[2] = .0;
104 +        SDerrorDetail[0] = '\0';
105          if ((geom = ezxml_child(wdb, "Width")) != NULL)
106                  sd->dim[0] = atof(ezxml_txt(geom)) *
107                                  to_meters(ezxml_attr(geom, "unit"));
# Line 103 | Line 112 | SDloadGeometry(SDData *sd, ezxml_t wdb)
112                  sd->dim[2] = atof(ezxml_txt(geom)) *
113                                  to_meters(ezxml_attr(geom, "unit"));
114          if ((sd->dim[0] < 0) | (sd->dim[1] < 0) | (sd->dim[2] < 0)) {
115 <                sprintf(SDerrorDetail, "Negative size in \"%s\"", sd->name);
115 >                if (!SDerrorDetail[0])
116 >                        sprintf(SDerrorDetail, "Negative dimension in \"%s\"",
117 >                                                sd->name);
118                  return SDEdata;
119          }
120          if ((geom = ezxml_child(wdb, "Geometry")) == NULL ||
# Line 121 | Line 132 | SDloadGeometry(SDData *sd, ezxml_t wdb)
132                  return SDEsupport;
133          }
134          cfact = to_meters(ezxml_attr(geom, "unit"));
135 +        if (cfact <= 0)
136 +                return SDEformat;
137          sd->mgf = (char *)malloc(strlen(mgfstr)+32);
138          if (sd->mgf == NULL) {
139                  strcpy(SDerrorDetail, "Out of memory in SDloadGeometry");
# Line 164 | Line 177 | SDloadFile(SDData *sd, const char *fname)
177          }
178          wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer");
179          if (wtl == NULL) {
180 <                sprintf(SDerrorDetail, "BSDF \"%s\": no optical layer'",
180 >                sprintf(SDerrorDetail, "BSDF \"%s\": no optical layers'",
181                                  sd->name);
182                  ezxml_free(fl);
183                  return SDEformat;
# Line 223 | Line 236 | SDnewSpectralDF(int nc)
236          df->maxHemi = .0;
237          df->ncomp = nc;
238          memset(df->comp, 0, nc*sizeof(SDComponent));
239 +        return df;
240 + }
241 +
242 + /* Add component(s) to spectral distribution function */
243 + SDSpectralDF *
244 + SDaddComponent(SDSpectralDF *odf, int nadd)
245 + {
246 +        SDSpectralDF    *df;
247 +
248 +        if (odf == NULL)
249 +                return SDnewSpectralDF(nadd);
250 +        if (nadd <= 0)
251 +                return odf;
252 +        df = (SDSpectralDF *)realloc(odf, sizeof(SDSpectralDF) +
253 +                                (odf->ncomp+nadd-1)*sizeof(SDComponent));
254 +        if (df == NULL) {
255 +                sprintf(SDerrorDetail,
256 +                        "Cannot add %d component(s) to spectral DF", nadd);
257 +                SDfreeSpectralDF(odf);
258 +                return NULL;
259 +        }
260 +        memset(df->comp+df->ncomp, 0, nadd*sizeof(SDComponent));
261 +        df->ncomp += nadd;
262          return df;
263   }
264  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines