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

Comparing ray/src/px/xshowtrace.c (file contents):
Revision 2.7 by greg, Sat Feb 22 02:07:28 2003 UTC vs.
Revision 2.14 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *      9/21/90 Greg Ward
8   */
9  
10 + #include <X11/Xlib.h>
11 +
12   #include "standard.h"
13 + #include "paths.h"
14   #include "view.h"
12 #include <X11/Xlib.h>
15  
16   #define MAXDEPTH        32              /* ridiculous ray tree depth */
17  
18 < #ifdef  SMLFLT
17 < #define  sscanvec(s,v)  (sscanf(s,"%f %f %f",v,v+1,v+2)==3)
18 < #else
19 < #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
20 < #endif
18 > #define  sscanvec(s,v)  (sscanf(s,FVFORMAT,v,v+1,v+2)==3)
19  
20 < char    rtcom[] = "rtrace -h- -otp -fa -x 1";
20 > char    rtcom[64] = "rtrace -h- -otp -fa -x 1";
21   char    xicom[] = "ximage -c 256";
22  
23   VIEW    ourview = STDVIEW;              /* view for picture */
24   RESOLU  ourres;                         /* picture resolution */
25  
28 char    *progname;                      /* program name */
29
26   char    *picture;                       /* picture name */
27  
28   FILE    *pin;                           /* input stream */
# Line 43 | Line 39 | struct node {                          /* ray tree node */
39  
40   int     slow = 0;               /* slow trace? */
41  
42 + void mainloop(void);
43 + static void freetree(struct node        *tp);
44 + static void tracerays(struct node       *tp);
45 + static int strtoipt(int ipt[2], char    *str);
46 + static void setvec(int  ipt[2]);
47 + static void vector(int  ip1[2], int     ip2[2]);
48  
49 < main(argc, argv)                /* takes both the octree and the image */
50 < int     argc;
51 < char    *argv[];
49 >
50 > int
51 > main(           /* takes both the octree and the image */
52 >        int     argc,
53 >        char    *argv[]
54 > )
55   {
56          int     i;
57 <        char    combuf[256];
57 >        char    combuf[PATH_MAX];
58  
59 <        progname = argv[0];
59 >        fixargv0(argv[0]);              /* sets global progname */
60          for (i = 1; i < argc-2; i++)
61                  if (!strcmp(argv[i], "-s"))
62                          slow++;
63 +                else if (!strcmp(argv[i], "-T"))
64 +                        strcat(rtcom, " -oTp");
65                  else
66                          break;
67          if (i > argc-2) {
68 <                fprintf(stderr, "Usage: %s [-s] [rtrace args] octree picture\n",
68 >                fprintf(stderr, "Usage: %s [-s][-T] [rtrace args] octree picture\n",
69                                  progname);
70                  exit(1);
71          }
# Line 78 | Line 85 | char   *argv[];
85                  exit(1);
86          }
87                                          /* build input command */
88 <        sprintf(combuf, "%s %s | %s", xicom, picture, rtcom);
88 >        sprintf(combuf, "%s \"%s\" | %s", xicom, picture, rtcom);
89          for ( ; i < argc-1; i++) {
90                  strcat(combuf, " ");
91                  strcat(combuf, argv[i]);
# Line 94 | Line 101 | char   *argv[];
101   }
102  
103  
104 < mainloop()                              /* get and process input */
104 > void
105 > mainloop(void)                          /* get and process input */
106   {
107          static struct node      *sis[MAXDEPTH];
108          register struct node    *newp;
# Line 133 | Line 141 | mainloop()                             /* get and process input */
141   }
142  
143  
144 < freetree(tp)                            /* free a trace tree */
145 < struct node     *tp;
144 > static void
145 > freetree(                               /* free a trace tree */
146 >        struct node     *tp
147 > )
148   {
149 <        register struct node    *kid;
149 >        register struct node    *kid, *k2;
150  
151 <        for (kid = tp->daughter; kid != NULL; kid = kid->sister)
151 >        for (kid = tp->daughter; kid != NULL; kid = k2) {
152 >                k2 = kid->sister;
153                  freetree(kid);
154 +        }
155          free((void *)tp);
156   }
157  
158  
159 < tracerays(tp)                           /* trace a ray tree */
160 < struct node     *tp;
159 > static void
160 > tracerays(                              /* trace a ray tree */
161 >        struct node     *tp
162 > )
163   {
164          register struct node    *kid;
165  
# Line 156 | Line 170 | struct node    *tp;
170   }
171  
172  
173 < strtoipt(ipt, str)              /* convert string x y z to image point */
174 < int     ipt[2];
175 < char    *str;
173 > static int
174 > strtoipt(               /* convert string x y z to image point */
175 >        int     ipt[2],
176 >        char    *str
177 > )
178   {
179          FVECT   im_pt, pt;
180  
# Line 182 | Line 198 | Window gwind = 0;
198   int     xoff, yoff;
199  
200  
201 < setvec(ipt)                     /* set up vector drawing for pick */
202 < int     ipt[2];
201 > static void
202 > setvec(                 /* set up vector drawing for pick */
203 >        int     ipt[2]
204 > )
205   {
206          extern Window   xfindwind();
207          XWindowAttributes       wa;
# Line 222 | Line 240 | int    ipt[2];
240   }
241  
242  
243 < vector(ip1, ip2)                /* draw a vector */
244 < int     ip1[2], ip2[2];
243 > static void
244 > vector(         /* draw a vector */
245 >        int     ip1[2],
246 >        int     ip2[2]
247 > )
248   {
249          if (ip2[0] == -1 && ip2[1] == -1)
250                  return;                 /* null vector */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines