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

Comparing ray/src/cv/pabopto2xyz.c (file contents):
Revision 2.1 by greg, Wed Jul 27 18:05:53 2016 UTC vs.
Revision 2.7 by greg, Wed Dec 15 01:38:50 2021 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9  
10   #define _USE_MATH_DEFINES
11   #include "rtio.h"
12 + #include "fvect.h"
13   #include <stdlib.h>
14   #include <ctype.h>
15   #include <math.h>
# Line 39 | Line 40 | typedef struct {
40          float           *va;            /* corresponding value array */
41   } PGINTERP;
42  
42 extern void             SDdisk2square(double sq[2], double diskx, double disky);
43
43   char                    *progname;      /* global argv[0] */
44  
45 + int                     incident_side = 0;      /* signum(intheta) */
46 + int                     exiting_side = 0;       /* signum(outtheta) */
47 +
48   int                     nprocs = 1;     /* number of processes to run */
49  
50   int                     nchild = 0;     /* number of children (-1 in child) */
# Line 127 | Line 129 | run_subprocess(void)
129  
130   /* Compute square location from normalized input/output vector */
131   static void
132 < sq_from_ang(double sq[2], double theta, double phi)
132 > sq_from_ang(RREAL sq[2], double theta, double phi)
133   {
134          double  vec[3];
135          double  norm;
# Line 138 | Line 140 | sq_from_ang(double sq[2], double theta, double phi)
140          vec[2] = sqrt(1. - vec[2]*vec[2]);
141          norm = 1./sqrt(1. + vec[2]);
142  
143 <        SDdisk2square(sq, vec[0]*norm, vec[1]*norm);
143 >        disk2square(sq, vec[0]*norm, vec[1]*norm);
144   }
145  
146   /* Compute quantized grid position from normalized input/output vector */
147   static void
148   pos_from_ang(int gp[2], double theta, double phi)
149   {
150 <        double  sq[2];
150 >        RREAL   sq[2];
151  
152          sq_from_ang(sq, theta, phi);
153          gp[0] = (int)(sq[0]*ANGRES);
# Line 240 | Line 242 | init_pabopto_inp(PGINPUT *pgi, const char *fname)
242                  fputs(": unknown incident angle\n", stderr);
243                  return(0);
244          }
245 +        if (!incident_side) {
246 +                incident_side = (pgi->theta < 90.) ? 1 : -1;
247 +        } else if ((incident_side > 0) ^ (pgi->theta < 90.)) {
248 +                fputs(fname, stderr);
249 +                fputs(": incident on opposite side of surface\n", stderr);
250 +                return(0);
251 +        }
252                                  /* convert angle to grid position */
253          pos_from_ang(pgi->igp, pgi->theta, pgi->phi);
254          return(1);
# Line 280 | Line 289 | load_interp(PGINTERP *pgint, const int igp[2], const P
289                                  if ((pgint->ip2 == NULL) | (pgint->va == NULL))
290                                          goto memerr;
291                          }
292 +                        if (!exiting_side) {
293 +                                exiting_side = (theta < 90.) ? 1 : -1;
294 +                        } else if ((exiting_side > 0) ^ (theta < 90.)) {
295 +                                fputs(pginp->fname, stderr);
296 +                                fputs(": exiting measurement on wrong side\n", stderr);
297 +                                return(0);
298 +                        }
299                          sq_from_ang(sq, theta, phi);
300                          pgint->ip2->spt[nread][0] = sq[0]*ANGRES;
301                          pgint->ip2->spt[nread][1] = sq[1]*ANGRES;
# Line 305 | Line 321 | memerr:
321   static double
322   interp2val(const PGINTERP *pgint, double px, double py)
323   {
324 < #define NSMP    12
324 > #define NSMP    36
325          float   wt[NSMP];
326          int     si[NSMP];
327          int     n = interp2_topsamp(wt, si, NSMP, pgint->ip2, px, py);
# Line 371 | Line 387 | interp_xyz(const PGINPUT *inp0, int nf, const PGINTERP
387                                  inp0->fname, outfname);
388   #endif
389                  while (fscanf(ifp, "%lf %lf %lf", &theta, &phi, &val[0]) == 3) {
390 +                        if (!exiting_side) {
391 +                                exiting_side = (theta < 90.) ? 1 : -1;
392 +                        } else if ((exiting_side > 0) ^ (theta < 90.)) {
393 +                                fputs(inp0->fname, stderr);
394 +                                fputs(": exiting measurement on wrong side\n", stderr);
395 +                                return(0);
396 +                        }
397                          sq_from_ang(sq, theta, phi);
398                          val[1] = interp2val(int1, sq[0]*ANGRES, sq[1]*ANGRES);
399                          val[2] = interp2val(int2, sq[0]*ANGRES, sq[1]*ANGRES);
# Line 441 | Line 464 | advance_incidence(PGINPUT *slist[3], int ndx[3])
464   int
465   main(int argc, char *argv[])
466   {
444        char    *flist[MAX_INPUTS];
467          PGINPUT *slist[3];
468          int     i, j;
469          int     ndx[3];
# Line 467 | Line 489 | main(int argc, char *argv[])
489                  default:
490                          goto userr;
491                  }
492 <        if (i > argc-3)
492 >        if (i != argc-3)
493                  goto userr;
494          for (j = 0; j < 3; j++) {               /* prep input channels */
495 +                char    *flist[MAX_INPUTS];
496                  int     k, n;
497                  n = wordfile(flist, MAX_INPUTS, argv[i+j]);
498 <                if (n <= 0) {
498 >                if ((n <= 0) | (n >= MAX_INPUTS-1)) {
499                          fputs(argv[i+j], stderr);
500 <                        fputs(": cannot load input file names\n", stderr);
500 >                        if (n < 0)
501 >                                fputs(": cannot load input file names\n", stderr);
502 >                        else if (n == 0)
503 >                                fputs(": empty file\n", stderr);
504 >                        else /* n >= MAX_INPUTS-1 */
505 >                                fputs(": too many file names\n", stderr);
506                          return(1);
507                  }
508                  slist[j] = (PGINPUT *)malloc(sizeof(PGINPUT)*(n+1));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines