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

Comparing ray/src/util/eplus_adduvf.c (file contents):
Revision 2.12 by greg, Fri Feb 21 13:17:45 2014 UTC vs.
Revision 2.18 by schorsch, Sun Mar 6 01:13:18 2016 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   */
9  
10   #include <stdlib.h>
11 + #include "platform.h"
12   #include "rtio.h"
13   #include "rtmath.h"
14   #include "random.h"
# Line 176 | Line 177 | add_subsurf(IDF_OBJECT *param)
177   static IDF_FIELD *
178   get_vlist(IDF_OBJECT *param, const char *zname)
179   {
180 <        int             i = 0;
180 > #define itm_len         (sizeof(IDF_FIELD)+6)
181 >        static char             fld_buf[4*itm_len];
182 >        static char             *next_fbp = fld_buf;
183 >        int                     i;
184 >        IDF_FIELD               *res;
185                                                  /* check if subsurface */
186          if (!strcmp(param->pname, SUBSURF_PNAME)) {
187                  if (zname != NULL) {
# Line 185 | Line 190 | get_vlist(IDF_OBJECT *param, const char *zname)
190                          if (strcmp((*(ZONE *)lep->data).zname, zname))
191                                  return(NULL);
192                  }
193 <                return(idf_getfield(param, SS_VERT_FLD));
193 >                res = idf_getfield(param, SS_VERT_FLD);
194 >        } else {
195 >                i = 0;                          /* check for surface type */
196 >                while (strcmp(surf_type[i].pname, param->pname))
197 >                        if (surf_type[++i].pname == NULL)
198 >                                return(NULL);
199 >
200 >                if (zname != NULL) {            /* matches specified zone? */
201 >                        IDF_FIELD       *fptr = idf_getfield(param, surf_type[i].zone_fld);
202 >                        if (fptr == NULL || strcmp(fptr->val, zname))
203 >                                return(NULL);
204 >                }
205 >                res = idf_getfield(param, surf_type[i].vert_fld);
206          }
207 <                                                /* check for surface type */
208 <        while (strcmp(surf_type[i].pname, param->pname))
209 <                if (surf_type[++i].pname == NULL)
207 >        if (!res->val[0]) {                     /* hack for missing #vert */
208 >                IDF_FIELD       *fptr;
209 >                if (next_fbp >= fld_buf+sizeof(fld_buf))
210 >                        next_fbp = fld_buf;
211 >                i = 0;                          /* count vertices */
212 >                for (fptr = res->next; fptr != NULL; fptr = fptr->next)
213 >                        ++i;
214 >                if (i % 3)
215                          return(NULL);
216 <
217 <        if (zname != NULL) {                    /* matches specified zone? */
218 <                IDF_FIELD       *fptr = idf_getfield(param, surf_type[i].zone_fld);
219 <                if (fptr == NULL || strcmp(fptr->val, zname))
220 <                        return(NULL);
216 >                fptr = res->next;
217 >                res = (IDF_FIELD *)next_fbp; next_fbp += itm_len;
218 >                res->next = fptr;
219 >                res->rem = "";
220 >                sprintf(res->val, "%d", i/3);
221          }
222 <                                                /* return field for #verts */
223 <        return(idf_getfield(param, surf_type[i].vert_fld));
222 >        return(res);
223 > #undef itm_len
224   }
225  
226   /* Get/allocate surface polygon */
# Line 303 | Line 325 | static double
325   rad_subsurface(IDF_OBJECT *param, FILE *ofp)
326   {
327          const char      *sname = idf_getfield(param,NAME_FLD)->val;
328 <        SURFACE         *surf = get_surface(idf_getfield(param,SS_VERT_FLD));
328 >        SURFACE         *surf = get_surface(get_vlist(param, NULL));
329          double          area;
330          int             i;
331  
# Line 341 | Line 363 | start_rcontrib(SUBPROC *pd, ZONE *zp)
363          IDF_FIELD       *fptr;
364          int             i, j, n;
365                                                  /* start oconv command */
366 <        sprintf(cbuf, "oconv - > '%s'", temp_octree);
366 >        sprintf(cbuf, "oconv - > \"%s\"", temp_octree);
367          if ((ofp = popen(cbuf, "w")) == NULL) {
368                  fputs(progname, stderr);
369                  fputs(": cannot open oconv process\n", stderr);
# Line 371 | Line 393 | start_rcontrib(SUBPROC *pd, ZONE *zp)
393                                                  /* now subsurfaces */
394          if (zp->ntotal > zp->nsurf) {
395                  if (zp->area_redu != NULL)
396 <                        memset(zp->area_redu, 0, sizeof(float)*zp->nsurf);
397 <                else if ((zp->area_redu = (float *)calloc(zp->nsurf,
396 >                        memset(zp->area_redu, 0, sizeof(float)*zp->ntotal);
397 >                else if ((zp->area_redu = (float *)calloc(zp->ntotal,
398                                                  sizeof(float))) == NULL)
399                          return(0);
400          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines