1 /********************************************************************/
2 /* STRIPE: converting a polygonal model to triangle strips
5 Advisors: Steven Skiena and Amitabh Varshney
7 /********************************************************************/
9 /*---------------------------------------------------------------------*/
11 This file contains routines that are used to determine the options
12 that were specified by the user
14 /*---------------------------------------------------------------------*/
21 int power_10(int power)
23 /* Raise 10 to the power */
27 for (i = 1; i <= power; ++i)
32 float power_negative(int power)
34 /* Raise 10 to the negative power */
40 for (i = 1; i<=power; i++)
45 float convert_array(int num[],int stack_size)
47 /* Convert an array of characters to an integer */
49 register int counter,c;
50 float temp =(float)0.0;
52 for (c=(stack_size-1), counter = 0; c>=0; c--, counter++)
55 /* We are at the decimal point, convert to decimal
60 temp = power_negative(stack_size - c - 1) * temp;
63 temp += power_10(counter) * num[c];
69 float get_options(int argc, char **argv, int *f, int *t, int *tr, int *group)
76 enum tie_options tie = FIRST;
77 /* triangulation variable */
78 enum triangulation_options triangulate = WHOLE;
79 /* normal difference variable (in degrees) */
80 float norm_difference = (float)360.0;
81 /* file-type variable */
82 enum file_options file_type = ASCII;
84 /* User has the wrong number of options */
85 if ((argc > 5) || (argc < 2))
87 printf("Usage: bands -[file_option][ties_option][triangulation_option][normal_difference] file_name\n");
91 /* Interpret the options specified */
92 while (--argc > 0 && (*++argv)[0] == '-')
94 /* At the next option that was specified */
96 while (c = *++argv[0])
100 /* Use the first polygon we see. */
105 /* Randomly choose the next polygon */
110 /* Alternate direction in choosing the next polygon */
115 /* Use lookahead to choose the next polygon */
120 /* Try to reduce swaps */
125 /* Use partial triangulation of polygons */
126 triangulate = PARTIAL;
130 /* Use whole triangulation of polygons */
135 /* Input file is in binary */
140 /* Strips will be grouped according to the groups in
141 the data file. We will have to restrict strips to be
142 in the grouping of the data file.
146 /* Get each the value of the integer */
147 /* We have an integer */
149 if ((c >= '0') && (c <= '9'))
151 /* More than one normal difference specified, use the last one */
157 buffer[count++] = ATOI(c);
159 /* At the decimal point */
162 /* More than one normal difference specified, use the last one */
168 buffer[count++] = -1;
174 /* Convert the buffer of characters to a floating pt integer */
176 norm_difference = convert_array(buffer,count);
180 return norm_difference;