1 |
francois |
283 |
#include <stdio.h> |
2 |
|
|
#include <string.h> |
3 |
|
|
#include <stdlib.h> |
4 |
|
|
#include "m3d_struct.h" |
5 |
|
|
#include "m3d_const.h" |
6 |
|
|
#include "m3d_hotes.h" |
7 |
|
|
#include "m3d_erreur.h" |
8 |
|
|
#include "prototype.h" |
9 |
|
|
|
10 |
|
|
extern GEST_MEM *gest ; |
11 |
|
|
extern char *num_version; |
12 |
|
|
|
13 |
|
|
void m3d_init(void) |
14 |
|
|
{ |
15 |
|
|
|
16 |
|
|
if (gest!= NULL) { |
17 |
|
|
if (gest->tab_seg !=NULL) free(gest->tab_seg) ; |
18 |
|
|
gest->tab_seg = NULL ; |
19 |
|
|
if (gest->tab_surf !=NULL) free(gest->tab_surf) ; |
20 |
|
|
gest->tab_surf = NULL ; |
21 |
|
|
if (gest->tab_ele !=NULL) free(gest->tab_ele) ; |
22 |
|
|
gest->tab_ele = NULL ; |
23 |
|
|
if (gest->tab_ele2 !=NULL) free(gest->tab_ele2) ; |
24 |
|
|
gest->tab_ele2 = NULL ; |
25 |
|
|
if (gest->v_inter!=NULL) free(gest->v_inter) ; |
26 |
|
|
gest->v_inter = NULL ; |
27 |
|
|
if (gest->envel!=NULL) free(gest->envel) ; |
28 |
|
|
gest->envel = NULL ; |
29 |
|
|
if (gest->tab_rec!=NULL) free(gest->tab_rec) ; |
30 |
|
|
gest->tab_rec = NULL ; |
31 |
|
|
/* m3dtet */ |
32 |
|
|
if (gest->vcorg !=NULL) free(gest->vcorg) ; |
33 |
|
|
gest->vcorg = NULL ; |
34 |
|
|
if (gest->numele !=NULL) free(gest->numele) ; |
35 |
|
|
gest->numele = NULL ; |
36 |
|
|
if (gest->coord !=NULL) free(gest->coord) ; |
37 |
|
|
gest->coord = NULL ; |
38 |
|
|
if (gest->tabele !=NULL) free(gest->tabele) ; |
39 |
|
|
gest->tabele = NULL ; |
40 |
|
|
if (gest->coord2 !=NULL) free(gest->coord2) ; |
41 |
|
|
gest->coord2 = NULL ; |
42 |
|
|
if (gest->old !=NULL) free(gest->old) ; |
43 |
|
|
gest->old = NULL ; |
44 |
|
|
if (gest->neww !=NULL) free(gest->neww) ; |
45 |
|
|
gest->neww = NULL ; |
46 |
|
|
if (gest->tablin !=NULL) free(gest->tablin) ; |
47 |
|
|
gest->tablin = NULL ; |
48 |
|
|
if (gest->numele2 !=NULL) free(gest->numele2) ; |
49 |
|
|
gest->numele2 = NULL ; |
50 |
|
|
if (gest->connec !=NULL) free(gest->connec) ; |
51 |
|
|
gest->connec = NULL ; |
52 |
|
|
if (gest->tabcor !=NULL) free(gest->tabcor) ; |
53 |
|
|
gest->tabcor = NULL ; |
54 |
|
|
if (gest->tabcoul !=NULL) free(gest->tabcoul) ; |
55 |
|
|
gest->tabcoul = NULL ; |
56 |
|
|
/* m3d_crit */ |
57 |
|
|
if (gest->tab_voisin !=NULL) free(gest->tab_voisin) ; |
58 |
|
|
gest->tab_voisin = NULL ; |
59 |
|
|
|
60 |
|
|
/* m3d_maidft */ |
61 |
|
|
if (gest->val_noeud !=NULL) free(gest->val_noeud) ; |
62 |
|
|
gest->val_noeud = NULL ; |
63 |
|
|
if (gest->corresp !=NULL) free(gest->corresp) ; |
64 |
|
|
gest->corresp = NULL ; |
65 |
|
|
if (gest->number!=NULL) free(gest->number) ; |
66 |
|
|
gest->number = NULL ; |
67 |
|
|
/* listes de structures */ |
68 |
|
|
FREE_ALLOC(noeud) |
69 |
|
|
FREE_ALLOC(face) |
70 |
|
|
FREE_ALLOC(tetra) |
71 |
|
|
FREE_ALLOC(objet) |
72 |
|
|
FREE_ALLOC(connec) |
73 |
|
|
FREE_ALLOC(oct) |
74 |
|
|
free(gest) ; |
75 |
|
|
gest = NULL ; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
gest = (GEST_MEM *)calloc(1,sizeof(struct st_gest_mem)) ; |
79 |
|
|
if (gest== NULL) |
80 |
|
|
{ |
81 |
|
|
m3d_erreur(ERR_ALLOC); |
82 |
|
|
return; |
83 |
|
|
} |
84 |
|
|
strcpy( gest->release ,num_version); |
85 |
|
|
/* initialisations */ |
86 |
|
|
|
87 |
|
|
gest->icode = FAUX ; |
88 |
|
|
gest->size = 0 ; |
89 |
|
|
gest->nb_good = 0 ; |
90 |
|
|
gest->nb_medium = 0 ; |
91 |
|
|
gest->nb_low = 0 ; |
92 |
|
|
gest->nb_bad = 0 ; |
93 |
|
|
gest->cpu = 0.0 ; |
94 |
|
|
/* m3dtet */ |
95 |
|
|
gest->numax = 0 ; |
96 |
|
|
gest->numael = 0 ; |
97 |
|
|
gest->is_qua = 0 ; |
98 |
|
|
gest->nb_noe_qua = 0 ; |
99 |
|
|
/* structures */ |
100 |
|
|
INIT_ALLOC(noeud) |
101 |
|
|
INIT_ALLOC(face) |
102 |
|
|
INIT_ALLOC(tetra) |
103 |
|
|
INIT_ALLOC(objet) |
104 |
|
|
INIT_ALLOC(connec) |
105 |
|
|
INIT_ALLOC(oct) |
106 |
|
|
gest->root = NULL ; |
107 |
|
|
gest->buffer[0] = 0 ; |
108 |
|
|
gest->nb_init = 0 ; |
109 |
|
|
gest->nb_2d = 0 ; |
110 |
|
|
gest->coeff = 0. ; |
111 |
|
|
gest->xmin = 0. ; |
112 |
|
|
gest->ymin = 0. ; |
113 |
|
|
gest->zmin = 0. ; |
114 |
|
|
gest->xmax = 0. ; |
115 |
|
|
gest->ymax = 0. ; |
116 |
|
|
gest->zmax = 0. ; |
117 |
|
|
gest->premiere_couche = FAUX ; |
118 |
|
|
gest->lecture_donnees = FAUX ; |
119 |
|
|
return ; |
120 |
|
|
} |
121 |
|
|
|