1 /********************************************************************/
2 /* STRIPE: converting a polygonal model to triangle strips
5 Advisors: Steven Skiena and Amitabh Varshney
7 /********************************************************************/
9 /*---------------------------------------------------------------------*/
11 This file contains the code that initializes the data structures for
12 the local algorithm, and starts the local algorithm going.
14 /*---------------------------------------------------------------------*/
20 #include "triangulatex.h"
21 #include "sturctsex.h"
27 void Find_StripsEx(FILE *output,FILE *strip,int *ties,
28 int tie, int triangulate,
29 int swaps,int *next_id)
31 /* This routine will peel off the strips from the model */
34 P_ADJACENCIES temp = NULL;
35 register int max,bucket=0;
36 BOOL whole_flag = TRUE;
39 /* Set the last known input edge to be null */
40 Last_Edge(&dummy,&dummy,&dummy,1);
42 /* Search for lowest adjacency polygon and output strips */
46 /* Search for polygons in increasing number of adjacencies */
50 pListHead = array[bucket];
51 max = NumOnList(pListHead);
54 temp = (P_ADJACENCIES) PeekList(pListHead,LISTHEAD,0);
57 printf("Error in the buckets%d %d %d\n",bucket,max,0);
60 Polygon_OutputEx(temp,temp->face_id,bucket,pListHead,
61 output,strip,ties,tie,triangulate,swaps,next_id,1);
62 /* Try to extend backwards, if the starting polygon in the
63 strip had 2 or more adjacencies to begin with
66 Extend_BackwardsEx(temp->face_id,output,strip,ties,tie,triangulate,
71 /* Went through the whole structure, it is empty and we are done.
73 if ((bucket == 59) && (max == 0))
76 /* We just finished a strip, send dummy data to signal the end
77 of the strip so that we can output it.
81 Output_TriEx(-1,-2,-3,output,-1,-10,1);
82 Last_Edge(&dummy,&dummy,&dummy,1);
89 void SGI_Strip(int num_verts,int num_faces,FILE *output,
90 int ties,int triangulate)
96 strip = fopen("output.d","w");
97 /* We are going to output and find triangle strips
98 according the the method that SGI uses, ie always
99 choosing as the next triangle in our strip the triangle
100 that has the least number of adjacencies. We do not have
101 all triangles and will be triangulating on the fly those
102 polygons that have more than 3 sides.
105 /* Build a table that has all the polygons sorted by the number
106 of polygons adjacent to it.
111 Build_SGI_Table(num_verts,num_faces);
113 /* We will have a structure to hold all the strips, until
117 /* Now we have the structure built to find the polygons according
118 to the number of adjacencies. Now use the SGI Method to find
119 strips according to the adjacencies
121 Find_StripsEx(output,strip,&t,ties,triangulate,ON,&next_id);