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.22 by greg, Fri Feb 28 05:18:49 2020 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   */
9  
10   #include <stdlib.h>
11 + #include <ctype.h>
12 + #include "platform.h"
13   #include "rtio.h"
14   #include "rtmath.h"
15   #include "random.h"
# Line 39 | Line 41 | const char     ADD_HEADER[] =
41   #define NAME_FLD        1                       /* name field always first? */
42  
43   #define SS_BASE_FLD     4                       /* subsurface base surface */
44 < #define SS_VERT_FLD     10                      /* subsurface vertex count */
44 > #define SS_VERT_FLD     9                       /* subsurface vertex count */
45  
46   typedef struct {
47          const char      *pname;                 /* object type name */
# Line 176 | Line 178 | add_subsurf(IDF_OBJECT *param)
178   static IDF_FIELD *
179   get_vlist(IDF_OBJECT *param, const char *zname)
180   {
181 <        int             i = 0;
181 > #define itm_len         (sizeof(IDF_FIELD)+6)
182 >        static char             fld_buf[4*itm_len];
183 >        static char             *next_fbp = fld_buf;
184 >        int                     i;
185 >        IDF_FIELD               *res;
186                                                  /* check if subsurface */
187          if (!strcmp(param->pname, SUBSURF_PNAME)) {
188                  if (zname != NULL) {
# Line 185 | Line 191 | get_vlist(IDF_OBJECT *param, const char *zname)
191                          if (strcmp((*(ZONE *)lep->data).zname, zname))
192                                  return(NULL);
193                  }
194 <                return(idf_getfield(param, SS_VERT_FLD));
194 >                res = idf_getfield(param, SS_VERT_FLD);
195 >        } else {
196 >                i = 0;                          /* check for surface type */
197 >                while (strcmp(surf_type[i].pname, param->pname))
198 >                        if (surf_type[++i].pname == NULL)
199 >                                return(NULL);
200 >
201 >                if (zname != NULL) {            /* matches specified zone? */
202 >                        IDF_FIELD       *fptr = idf_getfield(param, surf_type[i].zone_fld);
203 >                        if (fptr == NULL || strcmp(fptr->val, zname))
204 >                                return(NULL);
205 >                }
206 >                res = idf_getfield(param, surf_type[i].vert_fld);
207          }
208 <                                                /* check for surface type */
209 <        while (strcmp(surf_type[i].pname, param->pname))
210 <                if (surf_type[++i].pname == NULL)
208 >        if (!res->val[0] || tolower(res->val[0]) == 'a') {  /* autocalculate */
209 >                IDF_FIELD       *fptr;
210 >                if (next_fbp >= fld_buf+sizeof(fld_buf))
211 >                        next_fbp = fld_buf;
212 >                i = 0;                          /* count vertices */
213 >                for (fptr = res->next; fptr != NULL; fptr = fptr->next)
214 >                        ++i;
215 >                if (i % 3)
216                          return(NULL);
217 <
218 <        if (zname != NULL) {                    /* matches specified zone? */
219 <                IDF_FIELD       *fptr = idf_getfield(param, surf_type[i].zone_fld);
220 <                if (fptr == NULL || strcmp(fptr->val, zname))
221 <                        return(NULL);
217 >                fptr = res->next;
218 >                res = (IDF_FIELD *)next_fbp; next_fbp += itm_len;
219 >                res->next = fptr;
220 >                res->rem = "";
221 >                sprintf(res->val, "%d", i/3);
222          }
223 <                                                /* return field for #verts */
224 <        return(idf_getfield(param, surf_type[i].vert_fld));
223 >        return(res);
224 > #undef itm_len
225   }
226  
227   /* Get/allocate surface polygon */
# Line 303 | Line 326 | static double
326   rad_subsurface(IDF_OBJECT *param, FILE *ofp)
327   {
328          const char      *sname = idf_getfield(param,NAME_FLD)->val;
329 <        SURFACE         *surf = get_surface(idf_getfield(param,SS_VERT_FLD));
329 >        SURFACE         *surf = get_surface(get_vlist(param, NULL));
330          double          area;
331          int             i;
332  
# Line 341 | Line 364 | start_rcontrib(SUBPROC *pd, ZONE *zp)
364          IDF_FIELD       *fptr;
365          int             i, j, n;
366                                                  /* start oconv command */
367 <        sprintf(cbuf, "oconv - > '%s'", temp_octree);
367 >        sprintf(cbuf, "oconv - > \"%s\"", temp_octree);
368          if ((ofp = popen(cbuf, "w")) == NULL) {
369                  fputs(progname, stderr);
370                  fputs(": cannot open oconv process\n", stderr);
# Line 371 | Line 394 | start_rcontrib(SUBPROC *pd, ZONE *zp)
394                                                  /* now subsurfaces */
395          if (zp->ntotal > zp->nsurf) {
396                  if (zp->area_redu != NULL)
397 <                        memset(zp->area_redu, 0, sizeof(float)*zp->nsurf);
398 <                else if ((zp->area_redu = (float *)calloc(zp->nsurf,
397 >                        memset(zp->area_redu, 0, sizeof(float)*zp->ntotal);
398 >                else if ((zp->area_redu = (float *)calloc(zp->ntotal,
399                                                  sizeof(float))) == NULL)
400                          return(0);
401          }
# Line 632 | Line 655 | compute_zones(void)
655          for (zptr = zone_list; zptr != NULL; zptr = zptr->next) {
656                  SUBPROC rcproc;
657                                                  /* start rcontrib process */
658 +                rcproc = sp_inactive;
659                  if (!start_rcontrib(&rcproc, zptr))
660                          return(0);
661                                                  /* compute+add view factors */
# Line 687 | Line 711 | main(int argc, char *argv[])
711                  fputs("'\n", stderr);
712                  return(1);
713          }
714 +                                                /* check version (warning) */
715 +        if ((pptr = idf_getobject(our_idf, "Version")) != NULL &&
716 +                        pptr->flist != NULL && pptr->flist->val[0] != '9') {
717 +                fputs(progname, stderr);
718 +                fputs(": warning - written for IDF version 9.x, not ",
719 +                                stderr);
720 +                fputs(pptr->flist->val, stderr);
721 +                fputc('\n', stderr);
722 +        }
723                                                  /* remove existing UVFs */
724          if ((pptr = idf_getobject(our_idf, UVF_PNAME)) != NULL) {
725                  IDF_OBJECT      *pnext;
# Line 695 | Line 728 | main(int argc, char *argv[])
728                  do {
729                          pnext = pptr->pnext;
730                          idf_delobject(our_idf, pptr);
731 <                } while (pnext != NULL);
731 >                } while ((pptr = pnext) != NULL);
732          }
733                                                  /* add to header */
734          if (our_idf->hrem == NULL ||

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines