1 /********************************************************************/
2 /* STRIPE: converting a polygonal model to triangle strips
5 Advisors: Steven Skiena and Amitabh Varshney
7 /********************************************************************/
9 /*---------------------------------------------------------------------*/
11 This file contains the initialization of data structures.
13 /*---------------------------------------------------------------------*/
20 void init_vert_norms(int num_vert)
22 /* Initialize vertex/normal array to have all zeros to
27 for (x = 0; x < num_vert; x++)
28 *(vert_norms + x) = 0;
31 void init_vert_texture(int num_vert)
33 /* Initialize vertex/normal array to have all zeros to
38 for (x = 0; x < num_vert; x++)
39 *(vert_texture + x) = 0;
42 BOOL InitVertTable( int nSize )
46 /* Initialize the vertex table */
47 PolVerts = (ListHead**) malloc(sizeof(ListHead*) * nSize );
50 for ( nIndex=0; nIndex < nSize; nIndex++ )
52 PolVerts[nIndex] = NULL;
59 BOOL InitFaceTable( int nSize )
63 /* Initialize the face table */
64 PolFaces = (ListHead**) malloc(sizeof(ListHead*) * nSize );
67 for ( nIndex=0; nIndex < nSize; nIndex++ )
69 PolFaces[nIndex] = NULL;
76 BOOL InitEdgeTable( int nSize )
80 /* Initialize the edge table */
81 PolEdges = (ListHead**) malloc(sizeof(ListHead*) * nSize );
84 for ( nIndex=0; nIndex < nSize; nIndex++ )
86 PolEdges[nIndex] = NULL;
94 void InitStripTable( )
99 /* Initialize the strip table */
100 pListHead = ( PLISTHEAD ) malloc(sizeof(ListHead));
103 InitList( pListHead );
104 strips[0] = pListHead;
108 printf("Out of memory !\n");
114 void Init_Table_SGI()
120 /* This routine will initialize the table that will
121 have the faces sorted by the number of adjacent polygons
125 for (x=0; x< max_adj; x++)
127 /* We are allowing the max number of sides of a polygon
130 pListHead = ( PLISTHEAD ) malloc(sizeof(ListHead));
133 InitList( pListHead );
134 array[x] = pListHead;
138 printf("Out of memory !\n");
144 void BuildVertTable( int nSize )
149 for ( nIndex=0; nIndex < nSize; nIndex++ )
151 pListHead = ( PLISTHEAD ) malloc(sizeof(ListHead));
154 InitList( pListHead );
155 PolVerts[nIndex] = pListHead;
164 void BuildFaceTable( int nSize )
169 for ( nIndex=0; nIndex < nSize; nIndex++ )
171 pListHead = ( PLISTHEAD ) malloc(sizeof(ListHead));
174 InitList( pListHead );
175 PolFaces[nIndex] = pListHead;
183 void BuildEdgeTable( int nSize )
188 for ( nIndex=0; nIndex < nSize; nIndex++ )
190 pListHead = ( PLISTHEAD ) malloc(sizeof(ListHead));
193 InitList( pListHead );
194 PolEdges[nIndex] = pListHead;
201 void Start_Face_Struct(int numfaces)
203 if (InitFaceTable(numfaces))
205 BuildFaceTable(numfaces);
209 void Start_Edge_Struct(int numverts)
211 if (InitEdgeTable(numverts))
213 BuildEdgeTable(numverts);