| 1 |
greg |
2.1 |
#ifndef lint
|
| 2 |
greg |
2.35 |
static const char RCSid[] = "$Id: pabopto2bsdf.c,v 2.34 2019/04/23 17:18:18 greg Exp $";
|
| 3 |
greg |
2.1 |
#endif
|
| 4 |
|
|
/*
|
| 5 |
|
|
* Load measured BSDF data in PAB-Opto format.
|
| 6 |
greg |
2.29 |
* Assumes that surface-normal (Z-axis) faces into room unless -t option given.
|
| 7 |
greg |
2.1 |
*
|
| 8 |
|
|
* G. Ward
|
| 9 |
|
|
*/
|
| 10 |
|
|
|
| 11 |
greg |
2.20 |
#define _USE_MATH_DEFINES
|
| 12 |
greg |
2.1 |
#include <stdio.h>
|
| 13 |
greg |
2.2 |
#include <stdlib.h>
|
| 14 |
greg |
2.1 |
#include <string.h>
|
| 15 |
|
|
#include <ctype.h>
|
| 16 |
greg |
2.6 |
#include <math.h>
|
| 17 |
greg |
2.1 |
#include "platform.h"
|
| 18 |
|
|
#include "bsdfrep.h"
|
| 19 |
greg |
2.15 |
#include "resolu.h"
|
| 20 |
greg |
2.1 |
/* global argv[0] */
|
| 21 |
|
|
char *progname;
|
| 22 |
|
|
|
| 23 |
greg |
2.2 |
typedef struct {
|
| 24 |
|
|
const char *fname; /* input file path */
|
| 25 |
greg |
2.27 |
double theta, phi; /* input angles (degrees) */
|
| 26 |
|
|
double up_phi; /* azimuth for "up" direction */
|
| 27 |
greg |
2.20 |
int igp[2]; /* input grid position */
|
| 28 |
greg |
2.2 |
int isDSF; /* data is DSF (rather than BSDF)? */
|
| 29 |
greg |
2.28 |
int nspec; /* number of spectral samples */
|
| 30 |
greg |
2.2 |
long dstart; /* data start offset in file */
|
| 31 |
|
|
} PGINPUT;
|
| 32 |
|
|
|
| 33 |
|
|
PGINPUT *inpfile; /* input files sorted by incidence */
|
| 34 |
|
|
int ninpfiles; /* number of input files */
|
| 35 |
|
|
|
| 36 |
greg |
2.29 |
int rev_orient = 0; /* shall we reverse surface orientation? */
|
| 37 |
|
|
|
| 38 |
greg |
2.2 |
/* Compare incident angles */
|
| 39 |
|
|
static int
|
| 40 |
greg |
2.20 |
cmp_indir(const void *p1, const void *p2)
|
| 41 |
greg |
2.2 |
{
|
| 42 |
|
|
const PGINPUT *inp1 = (const PGINPUT *)p1;
|
| 43 |
|
|
const PGINPUT *inp2 = (const PGINPUT *)p2;
|
| 44 |
greg |
2.20 |
int ydif = inp1->igp[1] - inp2->igp[1];
|
| 45 |
greg |
2.2 |
|
| 46 |
greg |
2.20 |
if (ydif)
|
| 47 |
|
|
return(ydif);
|
| 48 |
|
|
|
| 49 |
|
|
return(inp1->igp[0] - inp2->igp[0]);
|
| 50 |
greg |
2.2 |
}
|
| 51 |
|
|
|
| 52 |
|
|
/* Prepare a PAB-Opto input file by reading its header */
|
| 53 |
greg |
2.1 |
static int
|
| 54 |
greg |
2.2 |
init_pabopto_inp(const int i, const char *fname)
|
| 55 |
greg |
2.1 |
{
|
| 56 |
|
|
FILE *fp = fopen(fname, "r");
|
| 57 |
greg |
2.20 |
FVECT dv;
|
| 58 |
greg |
2.1 |
char buf[2048];
|
| 59 |
greg |
2.2 |
int c;
|
| 60 |
greg |
2.1 |
|
| 61 |
|
|
if (fp == NULL) {
|
| 62 |
|
|
fputs(fname, stderr);
|
| 63 |
|
|
fputs(": cannot open\n", stderr);
|
| 64 |
|
|
return(0);
|
| 65 |
|
|
}
|
| 66 |
greg |
2.2 |
inpfile[i].fname = fname;
|
| 67 |
|
|
inpfile[i].isDSF = -1;
|
| 68 |
greg |
2.28 |
inpfile[i].nspec = 0;
|
| 69 |
greg |
2.27 |
inpfile[i].up_phi = 0;
|
| 70 |
greg |
2.2 |
inpfile[i].theta = inpfile[i].phi = -10001.;
|
| 71 |
greg |
2.1 |
/* read header information */
|
| 72 |
|
|
while ((c = getc(fp)) == '#' || c == EOF) {
|
| 73 |
greg |
2.28 |
char typ[64];
|
| 74 |
greg |
2.1 |
if (fgets(buf, sizeof(buf), fp) == NULL) {
|
| 75 |
|
|
fputs(fname, stderr);
|
| 76 |
|
|
fputs(": unexpected EOF\n", stderr);
|
| 77 |
|
|
fclose(fp);
|
| 78 |
|
|
return(0);
|
| 79 |
|
|
}
|
| 80 |
greg |
2.10 |
if (sscanf(buf, "sample_name \"%[^\"]\"", bsdf_name) == 1)
|
| 81 |
|
|
continue;
|
| 82 |
greg |
2.28 |
if (sscanf(buf, "colorimetry: %s", typ) == 1) {
|
| 83 |
|
|
if (!strcasecmp(typ, "CIE-XYZ"))
|
| 84 |
|
|
inpfile[i].nspec = 3;
|
| 85 |
|
|
else if (!strcasecmp(typ, "CIE-Y"))
|
| 86 |
|
|
inpfile[i].nspec = 1;
|
| 87 |
|
|
continue;
|
| 88 |
|
|
}
|
| 89 |
greg |
2.5 |
if (sscanf(buf, "format: theta phi %s", typ) == 1) {
|
| 90 |
greg |
2.28 |
if (!strcasecmp(typ, "DSF"))
|
| 91 |
greg |
2.5 |
inpfile[i].isDSF = 1;
|
| 92 |
greg |
2.28 |
else if (!strcasecmp(typ, "BSDF") ||
|
| 93 |
greg |
2.23 |
!strcasecmp(typ, "BRDF") ||
|
| 94 |
greg |
2.28 |
!strcasecmp(typ, "BTDF"))
|
| 95 |
greg |
2.5 |
inpfile[i].isDSF = 0;
|
| 96 |
greg |
2.28 |
continue;
|
| 97 |
greg |
2.1 |
}
|
| 98 |
greg |
2.27 |
if (sscanf(buf, "upphi %lf", &inpfile[i].up_phi) == 1)
|
| 99 |
|
|
continue;
|
| 100 |
greg |
2.2 |
if (sscanf(buf, "intheta %lf", &inpfile[i].theta) == 1)
|
| 101 |
greg |
2.1 |
continue;
|
| 102 |
greg |
2.2 |
if (sscanf(buf, "inphi %lf", &inpfile[i].phi) == 1)
|
| 103 |
greg |
2.1 |
continue;
|
| 104 |
|
|
if (sscanf(buf, "incident_angle %lf %lf",
|
| 105 |
greg |
2.2 |
&inpfile[i].theta, &inpfile[i].phi) == 2)
|
| 106 |
greg |
2.1 |
continue;
|
| 107 |
|
|
}
|
| 108 |
greg |
2.2 |
inpfile[i].dstart = ftell(fp) - 1;
|
| 109 |
|
|
fclose(fp);
|
| 110 |
|
|
if (inpfile[i].isDSF < 0) {
|
| 111 |
greg |
2.1 |
fputs(fname, stderr);
|
| 112 |
|
|
fputs(": unknown format\n", stderr);
|
| 113 |
|
|
return(0);
|
| 114 |
|
|
}
|
| 115 |
greg |
2.2 |
if ((inpfile[i].theta < -10000.) | (inpfile[i].phi < -10000.)) {
|
| 116 |
|
|
fputs(fname, stderr);
|
| 117 |
|
|
fputs(": unknown incident angle\n", stderr);
|
| 118 |
|
|
return(0);
|
| 119 |
|
|
}
|
| 120 |
greg |
2.29 |
if (rev_orient) { /* reverse Z-axis to face outside */
|
| 121 |
|
|
inpfile[i].theta = 180. - inpfile[i].theta;
|
| 122 |
|
|
inpfile[i].phi = 360. - inpfile[i].phi;
|
| 123 |
|
|
}
|
| 124 |
greg |
2.27 |
/* convert to Y-up orientation */
|
| 125 |
|
|
inpfile[i].phi += 90.-inpfile[i].up_phi;
|
| 126 |
greg |
2.20 |
/* convert angle to grid position */
|
| 127 |
|
|
dv[2] = sin(M_PI/180.*inpfile[i].theta);
|
| 128 |
|
|
dv[0] = cos(M_PI/180.*inpfile[i].phi)*dv[2];
|
| 129 |
|
|
dv[1] = sin(M_PI/180.*inpfile[i].phi)*dv[2];
|
| 130 |
|
|
dv[2] = sqrt(1. - dv[2]*dv[2]);
|
| 131 |
greg |
2.30 |
if (inpfile[i].theta <= FTINY)
|
| 132 |
|
|
inpfile[i].igp[0] = inpfile[i].igp[1] = grid_res/2 - 1;
|
| 133 |
|
|
else
|
| 134 |
|
|
pos_from_vec(inpfile[i].igp, dv);
|
| 135 |
greg |
2.2 |
return(1);
|
| 136 |
|
|
}
|
| 137 |
|
|
|
| 138 |
|
|
/* Load a set of measurements corresponding to a particular incident angle */
|
| 139 |
|
|
static int
|
| 140 |
|
|
add_pabopto_inp(const int i)
|
| 141 |
|
|
{
|
| 142 |
greg |
2.19 |
FILE *fp = fopen(inpfile[i].fname, "r");
|
| 143 |
greg |
2.28 |
double theta_out, phi_out, val[3];
|
| 144 |
greg |
2.19 |
int n, c;
|
| 145 |
greg |
2.2 |
|
| 146 |
|
|
if (fp == NULL || fseek(fp, inpfile[i].dstart, 0) == EOF) {
|
| 147 |
|
|
fputs(inpfile[i].fname, stderr);
|
| 148 |
|
|
fputs(": cannot open\n", stderr);
|
| 149 |
|
|
return(0);
|
| 150 |
|
|
}
|
| 151 |
greg |
2.1 |
/* prepare input grid */
|
| 152 |
greg |
2.20 |
if (!i || cmp_indir(&inpfile[i-1], &inpfile[i])) {
|
| 153 |
|
|
if (i) /* process previous incidence */
|
| 154 |
greg |
2.2 |
make_rbfrep();
|
| 155 |
|
|
#ifdef DEBUG
|
| 156 |
greg |
2.22 |
fprintf(stderr, "New incident (theta,phi)=(%.1f,%.1f)\n",
|
| 157 |
greg |
2.2 |
inpfile[i].theta, inpfile[i].phi);
|
| 158 |
|
|
#endif
|
| 159 |
greg |
2.28 |
if (inpfile[i].nspec)
|
| 160 |
|
|
set_spectral_samples(inpfile[i].nspec);
|
| 161 |
greg |
2.2 |
new_bsdf_data(inpfile[i].theta, inpfile[i].phi);
|
| 162 |
|
|
}
|
| 163 |
greg |
2.3 |
#ifdef DEBUG
|
| 164 |
|
|
fprintf(stderr, "Loading measurements from '%s'...\n", inpfile[i].fname);
|
| 165 |
|
|
#endif
|
| 166 |
greg |
2.2 |
/* read scattering data */
|
| 167 |
greg |
2.28 |
while (fscanf(fp, "%lf %lf %lf", &theta_out, &phi_out, val) == 3) {
|
| 168 |
|
|
for (n = 1; n < inpfile[i].nspec; n++)
|
| 169 |
|
|
if (fscanf(fp, "%lf", val+n) != 1) {
|
| 170 |
|
|
fprintf(stderr, "%s: warning: unexpected EOF\n",
|
| 171 |
|
|
inpfile[i].fname);
|
| 172 |
|
|
fclose(fp);
|
| 173 |
|
|
return(1);
|
| 174 |
|
|
}
|
| 175 |
greg |
2.29 |
if (rev_orient) { /* reverse Z-axis to face outside */
|
| 176 |
|
|
theta_out = 180. - theta_out;
|
| 177 |
|
|
phi_out = 360. - phi_out;
|
| 178 |
|
|
}
|
| 179 |
greg |
2.27 |
add_bsdf_data(theta_out, phi_out+90.-inpfile[i].up_phi,
|
| 180 |
|
|
val, inpfile[i].isDSF);
|
| 181 |
greg |
2.28 |
}
|
| 182 |
greg |
2.1 |
n = 0;
|
| 183 |
|
|
while ((c = getc(fp)) != EOF)
|
| 184 |
|
|
n += !isspace(c);
|
| 185 |
|
|
if (n)
|
| 186 |
|
|
fprintf(stderr,
|
| 187 |
|
|
"%s: warning: %d unexpected characters past EOD\n",
|
| 188 |
greg |
2.2 |
inpfile[i].fname, n);
|
| 189 |
greg |
2.1 |
fclose(fp);
|
| 190 |
|
|
return(1);
|
| 191 |
|
|
}
|
| 192 |
|
|
|
| 193 |
greg |
2.8 |
#ifndef TEST_MAIN
|
| 194 |
greg |
2.35 |
|
| 195 |
|
|
#define SYM_ILL '?' /* illegal symmetry value */
|
| 196 |
|
|
#define SYM_ISO 'I' /* isotropic */
|
| 197 |
|
|
#define SYM_QUAD 'Q' /* quadrilateral symmetry */
|
| 198 |
|
|
#define SYM_BILAT 'B' /* bilateral symmetry */
|
| 199 |
|
|
#define SYM_ANISO 'A' /* anisotropic */
|
| 200 |
|
|
|
| 201 |
|
|
static const char quadrant_rep[16][16] = {
|
| 202 |
|
|
"in-plane","0-90","90-180","0-180",
|
| 203 |
|
|
"180-270","0-90+180-270","90-270",
|
| 204 |
|
|
"0-270","270-360","270-90",
|
| 205 |
|
|
"90-180+270-360","270-180","180-360",
|
| 206 |
|
|
"180-90","90-360","0-360"
|
| 207 |
|
|
};
|
| 208 |
|
|
static const char quadrant_sym[16] = {
|
| 209 |
|
|
SYM_ISO, SYM_QUAD, SYM_QUAD, SYM_BILAT,
|
| 210 |
|
|
SYM_QUAD, SYM_ILL, SYM_BILAT, SYM_ILL,
|
| 211 |
|
|
SYM_QUAD, SYM_BILAT, SYM_ILL, SYM_ILL,
|
| 212 |
|
|
SYM_BILAT, SYM_ILL, SYM_ILL, SYM_ANISO
|
| 213 |
|
|
};
|
| 214 |
|
|
|
| 215 |
greg |
2.1 |
/* Read in PAB-Opto BSDF files and output RBF interpolant */
|
| 216 |
|
|
int
|
| 217 |
|
|
main(int argc, char *argv[])
|
| 218 |
|
|
{
|
| 219 |
greg |
2.35 |
extern int nprocs;
|
| 220 |
|
|
const char *symmetry = "U";
|
| 221 |
|
|
int i;
|
| 222 |
greg |
2.1 |
/* start header */
|
| 223 |
|
|
SET_FILE_BINARY(stdout);
|
| 224 |
|
|
newheader("RADIANCE", stdout);
|
| 225 |
|
|
printargs(argc, argv, stdout);
|
| 226 |
|
|
fputnow(stdout);
|
| 227 |
|
|
progname = argv[0]; /* get options */
|
| 228 |
|
|
while (argc > 2 && argv[1][0] == '-') {
|
| 229 |
|
|
switch (argv[1][1]) {
|
| 230 |
greg |
2.29 |
case 't':
|
| 231 |
|
|
rev_orient = !rev_orient;
|
| 232 |
|
|
break;
|
| 233 |
greg |
2.1 |
case 'n':
|
| 234 |
|
|
nprocs = atoi(argv[2]);
|
| 235 |
greg |
2.29 |
argv++; argc--;
|
| 236 |
greg |
2.1 |
break;
|
| 237 |
greg |
2.33 |
case 's':
|
| 238 |
|
|
symmetry = argv[2];
|
| 239 |
|
|
argv++; argc--;
|
| 240 |
|
|
break;
|
| 241 |
greg |
2.1 |
default:
|
| 242 |
|
|
goto userr;
|
| 243 |
|
|
}
|
| 244 |
greg |
2.29 |
argv++; argc--;
|
| 245 |
greg |
2.1 |
}
|
| 246 |
greg |
2.2 |
/* initialize & sort inputs */
|
| 247 |
|
|
ninpfiles = argc - 1;
|
| 248 |
|
|
if (ninpfiles < 2)
|
| 249 |
greg |
2.1 |
goto userr;
|
| 250 |
greg |
2.2 |
inpfile = (PGINPUT *)malloc(sizeof(PGINPUT)*ninpfiles);
|
| 251 |
|
|
if (inpfile == NULL)
|
| 252 |
|
|
return(1);
|
| 253 |
|
|
for (i = 0; i < ninpfiles; i++)
|
| 254 |
|
|
if (!init_pabopto_inp(i, argv[i+1]))
|
| 255 |
greg |
2.1 |
return(1);
|
| 256 |
greg |
2.25 |
qsort(inpfile, ninpfiles, sizeof(PGINPUT), cmp_indir);
|
| 257 |
greg |
2.2 |
/* compile measurements */
|
| 258 |
|
|
for (i = 0; i < ninpfiles; i++)
|
| 259 |
|
|
if (!add_pabopto_inp(i))
|
| 260 |
|
|
return(1);
|
| 261 |
|
|
make_rbfrep(); /* process last data set */
|
| 262 |
greg |
2.33 |
/* check input symmetry */
|
| 263 |
|
|
switch (toupper(symmetry[0])) {
|
| 264 |
greg |
2.35 |
case 'U': /* unspecified symmetry */
|
| 265 |
|
|
if (quadrant_sym[inp_coverage] != SYM_ILL)
|
| 266 |
|
|
break; /* anything legal goes */
|
| 267 |
|
|
fprintf(stderr, "%s: unsupported phi coverage (%s)\n",
|
| 268 |
|
|
progname, quadrant_rep[inp_coverage]);
|
| 269 |
|
|
return(1);
|
| 270 |
|
|
case SYM_ISO: /* legal symmetry types */
|
| 271 |
|
|
case SYM_QUAD:
|
| 272 |
|
|
case SYM_BILAT:
|
| 273 |
|
|
case SYM_ANISO:
|
| 274 |
|
|
if (quadrant_sym[inp_coverage] == toupper(symmetry[0]))
|
| 275 |
|
|
break; /* matches spec */
|
| 276 |
|
|
fprintf(stderr,
|
| 277 |
|
|
"%s: phi coverage (%s) does not match requested '%s' symmetry\n",
|
| 278 |
|
|
progname, quadrant_rep[inp_coverage], symmetry);
|
| 279 |
|
|
return(1);
|
| 280 |
greg |
2.33 |
default:
|
| 281 |
|
|
fprintf(stderr,
|
| 282 |
|
|
"%s: -s option must be Isotropic, Quadrilateral, Bilateral, or Anisotropic\n",
|
| 283 |
|
|
progname);
|
| 284 |
|
|
return(1);
|
| 285 |
|
|
}
|
| 286 |
|
|
#ifdef DEBUG
|
| 287 |
greg |
2.35 |
fprintf(stderr, "Input phi coverage (%s) has '%c' symmetry\n",
|
| 288 |
|
|
quadrant_rep[inp_coverage],
|
| 289 |
|
|
quadrant_sym[inp_coverage]);
|
| 290 |
greg |
2.33 |
#endif
|
| 291 |
greg |
2.1 |
build_mesh(); /* create interpolation */
|
| 292 |
|
|
save_bsdf_rep(stdout); /* write it out */
|
| 293 |
|
|
return(0);
|
| 294 |
|
|
userr:
|
| 295 |
greg |
2.33 |
fprintf(stderr, "Usage: %s [-t][-n nproc][-s symmetry] meas1.dat meas2.dat .. > bsdf.sir\n",
|
| 296 |
greg |
2.1 |
progname);
|
| 297 |
|
|
return(1);
|
| 298 |
|
|
}
|
| 299 |
greg |
2.35 |
|
| 300 |
|
|
#else /* TEST_MAIN */
|
| 301 |
|
|
|
| 302 |
greg |
2.6 |
/* Test main produces a Radiance model from the given input file */
|
| 303 |
|
|
int
|
| 304 |
|
|
main(int argc, char *argv[])
|
| 305 |
|
|
{
|
| 306 |
|
|
PGINPUT pginp;
|
| 307 |
|
|
char buf[128];
|
| 308 |
|
|
FILE *pfp;
|
| 309 |
|
|
double bsdf, min_log;
|
| 310 |
|
|
FVECT dir;
|
| 311 |
|
|
int i, j, n;
|
| 312 |
|
|
|
| 313 |
greg |
2.21 |
progname = argv[0];
|
| 314 |
greg |
2.6 |
if (argc != 2) {
|
| 315 |
greg |
2.21 |
fprintf(stderr, "Usage: %s input.dat > output.rad\n", progname);
|
| 316 |
greg |
2.6 |
return(1);
|
| 317 |
|
|
}
|
| 318 |
|
|
ninpfiles = 1;
|
| 319 |
|
|
inpfile = &pginp;
|
| 320 |
|
|
if (!init_pabopto_inp(0, argv[1]) || !add_pabopto_inp(0))
|
| 321 |
|
|
return(1);
|
| 322 |
|
|
/* reduce data set */
|
| 323 |
greg |
2.21 |
if (make_rbfrep() == NULL) {
|
| 324 |
|
|
fprintf(stderr, "%s: nothing to plot!\n", progname);
|
| 325 |
|
|
exit(1);
|
| 326 |
|
|
}
|
| 327 |
greg |
2.9 |
#ifdef DEBUG
|
| 328 |
|
|
fprintf(stderr, "Minimum BSDF = %.4f\n", bsdf_min);
|
| 329 |
|
|
#endif
|
| 330 |
greg |
2.13 |
min_log = log(bsdf_min*.5 + 1e-5);
|
| 331 |
greg |
2.11 |
#if 1 /* produce spheres at meas. */
|
| 332 |
greg |
2.6 |
puts("void plastic yellow\n0\n0\n5 .6 .4 .01 .04 .08\n");
|
| 333 |
|
|
n = 0;
|
| 334 |
greg |
2.28 |
for (i = 0; i < grid_res; i++)
|
| 335 |
|
|
for (j = 0; j < grid_res; j++)
|
| 336 |
greg |
2.16 |
if (dsf_grid[i][j].sum.n > 0) {
|
| 337 |
greg |
2.6 |
ovec_from_pos(dir, i, j);
|
| 338 |
greg |
2.16 |
bsdf = dsf_grid[i][j].sum.v /
|
| 339 |
greg |
2.24 |
((double)dsf_grid[i][j].sum.n*output_orient*dir[2]);
|
| 340 |
greg |
2.6 |
if (bsdf <= bsdf_min*.6)
|
| 341 |
|
|
continue;
|
| 342 |
greg |
2.14 |
bsdf = log(bsdf + 1e-5) - min_log;
|
| 343 |
greg |
2.7 |
ovec_from_pos(dir, i, j);
|
| 344 |
|
|
printf("yellow sphere s%04d\n0\n0\n", ++n);
|
| 345 |
|
|
printf("4 %.6g %.6g %.6g %.6g\n\n",
|
| 346 |
greg |
2.6 |
dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf,
|
| 347 |
greg |
2.7 |
.007*bsdf);
|
| 348 |
greg |
2.6 |
}
|
| 349 |
greg |
2.11 |
#endif
|
| 350 |
|
|
#if 1 /* spheres at RBF peaks */
|
| 351 |
|
|
puts("void plastic red\n0\n0\n5 .8 .01 .01 .04 .08\n");
|
| 352 |
|
|
for (n = 0; n < dsf_list->nrbf; n++) {
|
| 353 |
|
|
RBFVAL *rbf = &dsf_list->rbfa[n];
|
| 354 |
|
|
ovec_from_pos(dir, rbf->gx, rbf->gy);
|
| 355 |
greg |
2.26 |
bsdf = eval_rbfrep(dsf_list, dir);
|
| 356 |
greg |
2.14 |
bsdf = log(bsdf + 1e-5) - min_log;
|
| 357 |
greg |
2.11 |
printf("red sphere p%04d\n0\n0\n", ++n);
|
| 358 |
|
|
printf("4 %.6g %.6g %.6g %.6g\n\n",
|
| 359 |
|
|
dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf,
|
| 360 |
|
|
.011*bsdf);
|
| 361 |
|
|
}
|
| 362 |
|
|
#endif
|
| 363 |
|
|
#if 1 /* output continuous surface */
|
| 364 |
greg |
2.6 |
puts("void trans tgreen\n0\n0\n7 .7 1 .7 .04 .04 .9 1\n");
|
| 365 |
|
|
fflush(stdout);
|
| 366 |
greg |
2.28 |
sprintf(buf, "gensurf tgreen bsdf - - - %d %d", grid_res-1, grid_res-1);
|
| 367 |
greg |
2.6 |
pfp = popen(buf, "w");
|
| 368 |
|
|
if (pfp == NULL) {
|
| 369 |
greg |
2.21 |
fprintf(stderr, "%s: cannot open '| %s'\n", progname, buf);
|
| 370 |
greg |
2.6 |
return(1);
|
| 371 |
|
|
}
|
| 372 |
greg |
2.28 |
for (i = 0; i < grid_res; i++)
|
| 373 |
|
|
for (j = 0; j < grid_res; j++) {
|
| 374 |
greg |
2.6 |
ovec_from_pos(dir, i, j);
|
| 375 |
greg |
2.26 |
bsdf = eval_rbfrep(dsf_list, dir);
|
| 376 |
greg |
2.14 |
bsdf = log(bsdf + 1e-5) - min_log;
|
| 377 |
greg |
2.6 |
fprintf(pfp, "%.8e %.8e %.8e\n",
|
| 378 |
|
|
dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf);
|
| 379 |
|
|
}
|
| 380 |
greg |
2.11 |
if (pclose(pfp) != 0)
|
| 381 |
|
|
return(1);
|
| 382 |
|
|
#endif
|
| 383 |
|
|
return(0);
|
| 384 |
greg |
2.6 |
}
|
| 385 |
greg |
2.35 |
|
| 386 |
|
|
#endif /* TEST_MAIN */
|