ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_test.c
Revision: 3.1
Committed: Sat Feb 22 02:07:25 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6P1, rad3R5, rad3R6
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * sm_test.c
6 *
7 * A simple OGL display program to test sm code
8 */
9 #include "standard.h"
10
11 #include <glut.h>
12 #include "ui.h"
13 #include "sm_geom.h"
14 #include "sm_qtree.h"
15 #include "sm_stree.h"
16 #include "sm.h"
17 #include "sm_draw.h"
18
19 struct driver odev;
20 char *progname;
21 double
22 test_normalize(v) /* normalize a vector, return old magnitude */
23 register FVECT v;
24 {
25 register double len;
26
27 len = DOT(v, v);
28
29 if (len <= 0.0)
30 return(0.0);
31
32 if (len <= 1.0+FTINY && len >= 1.0-FTINY)
33 len = 0.5 + 0.5*len; /* first order approximation */
34 else
35 len = sqrt(len);
36
37 v[0] /= len;
38 v[1] /= len;
39 v[2] /= len;
40
41 return(len);
42 }
43
44 void
45 print_usage(char *program)
46 {
47 fprintf(stderr, "usage: %s \n", program);
48 }
49
50
51 /* Parse the command line arguments to get the input file name. The depth
52 * thresholding size may also be specified, as well as the disparity
53 * threshold, specified in number of depth ranges, for creating depth
54 * disparity lines.
55 */
56 void
57 parse_cmd_line(int argc, char* argv[])
58 {
59 int i;
60 if(argc < 2)
61 return;
62
63 for(i=1;i<argc;i++)
64 if(argv[i][0] == '-')
65 switch(argv[i][1]) {
66 case 't':
67 Tri_intersect = TRUE;
68 break;
69 case 'd':
70 Pt_delete = TRUE;
71 break;
72 case 'f':
73 if(i+1 < argc)
74 {
75 Filename = &(argv[i+1][0]);
76 i++;
77 }
78 else
79 fprintf(stderr,"Must include file name\n");
80 }
81 /* Nothing for now */
82 }
83
84 void
85 display()
86 {
87 glutMainLoop();
88 }
89
90 VIEW View = {0,{0,0,0},{0,0,-1},{0,1,0},60,60,0};
91 int
92 main(int argc, char *argv[])
93 {
94 COLR colr;
95 FVECT v0,v1,v2,a,b,c,dir;
96 double d[3];
97 double phi,theta;
98
99 progname = argv[0];
100 parse_cmd_line(argc,argv);
101 /* Open a display window */
102 smDraw_open_window(argc,argv);
103 /* First read in the command line arguments */
104
105 odev.v = View;
106
107 if(Filename)
108 {
109 next_sample(a,a,colr,1);
110 /* Initialize the data structures for 10 samples*/
111 smInit(262000);
112 }
113 else
114 smInit(100);
115 display();
116 }
117
118
119
120
121
122
123
124
125
126
127
128
129