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.6 by greg, Sat Feb 22 02:07:23 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 <math.h>
11   #include "random.h"
12   #include "mgflib/parser.h"
13  
14 < #define MX(v)   (int)(((1<<14)-1)*(v)[(proj_axis+1)%3])
15 < #define MY(v)   (int)(((1<<14)-1)*(v)[(proj_axis+2)%3])
14 > #define MSIZE   ((1<<14)-1)
15 > #define MX(v)   (int)(MSIZE*(v)[(proj_axis+1)%3])
16 > #define MY(v)   (int)(MSIZE*(v)[(proj_axis+2)%3])
17  
18   int     r_face();
19   int     proj_axis;
20   double  limit[3][2];
21   int     layer;
22 + long    rthresh = 1;
23  
24   extern int      mg_nqcdivs;
25  
# Line 37 | Line 37 | char   *argv[];
37          mg_nqcdivs = 3;         /* reduce object subdivision */
38          mg_init();              /* initialize the parser */
39                                          /* get arguments */
40 +        if (argc > 9 && !strcmp(argv[1], "-t")) {
41 +                rthresh = atof(argv[2])*MSIZE + 0.5;
42 +                rthresh *= rthresh;
43 +                argv += 2;
44 +                argc -= 2;
45 +        }
46          if (argc < 8 || (proj_axis = argv[1][0]-'x') < 0 || proj_axis > 2)
47                  goto userr;
48          limit[0][0] = atof(argv[2]); limit[0][1] = atof(argv[3]);
# Line 56 | Line 62 | char   *argv[];
62          mdone();                        /* close output */
63          exit(0);
64   userr:
65 <        fprintf(stderr, "Usage: %s {x|y|z} xmin xmax ymin ymax zmin zmax [file.mgf] ..\n",
66 <                        argv[0]);
65 >        fputs("Usage: mgf2meta [-t thresh] {x|y|z} xmin xmax ymin ymax zmin zmax [file.mgf] ..\n",
66 >                        stderr);
67          exit(1);
68   }
69  
# Line 102 | Line 108 | short  hshtab[HTBLSIZ][4];             /* done line segments */
108   #define  hash(mx1,my1,mx2,my2)  ((long)(mx1)<<15 ^ (long)(my1)<<10 ^ \
109                                          (long)(mx2)<<5 ^ (long)(my2))
110  
105 #define  RANDMASK       ((1L<<14)-1)
111  
107
112   newlayer()                              /* start a new layer */
113   {
114   #ifdef BSD
# Line 136 | Line 140 | int    v1x, v1y, v2x, v2y;
140          hshtab[h][0] = v1x; hshtab[h][1] = v1y;
141          hshtab[h][2] = v2x; hshtab[h][3] = v2y;
142          if ((long)(v2x-v1x)*(v2x-v1x) + (long)(v2y-v1y)*(v2y-v1y)
143 <                        <= (random()&RANDMASK))
143 >                        <= random() % rthresh)
144                  return(0);
145          mline(v1x, v1y, layer/4, 0, layer%4);
146          mdraw(v2x, v2y);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines