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.4 by greg, Mon Feb 10 17:50:02 2014 UTC vs.
Revision 2.5 by greg, Tue Feb 11 21:17:29 2014 UTC

# Line 16 | Line 16 | static const char RCSid[] = "$Id$";
16   #include "rtprocess.h"
17  
18   #ifndef NSAMPLES
19 < #define NSAMPLES        100000                  /* number of samples to use */
19 > #define NSAMPLES        10000                   /* number of samples to use */
20   #endif
21  
22   char            *progname;                      /* global argv[0] */
23  
24 < char            temp_octree[128];                       /* temporary octree */
24 > char            temp_octree[128];               /* temporary octree */
25  
26   const char      UVF_PNAME[] =
27                          "ZoneProperty:UserViewFactor:bySurfaceName";
28  
29   const char      ADD_HEADER[] =
30 <                        "!+++ User View Factors computed by Radiance +++!\n";
30 >                        "\n!+++ User View Factors computed by Radiance +++!\n\n";
31  
32   #define NAME_FLD        1                       /* name field always first? */
33  
# Line 39 | Line 39 | typedef struct {
39  
40   const SURF_PTYPE        surf_type[] = {
41                  {"BuildingSurface:Detailed", 4, 10},
42 +                {"Floor:Detailed", 3, 9},
43 +                {"RoofCeiling:Detailed", 3, 9},
44 +                {"Wall:Detailed", 3, 9},
45                  {NULL}
46          };
47  
# Line 143 | Line 146 | rad_surface(IDF_PARAMETER *param, FILE *ofp)
146   static int
147   start_rcontrib(SUBPROC *pd, ZONE *zp)
148   {
149 < #define BASE_AC         3
149 > #define BASE_AC         5
150          static char     *base_av[BASE_AC] = {
151 <                                "rcontrib", "-ff", "-h"
151 >                                "rcontrib", "-ff", "-h", "-x", "1"
152                          };
153          char            cbuf[300];
154          char            **av;
# Line 221 | Line 224 | init_poly(POLYSAMP *ps, IDF_FIELD *f0, int nv)
224          vl3 = (FVECT *)malloc(sizeof(FVECT)*nv);
225          if (vl3 == NULL)
226                  return(NULL);
227 <        for (i = 0; i < nv; i++)
227 >        for (i = nv; i--; )             /* reverse vertex ordering */
228                  for (j = 0; j < 3; j++) {
229                          if (fptr == NULL) {
230                                  fputs(progname, stderr);
231 <                                fputs(": bad vertex in init_poly()\n", stderr);
231 >                                fputs(": missing vertex in init_poly()\n", stderr);
232                                  return(NULL);
233                          }
234                          vl3[i][j] = atof(fptr->val);
235 +                        fptr = fptr->next;
236                  }
237                                          /* compute area and normal */
238          ps->sdir[2][0] = ps->sdir[2][1] = ps->sdir[2][2] = 0;
# Line 252 | Line 256 | init_poly(POLYSAMP *ps, IDF_FIELD *f0, int nv)
256          normalize(ps->sdir[0]);
257          fcross(ps->sdir[1], ps->sdir[2], ps->sdir[0]);
258                                          /* compute plane offset */
259 <        ps->poff = DOT(vl3[0], ps->sdir[2]) + FTINY;
259 >        ps->poff = DOT(vl3[0], ps->sdir[2]);
260                                          /* assign 2-D vertices */
261          for (i = 0; i < nv; i++) {
262                  vl2->v[i].mX = DOT(vl3[i], ps->sdir[0]);
# Line 276 | Line 280 | sample_triangle(const Vert2_list *vl2, int a, int b, i
280          for (i = 3; i--; ) {
281                  orig[i] = vl2->v[a].mX*ps->sdir[0][i] +
282                                  vl2->v[a].mY*ps->sdir[1][i] +
283 <                                ps->poff*ps->sdir[2][i];
283 >                                (ps->poff+.001)*ps->sdir[2][i];
284                  ab[i] = (vl2->v[b].mX - vl2->v[a].mX)*ps->sdir[0][i] +
285                                  (vl2->v[b].mY - vl2->v[a].mY)*ps->sdir[1][i];
286                  ac[i] = (vl2->v[c].mX - vl2->v[a].mX)*ps->sdir[0][i] +
# Line 307 | Line 311 | sample_triangle(const Vert2_list *vl2, int a, int b, i
311                  return(0);
312          for (i = ns; i--; ) {           /* stratified Monte Carlo sampling */
313                  double  sv[4];
314 +                FVECT   dv;
315                  multisamp(sv, 4, (i+frandom())/(double)ns);
316                  sv[0] *= sv[1] = sqrt(sv[1]);
317                  sv[1] = 1. - sv[1];
318                  for (j = 3; j--; )
319 <                        samp[ns*6 + j] = orig[j] + sv[0]*ab[j] + sv[1]*ac[j];
320 <                sv[3] = sqrt(sv[3]);
321 <                sv[4] *= 2.*PI;
322 <                samp[ns*6 + 3] = tcos(sv[4]) * sv[3];
323 <                samp[ns*6 + 4] = tsin(sv[4]) * sv[3];
324 <                samp[ns*6 + 5] = sqrt(1. - sv[3]*sv[3]);
319 >                        samp[i*6 + j] = orig[j] + sv[0]*ab[j] + sv[1]*ac[j];
320 >                sv[2] = sqrt(sv[2]);
321 >                sv[3] *= 2.*PI;
322 >                dv[0] = tcos(sv[3]) * sv[2];
323 >                dv[1] = tsin(sv[3]) * sv[2];
324 >                dv[2] = sqrt(1. - sv[2]*sv[2]);
325 >                for (j = 3; j--; )
326 >                        samp[i*6 + 3 + j] = dv[0]*ps->sdir[0][j] +
327 >                                                dv[1]*ps->sdir[1][j] +
328 >                                                dv[2]*ps->sdir[2][j] ;
329          }
330                                          /* send to our process */
331          writebuf(ps->wd, (char *)samp, sizeof(float)*6*ns);
# Line 333 | Line 342 | sample_surface(IDF_PARAMETER *param, int wd)
342          int             nv;
343          Vert2_list      *vlist2;
344                                          /* set up our polygon sampler */
345 <        if (fptr == NULL || (nv = atoi(fptr->val)) < 3) {
346 <                fprintf(stderr, "%s: error in %s '%s'\n",
345 >        if (fptr == NULL || (nv = atoi(fptr->val)) < 3 ||
346 >                        (vlist2 = init_poly(&psamp, fptr->next, nv)) == NULL) {
347 >                fprintf(stderr, "%s: bad polygon %s '%s'\n",
348                                  progname, param->pname,
349                                  idf_getfield(param,NAME_FLD)->val);
350                  return(0);
351          }
342        vlist2 = init_poly(&psamp, fptr->next, nv);
343        if (vlist2 == NULL)
344                return(0);
352          psamp.samp_left = NSAMPLES;     /* assign samples & destination */
353          psamp.wd = wd;
354                                          /* sample each subtriangle */
# Line 397 | Line 404 | compute_uvfs(SUBPROC *pd, ZONE *zp)
404                          if (pptr1 == pptr) {
405                                  if (uvfa[3*m + 1] > .001)
406                                          fprintf(stderr,
407 <                "%s: warning - non-zero self-VF (%.3e) for surface '%s'\n",
408 <                                                progname, uvfa[3*m + 1],
407 >                "%s: warning - non-zero self-VF (%.1f%%) for surface '%s'\n",
408 >                                                progname, 100.*uvfa[3*m + 1],
409                                                  idf_getfield(pptr,NAME_FLD)->val);
410                                  continue;       /* don't record self-factor */
411                          }
# Line 431 | Line 438 | compute_zones(void)
438   {
439          ZONE    *zptr;
440                                                  /* temporary octree name */
441 <        if (temp_filename(temp_octree, sizeof(temp_octree), TEMPLATE) == NULL) {
435 <                fputs(progname, stderr);
436 <                fputs(": cannot create temporary octree\n", stderr);
437 <                return(0);
438 <        }
441 >        mktemp(strcpy(temp_octree, TEMPLATE));
442                                                  /* compute each zone */
443          for (zptr = zone_list; zptr != NULL; zptr = zptr->next) {
444                  SUBPROC rcproc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines