]> git.mxchange.org Git - flightgear.git/blob - Stripe_u/free.c
Added Construct/ and moved Clipper/ to it.
[flightgear.git] / Stripe_u / 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 void ParseAndFreeList( ListHead *pListHead )
20 {
21     PLISTINFO value;
22     register int c,num;
23           
24     /*    Freeing a linked list */
25     num = NumOnList(pListHead);
26     for (c = 0; c< num; c++)
27              value =   RemHead(pListHead);
28
29
30 void FreePolygonNode( PF_VERTS pfVerts)
31 {
32         /*   Free a vertex node */
33      if ( pfVerts->pPolygon )
34                 free( pfVerts->pPolygon );
35         free( pfVerts );
36
37 }
38  
39 void Free_Strips()
40 {
41     P_STRIPS temp = NULL;
42
43     /*    Free strips data structure */
44     if (strips[0] == NULL)
45          return;
46     else
47          ParseAndFreeList(strips[0]);
48 }
49
50 void FreeFaceNode( PF_FACES pfFaces)
51 {
52         /*   Free face node */
53      if ( pfFaces->pPolygon )
54                 free( pfFaces->pPolygon );
55         free( pfFaces );
56 }
57
58
59 void FreeFaceTable(int nSize)
60 {
61      register int nIndex;
62
63      for ( nIndex=0; nIndex < nSize; nIndex++ )
64      { 
65                 if ( PolFaces[nIndex] != NULL ) 
66              ParseAndFreeList( PolFaces[nIndex] );
67      }
68      free( PolFaces );
69 }
70
71 void FreeEdgeTable(int nSize)
72 {
73         register int nIndex;
74
75         for ( nIndex=0; nIndex < nSize; nIndex++ )
76         {
77                 if ( PolEdges[nIndex] != NULL )
78                         ParseAndFreeList( PolEdges[nIndex] );
79         }
80         free( PolEdges );
81 }
82
83
84 void Free_All_Strips()
85 {
86
87         ListHead *pListHead;
88         register int y;
89
90         for (y =0; ; y++)
91         {
92                 pListHead = all_strips[y];
93                 if (pListHead == NULL)
94                         return;
95                 else
96                         ParseAndFreeList(all_strips[y]);
97         }
98 }
99
100 void End_Face_Struct(int numfaces)
101 {
102      FreeFaceTable(numfaces);
103 }
104
105 void End_Edge_Struct(int numverts)
106 {
107      FreeEdgeTable(numverts);
108 }       
109
110