]> git.mxchange.org Git - flightgear.git/blob - Stripe_w/free.c
Build Triangle as a lib rather than as a program.
[flightgear.git] / Stripe_w / free.c
1 /********************************************************************/
2 /*   STRIPE: converting a polygonal model to triangle strips    
3      Francine Evans, 1996.
4      SUNY @ Stony Brook
5      Advisors: Steven Skiena and Amitabh Varshney
6 */
7 /********************************************************************/
8
9 /*---------------------------------------------------------------------*/
10 /*   STRIPE: free.c
11      This file contains the code used to free the data structures.
12 */
13 /*---------------------------------------------------------------------*/
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include "polverts.h"
18
19 ListHead *array[60];
20 int     id_array[60];
21 ListHead *strips[1];
22 ListHead *all_strips[100000]; /*  Assume max 100000 strips */
23
24 void ParseAndFreeList( ListHead *pListHead )
25 {
26     register int c,num;
27           
28     /*    Freeing a linked list */
29     num = NumOnList(pListHead);
30     for (c = 0; c< num; c++)
31              RemHead(pListHead);
32
33
34 void FreePolygonNode( PF_VERTS pfVerts)
35 {
36         /*   Free a vertex node */
37      if ( pfVerts->pPolygon )
38                 free( pfVerts->pPolygon );
39         free( pfVerts );
40
41 }
42  
43 void Free_Strips()
44 {
45     /*    Free strips data structure */
46     if (strips[0] == NULL)
47          return;
48     else
49          ParseAndFreeList(strips[0]);
50 }
51
52 void FreeFaceNode( PF_FACES pfFaces)
53 {
54         /*   Free face node */
55      if ( pfFaces->pPolygon )
56                 free( pfFaces->pPolygon );
57         free( pfFaces );
58 }
59
60
61 void FreeFaceTable(int nSize)
62 {
63      register int nIndex;
64
65      for ( nIndex=0; nIndex < nSize; nIndex++ )
66      { 
67                 if ( PolFaces[nIndex] != NULL ) 
68              ParseAndFreeList( PolFaces[nIndex] );
69      }
70      free( PolFaces );
71 }
72
73 void FreeEdgeTable(int nSize)
74 {
75         register int nIndex;
76
77         for ( nIndex=0; nIndex < nSize; nIndex++ )
78         {
79                 if ( PolEdges[nIndex] != NULL )
80                         ParseAndFreeList( PolEdges[nIndex] );
81         }
82         free( PolEdges );
83 }
84
85
86 void Free_All_Strips()
87 {
88
89         ListHead *pListHead;
90         register int y;
91
92         for (y =0; ; y++)
93         {
94                 pListHead = all_strips[y];
95                 if (pListHead == NULL)
96                         return;
97                 else
98                         ParseAndFreeList(all_strips[y]);
99         }
100 }
101
102 void End_Face_Struct(int numfaces)
103 {
104      FreeFaceTable(numfaces);
105 }
106
107 void End_Edge_Struct(int numverts)
108 {
109      FreeEdgeTable(numverts);
110 }       
111
112