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

Comparing ray/src/cv/mgf2meta.c (file contents):
Revision 2.4 by greg, Thu May 4 13:55:30 1995 UTC vs.
Revision 2.7 by schorsch, Mon Jun 30 14:59:11 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1995 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Convert MGF (Materials and Geometry Format) to Metafile 2-d graphics
6   */
7  
8   #include <stdio.h>
9 + #include <stdlib.h>
10 + #include <string.h>
11   #include <math.h>
12   #include "random.h"
13   #include "mgflib/parser.h"
14  
15 < #define MX(v)   (int)(((1<<14)-1)*(v)[(proj_axis+1)%3])
16 < #define MY(v)   (int)(((1<<14)-1)*(v)[(proj_axis+2)%3])
15 > #define MSIZE   ((1<<14)-1)
16 > #define MX(v)   (int)(MSIZE*(v)[(proj_axis+1)%3])
17 > #define MY(v)   (int)(MSIZE*(v)[(proj_axis+2)%3])
18  
19   int     r_face();
20   int     proj_axis;
21   double  limit[3][2];
22   int     layer;
23 + long    rthresh = 1;
24  
25   extern int      mg_nqcdivs;
26  
# Line 37 | Line 38 | char   *argv[];
38          mg_nqcdivs = 3;         /* reduce object subdivision */
39          mg_init();              /* initialize the parser */
40                                          /* get arguments */
41 +        if (argc > 9 && !strcmp(argv[1], "-t")) {
42 +                rthresh = atof(argv[2])*MSIZE + 0.5;
43 +                rthresh *= rthresh;
44 +                argv += 2;
45 +                argc -= 2;
46 +        }
47          if (argc < 8 || (proj_axis = argv[1][0]-'x') < 0 || proj_axis > 2)
48                  goto userr;
49          limit[0][0] = atof(argv[2]); limit[0][1] = atof(argv[3]);
# Line 56 | Line 63 | char   *argv[];
63          mdone();                        /* close output */
64          exit(0);
65   userr:
66 <        fprintf(stderr, "Usage: %s {x|y|z} xmin xmax ymin ymax zmin zmax [file.mgf] ..\n",
67 <                        argv[0]);
66 >        fputs("Usage: mgf2meta [-t thresh] {x|y|z} xmin xmax ymin ymax zmin zmax [file.mgf] ..\n",
67 >                        stderr);
68          exit(1);
69   }
70  
# Line 102 | Line 109 | short  hshtab[HTBLSIZ][4];             /* done line segments */
109   #define  hash(mx1,my1,mx2,my2)  ((long)(mx1)<<15 ^ (long)(my1)<<10 ^ \
110                                          (long)(mx2)<<5 ^ (long)(my2))
111  
105 #define  RANDMASK       ((1L<<14)-1)
112  
107
113   newlayer()                              /* start a new layer */
114   {
115 < #ifdef BSD
111 <        bzero((char *)hshtab, sizeof(hshtab));
112 < #else
113 <        (void)memset((char *)hshtab, 0, sizeof(hshtab));
114 < #endif
115 >        (void)memset((char *)hshtab, '\0', sizeof(hshtab));
116          if (++layer >= 16) {
117                  mendpage();
118                  layer = 0;
# Line 136 | Line 137 | int    v1x, v1y, v2x, v2y;
137          hshtab[h][0] = v1x; hshtab[h][1] = v1y;
138          hshtab[h][2] = v2x; hshtab[h][3] = v2y;
139          if ((long)(v2x-v1x)*(v2x-v1x) + (long)(v2y-v1y)*(v2y-v1y)
140 <                        <= (random()&RANDMASK))
140 >                        <= random() % rthresh)
141                  return(0);
142          mline(v1x, v1y, layer/4, 0, layer%4);
143          mdraw(v2x, v2y);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines