| 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" |
| 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 */ |
| 178 |
|
static IDF_FIELD * |
| 179 |
|
get_vlist(IDF_OBJECT *param, const char *zname) |
| 180 |
|
{ |
| 181 |
< |
static const int itm_len = sizeof(IDF_FIELD)+6; |
| 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; |
| 205 |
|
} |
| 206 |
|
res = idf_getfield(param, surf_type[i].vert_fld); |
| 207 |
|
} |
| 208 |
< |
if (!res->val[0]) { /* hack for missing #vert */ |
| 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; |
| 221 |
|
sprintf(res->val, "%d", i/3); |
| 222 |
|
} |
| 223 |
|
return(res); |
| 224 |
+ |
#undef itm_len |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
/* Get/allocate surface polygon */ |
| 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); |
| 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 |
|
} |
| 534 |
|
dv[2]*ps->sdir[2][j] ; |
| 535 |
|
} |
| 536 |
|
/* send to our process */ |
| 537 |
< |
writebuf(ps->wd, (char *)samp, sizeof(float)*6*ns); |
| 537 |
> |
writebuf(ps->wd, samp, sizeof(float)*6*ns); |
| 538 |
|
free(samp); /* that's it! */ |
| 539 |
|
return(1); |
| 540 |
|
} |
| 605 |
|
else /* comp. for subsurface area */ |
| 606 |
|
adj_factor /= adj_factor - zp->area_redu[n]; |
| 607 |
|
/* read results */ |
| 608 |
< |
if (readbuf(pd->r, (char *)uvfa, sizeof(float)*3*zp->ntotal) != |
| 608 |
> |
if (readbuf(pd->r, uvfa, sizeof(float)*3*zp->ntotal) != |
| 609 |
|
sizeof(float)*3*zp->ntotal) { |
| 610 |
|
fputs(progname, stderr); |
| 611 |
|
fputs(": read error from rcontrib process\n", stderr); |
| 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 */ |
| 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; |
| 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 || |