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

Comparing src/util/eplus_adduvf.c (file contents):
Revision 2.15 by greg, Fri Feb 28 19:14:10 2014 UTC vs.
Revision 2.24 by greg, Tue Jun 3 21:31:51 2025 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 21 | Line 23 | static const char RCSid[] = "$Id$";
23  
24   #define SURF_EPS        0.0005                  /* surface testing epsilon */
25  
24 char            *progname;                      /* global argv[0] */
25
26   int             nsamps = NSAMPLES;              /* number of samples to use */
27  
28   char            temp_octree[128];               /* temporary octree */
# Line 39 | Line 39 | const char     ADD_HEADER[] =
39   #define NAME_FLD        1                       /* name field always first? */
40  
41   #define SS_BASE_FLD     4                       /* subsurface base surface */
42 < #define SS_VERT_FLD     10                      /* subsurface vertex count */
42 > #define SS_VERT_FLD     9                       /* subsurface vertex count */
43  
44   typedef struct {
45          const char      *pname;                 /* object type name */
# Line 203 | Line 203 | get_vlist(IDF_OBJECT *param, const char *zname)
203                  }
204                  res = idf_getfield(param, surf_type[i].vert_fld);
205          }
206 <        if (!res->val[0]) {                     /* hack for missing #vert */
206 >        if (!res->val[0] || tolower(res->val[0]) == 'a') {  /* autocalculate */
207                  IDF_FIELD       *fptr;
208                  if (next_fbp >= fld_buf+sizeof(fld_buf))
209                          next_fbp = fld_buf;
# Line 362 | Line 362 | start_rcontrib(SUBPROC *pd, ZONE *zp)
362          IDF_FIELD       *fptr;
363          int             i, j, n;
364                                                  /* start oconv command */
365 <        sprintf(cbuf, "oconv - > '%s'", temp_octree);
365 >        sprintf(cbuf, "oconv - > \"%s\"", temp_octree);
366          if ((ofp = popen(cbuf, "w")) == NULL) {
367                  fputs(progname, stderr);
368                  fputs(": cannot open oconv process\n", stderr);
# Line 392 | Line 392 | start_rcontrib(SUBPROC *pd, ZONE *zp)
392                                                  /* now subsurfaces */
393          if (zp->ntotal > zp->nsurf) {
394                  if (zp->area_redu != NULL)
395 <                        memset(zp->area_redu, 0, sizeof(float)*zp->nsurf);
396 <                else if ((zp->area_redu = (float *)calloc(zp->nsurf,
395 >                        memset(zp->area_redu, 0, sizeof(float)*zp->ntotal);
396 >                else if ((zp->area_redu = (float *)calloc(zp->ntotal,
397                                                  sizeof(float))) == NULL)
398                          return(0);
399          }
# Line 532 | Line 532 | sample_triangle(const Vert2_list *vl2, int a, int b, i
532                                                  dv[2]*ps->sdir[2][j] ;
533          }
534                                          /* send to our process */
535 <        writebuf(ps->wd, (char *)samp, sizeof(float)*6*ns);
535 >        writebuf(ps->wd, samp, sizeof(float)*6*ns);
536          free(samp);                     /* that's it! */
537          return(1);
538   }
# Line 603 | Line 603 | compute_uvfs(SUBPROC *pd, ZONE *zp)
603                  else                            /* comp. for subsurface area */
604                          adj_factor /= adj_factor - zp->area_redu[n];
605                                                  /* read results */
606 <                if (readbuf(pd->r, (char *)uvfa, sizeof(float)*3*zp->ntotal) !=
606 >                if (readbuf(pd->r, uvfa, sizeof(float)*3*zp->ntotal) !=
607                                  sizeof(float)*3*zp->ntotal) {
608                          fputs(progname, stderr);
609                          fputs(": read error from rcontrib process\n", stderr);
# Line 653 | Line 653 | compute_zones(void)
653          for (zptr = zone_list; zptr != NULL; zptr = zptr->next) {
654                  SUBPROC rcproc;
655                                                  /* start rcontrib process */
656 +                rcproc = sp_inactive;
657                  if (!start_rcontrib(&rcproc, zptr))
658                          return(0);
659                                                  /* compute+add view factors */
# Line 677 | Line 678 | main(int argc, char *argv[])
678          IDF_OBJECT      *pptr;
679          int             i;
680  
681 <        progname = *argv++; argc--;             /* get options if any */
681 >        fixargv0(*argv++); argc--;              /* get options if any */
682          while (argc > 1 && argv[0][0] == '-')
683                  switch (argv[0][1]) {
684                  case 'c':                       /* elide comments */
# Line 708 | Line 709 | main(int argc, char *argv[])
709                  fputs("'\n", stderr);
710                  return(1);
711          }
712 +                                                /* check version (warning) */
713 +        if ((pptr = idf_getobject(our_idf, "Version")) != NULL &&
714 +                        pptr->flist != NULL && pptr->flist->val[0] != '9') {
715 +                fputs(progname, stderr);
716 +                fputs(": warning - written for IDF version 9.x, not ",
717 +                                stderr);
718 +                fputs(pptr->flist->val, stderr);
719 +                fputc('\n', stderr);
720 +        }
721                                                  /* remove existing UVFs */
722          if ((pptr = idf_getobject(our_idf, UVF_PNAME)) != NULL) {
723                  IDF_OBJECT      *pnext;
# Line 716 | Line 726 | main(int argc, char *argv[])
726                  do {
727                          pnext = pptr->pnext;
728                          idf_delobject(our_idf, pptr);
729 <                } while (pnext != NULL);
729 >                } while ((pptr = pnext) != NULL);
730          }
731                                                  /* add to header */
732          if (our_idf->hrem == NULL ||

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines