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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines