ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/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.16 by greg, Fri Dec 5 17:51:34 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 >                                "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
58 >                                "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
59 >                                "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
60  
61   int
62   main(int  argc, char  *argv[])
# Line 69 | Line 75 | main(int  argc, char  *argv[])
75          int  rval;
76          int  i;
77                                          /* global program name */
78 <        progname = argv[0] = fixargv0(argv[0]);
78 >        progname = argv[0];
79                                          /* feature check only? */
80 <        strcat(RFeatureList, RATRACE_FEATURES);
80 >        strcat(RFeatureList, RXTRACE_FEATURES);
81          if (argc > 1 && !strcmp(argv[1], "-features"))
82                  return feature_status(argc-2, argv+2);
83 +                                        /* initialize calcomp routines */
84 +        initfunc();
85                                          /* add trace notify function */
86          for (i = 0; addobjnotify[i] != NULL; i++)
87                  ;
# Line 107 | Line 115 | main(int  argc, char  *argv[])
115                  case 'n':                               /* number of cores */
116                          check(2,"i");
117                          nproc = atoi(argv[++i]);
110                        if (nproc < 0)
111                                error(USER, "bad number of processes");
118                          break;
119                  case 'x':                               /* x resolution */
120                          check(2,"i");
# Line 138 | Line 144 | main(int  argc, char  *argv[])
144                          break;
145                  case 'I':                               /* immed. irradiance */
146                          rval = myRTmanager.rtFlags & RTimmIrrad;
147 <                        check_bool(3,rval);
147 >                        check_bool(2,rval);
148                          if (rval) myRTmanager.rtFlags |= RTimmIrrad;
149                          else myRTmanager.rtFlags &= ~RTimmIrrad;
150                          break;
# Line 223 | Line 229 | main(int  argc, char  *argv[])
229                                  goto badopt;
230                          }
231                          break;
232 +                case 'p':                               /* value output */
233 +                        switch (argv[i][2]) {
234 +                        case 'R':                       /* standard RGB output */
235 +                                if (strcmp(argv[i]+2, "RGB"))
236 +                                        goto badopt;
237 +                                out_prims = stdprims;
238 +                                out_scalefactor = 1;
239 +                                sens_curve = NULL;
240 +                                break;
241 +                        case 'X':                       /* XYZ output */
242 +                                if (strcmp(argv[i]+2, "XYZ"))
243 +                                        goto badopt;
244 +                                out_prims = xyzprims;
245 +                                out_scalefactor = WHTEFFICACY;
246 +                                sens_curve = NULL;
247 +                                break;
248 +                        case 'c': {
249 +                                int     j;
250 +                                check(3,"ffffffff");
251 +                                rval = 0;
252 +                                for (j = 0; j < 8; j++) {
253 +                                        our_prims[0][j] = atof(argv[++i]);
254 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
255 +                                }
256 +                                if (rval) {
257 +                                        if (!colorprimsOK(our_prims))
258 +                                                error(USER, "illegal primary chromaticities");
259 +                                        out_prims = our_prims;
260 +                                } else
261 +                                        out_prims = stdprims;
262 +                                out_scalefactor = 1;
263 +                                sens_curve = NULL;
264 +                                } break;
265 +                        case 'Y':                       /* photopic response */
266 +                                if (argv[i][3])
267 +                                        goto badopt;
268 +                                out_scalefactor = WHTEFFICACY;
269 +                                sens_curve = scolor_photopic;
270 +                                break;
271 +                        case 'S':                       /* scotopic response */
272 +                                if (argv[i][3])
273 +                                        goto badopt;
274 +                                out_scalefactor = WHTSCOTOPIC;
275 +                                sens_curve = scolor_scotopic;
276 +                                break;
277 +                        case 'M':                       /* melanopic response */
278 +                                if (argv[i][3])
279 +                                        goto badopt;
280 +                                out_scalefactor = WHTMELANOPIC;
281 +                                sens_curve = scolor_melanopic;
282 +                                break;
283 +                        case 'A':                       /* radiometric average */
284 +                                if (argv[i][3])
285 +                                        goto badopt;
286 +                                out_scalefactor = 1;
287 +                                sens_curve = scolor_mean;
288 +                                break;
289 +                        default:
290 +                                goto badopt;
291 +                        }
292 +                        break;
293 + #if MAXCSAMP>3
294 +                case 'c':                               /* output spectral results */
295 +                        if (argv[i][2] != 'o')
296 +                                goto badopt;
297 +                        rval = (out_prims == NULL) & (sens_curve == NULL);
298 +                        check_bool(3,rval);
299 +                        if (rval) {
300 +                                out_prims = NULL;
301 +                                sens_curve = NULL;
302 +                        } else if (out_prims == NULL)
303 +                                out_prims = stdprims;
304 +                        break;
305 + #endif
306                  default:
307                          goto badopt;
308                  }
309          }
310 +                                        /* set/check spectral sampling */
311 +        rval = setspectrsamp(CNDX, WLPART);
312 +        if (rval < 0)
313 +                error(USER, "unsupported spectral sampling");
314 +        if (sens_curve != NULL)
315 +                out_prims = NULL;
316 +        else if (out_prims != NULL) {
317 +                if (!rval)
318 +                        error(WARNING, "spectral range incompatible with color output");
319 +        } else if (NCSAMP == 3)
320 +                out_prims = stdprims;   /* 3 samples do not a spectrum make */
321                                          /* set up signal handling */
322          sigdie(SIGINT, "Interrupt");
323   #ifdef SIGHUP
# Line 270 | Line 361 | main(int  argc, char  *argv[])
361          if (outform != 'a')
362                  SET_FILE_BINARY(stdout);
363          if (doheader) {                 /* print header? */
364 <                static char     fmt[] = OCTFMT;
365 <                FILE *          octfp = fopen(argv[i], "rb");
275 <                if (checkheader(octfp, fmt, stdout) < 0)
276 <                        error(USER, "bad octree header");
277 <                fclose(octfp);
364 >                newheader("RADIANCE", stdout);
365 >                fputs(myRTmanager.GetHeadStr(), stdout);
366                  printargs(i, argv, stdout);
367                  printf("SOFTWARE= %s\n", VersionID);
368                  fputnow(stdout);
369                  if (rval > 0)           /* saved from setrtoutput() call */
370 <                        printf("NCOMP=%d\n", rval);
370 >                        fputncomp(rval, stdout);
371 >                if (NCSAMP > 3)
372 >                        fputwlsplit(WLPART, stdout);
373 >                if ((out_prims != stdprims) & (out_prims != NULL))
374 >                        fputprims(out_prims, stdout);
375                  if ((outform == 'f') | (outform == 'd'))
376                          fputendian(stdout);
377                  fputformat(formstr(outform), stdout);
378 <                putchar('\n');
378 >                fputc('\n', stdout);    /* end of header */
379          }
380          rtrace(NULL, nproc);            /* trace rays */
381          quit(0);                        /* clean up & exit */
# Line 309 | Line 401 | wputs(                         /* warning output function */
401  
402   void
403   eputs(                          /* put string to stderr */
404 <        char  *s
404 >        const char  *s
405   )
406   {
407          static int  midline = 0;
# Line 400 | Line 492 | printdefaults(void)                    /* print default values to stdou
492                  case '~': printf(" tilde"); break;
493                  }
494          putchar('\n');
495 +        if (sens_curve == scolor_photopic)
496 +                printf("-pY\t\t\t\t# photopic output\n");
497 +        else if (sens_curve == scolor_scotopic)
498 +                printf("-pS\t\t\t\t# scotopic output\n");
499 +        else if (sens_curve == scolor_melanopic)
500 +                printf("-pM\t\t\t\t# melanopic output\n");
501 +        else if (out_prims == stdprims)
502 +                printf("-pRGB\t\t\t\t# standard RGB color output\n");
503 +        else if (out_prims == xyzprims)
504 +                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
505 +        else if (out_prims != NULL)
506 +                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
507 +                                out_prims[RED][0], out_prims[RED][1],
508 +                                out_prims[GRN][0], out_prims[GRN][1],
509 +                                out_prims[BLU][0], out_prims[BLU][1],
510 +                                out_prims[WHT][0], out_prims[WHT][1]);
511 +        if ((sens_curve == NULL) & (NCSAMP > 3))
512 +                printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" :
513 +                                "-co+\t\t\t\t# output spectral values\n");
514          printf(erract[WARNING].pf != NULL ?
515                          "-w+\t\t\t\t# warning messages on\n" :
516                          "-w-\t\t\t\t# warning messages off\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)