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

Comparing ray/src/rt/renderopts.c (file contents):
Revision 2.14 by greg, Fri Oct 8 22:08:26 2010 UTC vs.
Revision 2.25 by greg, Fri Apr 5 17:52:20 2024 UTC

# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11  
12   #include  "ray.h"
13   #include  "paths.h"
14 + #include  "pmapopt.h"
15  
16 + extern char     *progname;      /* global argv[0] */
17  
18 < extern int
18 > char    RFeatureList[2048] =    /* newline-separated feature list */
19 >                "VirtualSources\nSecondarySources\nSourceSubsampling\n"
20 >                "SourceVisibility\nAmbientModifierSelection\n"
21 >                "PathTracing\nRussianRoulette\nLowDiscrepancySeq\n"
22 >                "SpecularSampling\nMaterialMixtures\nAntimatter\nBackFaceVisibility\n"
23 >                "ScatteringModels=WGMD,Ashikhmin-Shirley\n"
24 >                "TabulatedBSDFs=DataFile,KlemsXML,TensorTreeXML,+ViewPeakExtraction\n"
25 >                "Instancing=Octree,TriangleMesh\nAliases\n"
26 > #if MAXCSAMP>3
27 >                "Hyperspectral\n"
28 > #endif
29 > #if !defined(SHADCACHE) || SHADCACHE > 0
30 >                "ShadowCache\n"
31 > #endif
32 > #ifdef  DISPERSE
33 >                "DielectricDispersion\n"
34 > #endif
35 > /*              PMAP_FEATURES   XXX @Roland: need to define this in pmapopt.h */
36 > ;
37 >
38 >
39 > static char *
40 > get_feature(            /* find a specific feature (with optional sublist) */
41 >        const char *feat
42 > )
43 > {
44 >        char    *cp = RFeatureList;
45 >        int     n = 0;
46 >
47 >        while ((feat[n] != '\0') & (feat[n] != '='))
48 >                n++;
49 >        if (!n)
50 >                return(NULL);
51 >        while (*cp) {
52 >                if (!strncmp(cp, feat, n) && (cp[n] == '\n') | !feat[n] | (cp[n] == feat[n]))
53 >                        return(cp);
54 >                while (*cp++ != '\n')
55 >                        ;
56 >        }
57 >        return(NULL);
58 > }
59 >
60 >
61 > static int
62 > match_subfeatures(      /* check if subfeatures are supported */
63 >        char *mysublist,
64 >        char *reqs
65 > )
66 > {
67 >        if (mysublist)
68 >                mysublist = strchr(mysublist, '=');
69 >        if (!mysublist++ | !reqs)
70 >                return(0);              /* not a feature list */
71 >        while (*reqs) {                 /* check each of their subfeature requests */
72 >                char    subfeat[64];
73 >                char    *cp = subfeat;
74 >                int     n;
75 >                while (*reqs && (*cp = *reqs++) != ',')
76 >                        cp++;
77 >                *cp = '\0';
78 >                n = cp - subfeat;
79 >                for (cp = mysublist; (cp = strstr(cp, subfeat)) != NULL; cp++)
80 >                        if ((cp[-1] == ',') | (cp[-1] == '=') &&
81 >                                        (cp[n] == ',') | (cp[n] == '\n'))
82 >                                break;  /* match */
83 >                if (!cp)
84 >                        return(0);      /* missing this one! */
85 >        }
86 >        return(1);                      /* matched them all */
87 > }
88 >
89 >
90 > int
91 > feature_status(         /* report active feature list / check specifics */
92 >        int  ac,
93 >        char  *av[]
94 > )
95 > {
96 >        if (ac <= 0)                    /* report entire list? */
97 >                fputs(RFeatureList, stdout);
98 >
99 >        for ( ; ac-- > 0; av++) {       /* check each argument */
100 >                char    *cp;
101 >                if (!*av[0]) continue;
102 >                if ((cp = strchr(av[0], '=')) != NULL) {
103 >                        if (!match_subfeatures(get_feature(av[0]), cp+1))
104 >                                goto missing_feature;
105 >                } else if ((cp = get_feature(av[0])) != NULL) {
106 >                        char    *tp = strchr(cp, '=');
107 >                        if (tp && tp < strchr(cp, '\n'))
108 >                                do
109 >                                        fputc(*cp, stdout);
110 >                                while (*cp++ != '\n');
111 >                } else
112 >                        goto missing_feature;
113 >        }
114 >        return(0);                      /* return satisfactory status */
115 > missing_feature:                        /* or report error */
116 >        fprintf(stderr, "%s: missing feature - %s\n", progname, av[0]);
117 >        return(1);
118 > }
119 >
120 >
121 > int
122   getrenderopt(           /* get next render option */
123          int  ac,
124          char  *av[]
# Line 22 | Line 127 | getrenderopt(          /* get next render option */
127   #define  check(ol,al)           if (av[0][ol] || \
128                                  badarg(ac-1,av+1,al)) \
129                                  return(-1)
130 < #define  bool(olen,var)         switch (av[0][olen]) { \
130 > #define  check_bool(olen,var)           switch (av[0][olen]) { \
131                                  case '\0': var = !var; break; \
132                                  case 'y': case 'Y': case 't': case 'T': \
133                                  case '+': case '1': var = 1; break; \
# Line 37 | Line 142 | getrenderopt(          /* get next render option */
142                                          /* check if it's one we know */
143          switch (av[0][1]) {
144          case 'u':                               /* uncorrelated sampling */
145 <                bool(2,rand_samp);
145 >                check_bool(2,rand_samp);
146                  return(0);
147          case 'b':                               /* back face vis. */
148                  if (av[0][2] == 'v') {
149 <                        bool(3,backvis);
149 >                        check_bool(3,backvis);
150                          return(0);
151                  }
152                  break;
# Line 68 | Line 173 | getrenderopt(          /* get next render option */
173                          vspretest = atoi(av[1]);
174                          return(1);
175                  case 'v':                               /* visibility */
176 <                        bool(3,directvis);
176 >                        check_bool(3,directvis);
177                          return(0);
178                  case 's':                               /* size */
179                          check(3,"f");
# Line 101 | Line 206 | getrenderopt(          /* get next render option */
206                  }
207                  break;
208          case 'i':                               /* irradiance */
209 <                bool(2,do_irrad);
209 >                check_bool(2,do_irrad);
210                  return(0);
211          case 'a':                               /* ambient */
212                  switch (av[0][2]) {
# Line 143 | Line 248 | getrenderopt(          /* get next render option */
248                                  amblp = amblist;
249                          }
250                          if (av[0][2] == 'I') {  /* file */
251 <                                rval = wordfile(amblp,
251 >                                rval = wordfile(amblp, AMBLLEN-(amblp-amblist),
252                                          getpath(av[1],getrlibpath(),R_OK));
253                                  if (rval < 0) {
254                                          sprintf(errmsg,
# Line 164 | Line 269 | getrenderopt(          /* get next render option */
269                                  amblp = amblist;
270                          }
271                          if (av[0][2] == 'E') {  /* file */
272 <                                rval = wordfile(amblp,
272 >                                rval = wordfile(amblp, AMBLLEN-(amblp-amblist),
273                                          getpath(av[1],getrlibpath(),R_OK));
274                                  if (rval < 0) {
275                                          sprintf(errmsg,
# Line 207 | Line 312 | getrenderopt(          /* get next render option */
312                          return(1);
313                  }
314                  break;
315 + #if MAXCSAMP>3
316 +        case 'c':                               /* spectral sampling */
317 +                switch (av[0][2]) {
318 +                case 's':                       /* spectral bin count */
319 +                        check(3,"i");
320 +                        NCSAMP = atoi(av[1]);
321 +                        return(1);
322 +                case 'w':                       /* wavelength extrema */
323 +                        check(3,"ff");
324 +                        WLPART[0] = atof(av[1]);
325 +                        WLPART[3] = atof(av[2]);
326 +                        return(2);
327 +                }
328 +                break;
329 + #endif
330          }
331 <        return(-1);             /* unknown option */
331 >        
332 >        /* PMAP: Parse photon mapping options */
333 >        return(getPmapRenderOpt(ac, av));
334 >        
335 > /*      return(-1); */          /* unknown option */
336  
337   #undef  check
338 < #undef  bool
338 > #undef  check_bool
339   }
340  
341  
342 < extern void
342 > void
343   print_rdefaults(void)           /* print default render values to stdout */
344   {
345          printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
# Line 250 | Line 374 | print_rdefaults(void)          /* print default render values
374                          colval(salbedo,GRN), colval(salbedo,BLU));
375          printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
376          printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
377 +        if (NCSAMP > 3) {
378 +                printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP);
379 +                printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n",
380 +                                WLPART[3], WLPART[0]);
381 +        }
382          printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth,
383                          maxdepth<=0 ? " (Russian roulette)" : "");
384          printf("-lw %.2e\t\t\t# limit weight\n", minweight);
385 +        
386 +        /* PMAP: output photon map defaults */
387 +        printPmapDefaults();
388   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines