ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rxtmain.cpp
(Generate patch)

Comparing ray/src/rt/rxtmain.cpp (file contents):
Revision 2.1 by greg, Mon Aug 21 22:39:05 2023 UTC vs.
Revision 2.13 by greg, Tue Apr 22 17:12:25 2025 UTC

# Line 2 | Line 2
2   static const char       RCSid[] = "$Id$";
3   #endif
4   /*
5 < *  rtmain.c - main for rtrace per-ray calculation program
5 > *  rxtmain.cpp - main for per-ray calculation program
6   */
7  
8   #include "copyright.h"
# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   #include  "rtprocess.h" /* getpid() */
13   #include  "platform.h"
14   #include  "RtraceSimulManager.h"
15 + #include  "func.h"
16  
17   extern char     *progname;              /* global argv[0] */
18  
# Line 43 | Line 44 | extern void  tranotify(OBJECT obj);
44   char  *tralist[MAXMODLIST];             /* list of modifers to trace (or no) */
45   int  traincl = -1;                      /* include == 1, exclude == 0 */
46  
47 + double  (*sens_curve)(const SCOLOR scol) = NULL;        /* spectral conversion for 1-channel */
48 + double  out_scalefactor = 1;            /* output calibration scale factor */
49 + RGBPRIMP  out_prims = stdprims;         /* output color primitives (NULL if spectral) */
50 + static RGBPRIMS  our_prims;             /* private output color primitives */
51 +
52   static void onsig(int  signo);
53   static void sigdie(int  signo, const char  *msg);
54   static void printdefaults(void);
55  
56 < #define RATRACE_FEATURES        "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \
57 <                        "HessianAmbientCache\nAmbientAveraging\n" \
58 <                        "AmbientValueSharing\nAdaptiveShadowTesting\n" \
59 <                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
56 > #define RXTRACE_FEATURES        "IrradianceCalc\nMultiprocessing\nDistanceLimiting\n" \
57 >                                "HessianAmbientCache\nAmbientAveraging\n" \
58 >                                "AmbientValueSharing\nAdaptiveShadowTesting\n" \
59 >                                "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
60 >                                "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
61  
62   int
63   main(int  argc, char  *argv[])
# Line 69 | Line 76 | main(int  argc, char  *argv[])
76          int  rval;
77          int  i;
78                                          /* global program name */
79 <        progname = argv[0] = fixargv0(argv[0]);
79 >        progname = argv[0];
80                                          /* feature check only? */
81 <        strcat(RFeatureList, RATRACE_FEATURES);
81 >        strcat(RFeatureList, RXTRACE_FEATURES);
82          if (argc > 1 && !strcmp(argv[1], "-features"))
83                  return feature_status(argc-2, argv+2);
84 +                                        /* initialize calcomp routines */
85 +        initfunc();
86                                          /* add trace notify function */
87          for (i = 0; addobjnotify[i] != NULL; i++)
88                  ;
# Line 107 | Line 116 | main(int  argc, char  *argv[])
116                  case 'n':                               /* number of cores */
117                          check(2,"i");
118                          nproc = atoi(argv[++i]);
110                        if (nproc < 0)
111                                error(USER, "bad number of processes");
119                          break;
120                  case 'x':                               /* x resolution */
121                          check(2,"i");
# Line 138 | Line 145 | main(int  argc, char  *argv[])
145                          break;
146                  case 'I':                               /* immed. irradiance */
147                          rval = myRTmanager.rtFlags & RTimmIrrad;
148 <                        check_bool(3,rval);
148 >                        check_bool(2,rval);
149                          if (rval) myRTmanager.rtFlags |= RTimmIrrad;
150                          else myRTmanager.rtFlags &= ~RTimmIrrad;
151                          break;
# Line 223 | Line 230 | main(int  argc, char  *argv[])
230                                  goto badopt;
231                          }
232                          break;
233 +                case 'p':                               /* value output */
234 +                        switch (argv[i][2]) {
235 +                        case 'R':                       /* standard RGB output */
236 +                                if (strcmp(argv[i]+2, "RGB"))
237 +                                        goto badopt;
238 +                                out_prims = stdprims;
239 +                                out_scalefactor = 1;
240 +                                sens_curve = NULL;
241 +                                break;
242 +                        case 'X':                       /* XYZ output */
243 +                                if (strcmp(argv[i]+2, "XYZ"))
244 +                                        goto badopt;
245 +                                out_prims = xyzprims;
246 +                                out_scalefactor = WHTEFFICACY;
247 +                                sens_curve = NULL;
248 +                                break;
249 +                        case 'c': {
250 +                                int     j;
251 +                                check(3,"ffffffff");
252 +                                rval = 0;
253 +                                for (j = 0; j < 8; j++) {
254 +                                        our_prims[0][j] = atof(argv[++i]);
255 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
256 +                                }
257 +                                if (rval) {
258 +                                        if (!colorprimsOK(our_prims))
259 +                                                error(USER, "illegal primary chromaticities");
260 +                                        out_prims = our_prims;
261 +                                } else
262 +                                        out_prims = stdprims;
263 +                                out_scalefactor = 1;
264 +                                sens_curve = NULL;
265 +                                } break;
266 +                        case 'Y':                       /* photopic response */
267 +                                if (argv[i][3])
268 +                                        goto badopt;
269 +                                sens_curve = scolor_photopic;
270 +                                out_scalefactor = WHTEFFICACY;
271 +                                break;
272 +                        case 'S':                       /* scotopic response */
273 +                                if (argv[i][3])
274 +                                        goto badopt;
275 +                                sens_curve = scolor_scotopic;
276 +                                out_scalefactor = WHTSCOTOPIC;
277 +                                break;
278 +                        case 'M':                       /* melanopic response */
279 +                                if (argv[i][3])
280 +                                        goto badopt;
281 +                                sens_curve = scolor_melanopic;
282 +                                out_scalefactor = WHTMELANOPIC;
283 +                                break;
284 +                        default:
285 +                                goto badopt;
286 +                        }
287 +                        break;
288 + #if MAXCSAMP>3
289 +                case 'c':                               /* output spectral results */
290 +                        if (argv[i][2] != 'o')
291 +                                goto badopt;
292 +                        rval = (out_prims == NULL) & (sens_curve == NULL);
293 +                        check_bool(3,rval);
294 +                        if (rval) {
295 +                                out_prims = NULL;
296 +                                sens_curve = NULL;
297 +                        } else if (out_prims == NULL)
298 +                                out_prims = stdprims;
299 +                        break;
300 + #endif
301                  default:
302                          goto badopt;
303                  }
304          }
305 +                                        /* set/check spectral sampling */
306 +        rval = setspectrsamp(CNDX, WLPART);
307 +        if (rval < 0)
308 +                error(USER, "unsupported spectral sampling");
309 +        if (sens_curve != NULL)
310 +                out_prims = NULL;
311 +        else if (out_prims != NULL) {
312 +                if (!rval)
313 +                        error(WARNING, "spectral range incompatible with color output");
314 +        } else if (NCSAMP == 3)
315 +                out_prims = stdprims;   /* 3 samples do not a spectrum make */
316                                          /* set up signal handling */
317          sigdie(SIGINT, "Interrupt");
318   #ifdef SIGHUP
# Line 270 | Line 356 | main(int  argc, char  *argv[])
356          if (outform != 'a')
357                  SET_FILE_BINARY(stdout);
358          if (doheader) {                 /* print header? */
359 <                static char     fmt[] = OCTFMT;
360 <                FILE *          octfp = fopen(argv[i], "rb");
275 <                if (checkheader(octfp, fmt, stdout) < 0)
276 <                        error(USER, "bad octree header");
277 <                fclose(octfp);
359 >                newheader("RADIANCE", stdout);
360 >                fputs(myRTmanager.GetHeadStr(), stdout);
361                  printargs(i, argv, stdout);
362                  printf("SOFTWARE= %s\n", VersionID);
363                  fputnow(stdout);
364                  if (rval > 0)           /* saved from setrtoutput() call */
365 <                        printf("NCOMP=%d\n", rval);
365 >                        fputncomp(rval, stdout);
366 >                if (NCSAMP > 3)
367 >                        fputwlsplit(WLPART, stdout);
368 >                if ((out_prims != stdprims) & (out_prims != NULL))
369 >                        fputprims(out_prims, stdout);
370                  if ((outform == 'f') | (outform == 'd'))
371                          fputendian(stdout);
372                  fputformat(formstr(outform), stdout);
373 <                putchar('\n');
373 >                fputc('\n', stdout);    /* end of header */
374          }
375          rtrace(NULL, nproc);            /* trace rays */
376          quit(0);                        /* clean up & exit */
# Line 309 | Line 396 | wputs(                         /* warning output function */
396  
397   void
398   eputs(                          /* put string to stderr */
399 <        char  *s
399 >        const char  *s
400   )
401   {
402          static int  midline = 0;
# Line 400 | Line 487 | printdefaults(void)                    /* print default values to stdou
487                  case '~': printf(" tilde"); break;
488                  }
489          putchar('\n');
490 +        if (sens_curve == scolor_photopic)
491 +                printf("-pY\t\t\t\t# photopic output\n");
492 +        else if (sens_curve == scolor_scotopic)
493 +                printf("-pS\t\t\t\t# scotopic output\n");
494 +        else if (sens_curve == scolor_melanopic)
495 +                printf("-pM\t\t\t\t# melanopic output\n");
496 +        else if (out_prims == stdprims)
497 +                printf("-pRGB\t\t\t\t# standard RGB color output\n");
498 +        else if (out_prims == xyzprims)
499 +                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
500 +        else if (out_prims != NULL)
501 +                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
502 +                                out_prims[RED][0], out_prims[RED][1],
503 +                                out_prims[GRN][0], out_prims[GRN][1],
504 +                                out_prims[BLU][0], out_prims[BLU][1],
505 +                                out_prims[WHT][0], out_prims[WHT][1]);
506 +        if ((sens_curve == NULL) & (NCSAMP > 3))
507 +                printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" :
508 +                                "-co+\t\t\t\t# output spectral values\n");
509          printf(erract[WARNING].pf != NULL ?
510                          "-w+\t\t\t\t# warning messages on\n" :
511                          "-w-\t\t\t\t# warning messages off\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines