1 |
francois |
283 |
|
2 |
|
|
/* structures employees */ |
3 |
|
|
struct st_noeud |
4 |
|
|
{ |
5 |
|
|
int num ; |
6 |
|
|
int mark ; |
7 |
|
|
int mark2 ; |
8 |
|
|
int flag ; |
9 |
|
|
struct st_connec *tete ; |
10 |
|
|
} ; |
11 |
|
|
typedef struct st_noeud NOEUD ; |
12 |
|
|
struct st_flag |
13 |
|
|
{ |
14 |
|
|
unsigned val0: |
15 |
|
|
1 ; |
16 |
|
|
unsigned val1: |
17 |
|
|
1 ; |
18 |
|
|
unsigned val2: |
19 |
|
|
1 ; |
20 |
|
|
unsigned val3: |
21 |
|
|
1 ; |
22 |
|
|
/* alignement */ |
23 |
|
|
unsigned val4: |
24 |
|
|
1 ; |
25 |
|
|
unsigned val5: |
26 |
|
|
1 ; |
27 |
|
|
unsigned val6: |
28 |
|
|
1 ; |
29 |
|
|
unsigned val7: |
30 |
|
|
1 ; |
31 |
|
|
unsigned val8: |
32 |
|
|
1 ; |
33 |
|
|
unsigned val9: |
34 |
|
|
1 ; |
35 |
|
|
unsigned val10: |
36 |
|
|
1 ; |
37 |
|
|
unsigned val11: |
38 |
|
|
1 ; |
39 |
|
|
unsigned val12: |
40 |
|
|
1 ; |
41 |
|
|
unsigned val13: |
42 |
|
|
1 ; |
43 |
|
|
unsigned val14: |
44 |
|
|
1 ; |
45 |
|
|
unsigned val15: |
46 |
|
|
1 ; |
47 |
|
|
} ; |
48 |
|
|
typedef struct st_flag FLAG ; |
49 |
|
|
struct st_face |
50 |
|
|
{ |
51 |
|
|
int nb_qua ; |
52 |
|
|
int mark ; |
53 |
|
|
int hist ;/* historique */ |
54 |
|
|
int essai ; |
55 |
|
|
FLAG tab ; |
56 |
|
|
struct st_noeud *n1 ; |
57 |
|
|
struct st_noeud *n2 ; |
58 |
|
|
struct st_noeud *n3 ; |
59 |
|
|
struct st_tetra *tetra1 ; |
60 |
|
|
struct st_tetra *tetra2 ; |
61 |
|
|
struct st_face *prec ; |
62 |
|
|
struct st_face *suivant ; |
63 |
|
|
} ; |
64 |
|
|
typedef struct st_face FACE ; |
65 |
|
|
|
66 |
|
|
struct st_tetra /* ensemble de faces creees */ |
67 |
|
|
{ |
68 |
|
|
int num ; |
69 |
|
|
int mark ; |
70 |
|
|
struct st_face *face1 ; |
71 |
|
|
struct st_face *face2 ; |
72 |
|
|
struct st_face *face3 ; |
73 |
|
|
struct st_face *face4 ; |
74 |
|
|
}; |
75 |
|
|
typedef struct st_tetra TETRAEDRE ; |
76 |
|
|
struct st_connec |
77 |
|
|
{ |
78 |
|
|
struct st_tetra *tetra ;/* tetraedre de reference */ |
79 |
|
|
struct st_connec *suivant ;/* chainage des tetraedres lies au noeud */ |
80 |
|
|
}; |
81 |
|
|
typedef struct st_connec CONNEC ; |
82 |
|
|
struct st_gest_mem |
83 |
|
|
{ |
84 |
|
|
int ierr, icode ; |
85 |
|
|
int nb_2d ;/* mailles de la coquille */ |
86 |
|
|
int nb_init ;/* nombre de noeuds de la coquille */ |
87 |
|
|
/* table des elements 2d */ |
88 |
|
|
FACE *front ; |
89 |
|
|
int *tabele ; |
90 |
|
|
int size ; |
91 |
|
|
float *coord ;/* tableau des coordonnees */ |
92 |
|
|
int *numele ;/* tableau des elements */ |
93 |
|
|
NOEUD *tab_noeud[1000] ; |
94 |
|
|
int nb_noeud ; |
95 |
|
|
FACE *tab_face[1000] ; |
96 |
|
|
int nb_face ; |
97 |
|
|
TETRAEDRE *tab_tetra[1000] ; |
98 |
|
|
int nb_tetra ; |
99 |
|
|
CONNEC *tab_connec[1000] ; |
100 |
|
|
int nb_connec ; |
101 |
|
|
int *corresp ; |
102 |
|
|
} ; |
103 |
|
|
|
104 |
|
|
typedef struct st_gest_mem GEST_MEM ; |
105 |
|
|
|
106 |
|
|
/* ************************************************************ */ |
107 |
|
|
/* ------------------------------------------------------------ */ |
108 |
|
|
/* **************** definition de macros ******************** */ |
109 |
|
|
/* operateurs sur des structures, but : ameliorer l'alloc */ |
110 |
|
|
/* ------------------------------------------------------------ */ |
111 |
|
|
/* ************************************************************ */ |
112 |
|
|
#define NB_ENT 10 |
113 |
|
|
#define mknom(a,b) a##b |
114 |
|
|
#define TAB(entite) mknom(gest_r->tab_,entite) |
115 |
|
|
#define NBR(entite) mknom(gest_r->nb_,entite) |
116 |
|
|
/* ------------------------------------------ */ |
117 |
|
|
/* cree et retourne l'adresse de la structure */ |
118 |
|
|
/* ------------------------------------------ */ |
119 |
|
|
#define NEW_ALLOC(entite,adresse) \ |
120 |
|
|
if (TAB(entite)[NBR(entite)>>NB_ENT] == NULL ) \ |
121 |
|
|
{\ |
122 |
|
|
TAB(entite)[NBR(entite)>>NB_ENT] = (struct mknom(st_,entite) *)calloc(1<<NB_ENT,sizeof(struct mknom(st_,entite))) ; \ |
123 |
|
|
gest_r->size = gest_r->size + sizeof(struct mknom(st_,entite)) * (1<< NB_ENT) ;\ |
124 |
|
|
}\ |
125 |
|
|
if ( TAB(entite)[NBR(entite)>>NB_ENT] == NULL ) adresse = NULL ; \ |
126 |
|
|
else {\ |
127 |
|
|
adresse = &(TAB(entite)[NBR(entite)>>NB_ENT][NBR(entite)-(NBR(entite)>>NB_ENT) * (1<<NB_ENT)]) ;\ |
128 |
|
|
NBR(entite) ++ ;\ |
129 |
|
|
} |
130 |
|
|
/* ---------------------------------------------------------------- */ |
131 |
|
|
/* trouve l'adresse de la structure de type entite de numero numero */ |
132 |
|
|
/* ---------------------------------------------------------------- */ |
133 |
|
|
#define ADRESSE(entite,numero,adr)\ |
134 |
|
|
if (TAB(entite)[numero>>NB_ENT] == NULL) adr = NULL ; \ |
135 |
|
|
else adr = &(TAB(entite)[numero>>NB_ENT][numero - (numero>>NB_ENT)*(1<<NB_ENT)]) ; |
136 |
|
|
|
137 |
|
|
#define ERREUR_ALLOC_NULL(adr) \ |
138 |
|
|
if (adr == NULL) {\ |
139 |
|
|
if (debug) printf("%s\n","Erreur alloc") ;\ |
140 |
|
|
return(NULL) ;\ |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
#define ERREUR_ALLOC_FAUX(adr) \ |
144 |
|
|
if (adr == NULL) {\ |
145 |
|
|
if (debug) printf("%s\n","Erreur alloc") ;\ |
146 |
|
|
return(FAUX) ;\ |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
/* |
150 |
|
|
#define PREC(entite) mknom((entite),->prec) |
151 |
|
|
#define SUIVANT(entite) mknom((entite),->suivant) |
152 |
|
|
*/ |
153 |
|
|
|
154 |
|
|
#define PREC(entite) (entite)->prec |
155 |
|
|
#define SUIVANT(entite) (entite)->suivant |
156 |
|
|
|
157 |
|
|
|
158 |
|
|
/* suppression d'un objet d'une liste */ |
159 |
|
|
/* chainage suivant prec */ |
160 |
|
|
#define SUPPRIMER_LISTE(type,tete,fin,entite)\ |
161 |
|
|
{\ |
162 |
|
|
struct mknom(st_,type) *pcourant, *scourant ;\ |
163 |
|
|
pcourant = PREC(entite) ;\ |
164 |
|
|
scourant = SUIVANT(entite) ;\ |
165 |
|
|
if (pcourant== NULL) {\ |
166 |
|
|
if (scourant == NULL) { \ |
167 |
|
|
PREC(entite) = NULL ;\ |
168 |
|
|
SUIVANT(entite) = NULL ;\ |
169 |
|
|
tete = NULL ;\ |
170 |
|
|
fin = NULL ;\ |
171 |
|
|
}\ |
172 |
|
|
else {\ |
173 |
|
|
scourant->prec = NULL ;\ |
174 |
|
|
PREC(entite) = NULL ;\ |
175 |
|
|
SUIVANT(entite) = NULL ;\ |
176 |
|
|
tete = scourant ;\ |
177 |
|
|
}\ |
178 |
|
|
}\ |
179 |
|
|
else {\ |
180 |
|
|
if (scourant == NULL) \ |
181 |
|
|
{pcourant->suivant = NULL ;\ |
182 |
|
|
PREC(entite) = NULL ;\ |
183 |
|
|
SUIVANT(entite) = NULL ;\ |
184 |
|
|
fin = pcourant ;}\ |
185 |
|
|
else {pcourant->suivant = scourant ;\ |
186 |
|
|
scourant->prec = pcourant ;\ |
187 |
|
|
PREC(entite) = NULL ;\ |
188 |
|
|
SUIVANT(entite) = NULL ;}\ |
189 |
|
|
}\ |
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
#define INSERER_FIN_LISTE(tete,fin,entite)\ |
193 |
|
|
if (tete == NULL)\ |
194 |
|
|
/* insertion dans une liste vide */\ |
195 |
|
|
{\ |
196 |
|
|
tete = entite ;\ |
197 |
|
|
fin = entite ;\ |
198 |
|
|
}\ |
199 |
|
|
/* sinon insertion en queue de liste, la tete est inchangee */\ |
200 |
|
|
else {\ |
201 |
|
|
SUIVANT(fin) = entite ;\ |
202 |
|
|
PREC(entite) = fin ;\ |
203 |
|
|
SUIVANT(entite) = NULL ;\ |
204 |
|
|
fin = entite ;\ |
205 |
|
|
} |
206 |
|
|
|
207 |
|
|
#define INSERER_TETE_LISTE(tete,fin,entite)\ |
208 |
|
|
PREC(entite) = NULL ;\ |
209 |
|
|
if (tete != NULL) {\ |
210 |
|
|
/* la queue est inchangee */\ |
211 |
|
|
SUIVANT(entite) = tete ;\ |
212 |
|
|
PREC(tete) = entite ;\ |
213 |
|
|
tete = entite ;\ |
214 |
|
|
}\ |
215 |
|
|
else {\ |
216 |
|
|
SUIVANT(entite) = NULL ;\ |
217 |
|
|
tete = entite ;\ |
218 |
|
|
fin = entite ;\ |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
#define INSERE_TETE(tete,entite)\ |
222 |
|
|
SUIVANT(entite) = tete ;\ |
223 |
|
|
tete = entite ; |
224 |
|
|
|
225 |
|
|
#define INIT_ALLOC(entite)\ |
226 |
|
|
{\ |
227 |
|
|
int i ;\ |
228 |
|
|
for (i=0;i<1000;i++)\ |
229 |
|
|
{\ |
230 |
|
|
TAB(entite)[i] = NULL ;\ |
231 |
|
|
NBR(entite) = 0 ;\ |
232 |
|
|
}\ |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
#define FREE_ALLOC(entite)\ |
236 |
|
|
{\ |
237 |
|
|
int i ;\ |
238 |
|
|
i = 0 ;\ |
239 |
|
|
while (TAB(entite)[i] !=NULL)\ |
240 |
|
|
{\ |
241 |
|
|
free(TAB(entite)[i]) ;\ |
242 |
|
|
TAB(entite)[i] = NULL ;\ |
243 |
|
|
i++ ;\ |
244 |
|
|
}\ |
245 |
|
|
} |
246 |
|
|
|
247 |
|
|
#define TRI_REEL(tab,nb_val,iordre)\ |
248 |
|
|
{\ |
249 |
|
|
int i ;\ |
250 |
|
|
for (i=0;i<nb_val;i++) iordre[i] = i+1 ;\ |
251 |
|
|
trirea(tab,&nb_val,iordre) ; \ |
252 |
|
|
} |
253 |
|
|
|
254 |
|
|
#define BOITE(n1,n2,n3,n4,vmin,vmax)\ |
255 |
|
|
vmin[0] = min(coord[x(n1->num)],coord[x(n2->num)]) ;\ |
256 |
|
|
vmin[0] = min(vmin[0],coord[x(n3->num)]) ;\ |
257 |
|
|
if (n4 != NULL) vmin[0] = min(vmin[0],coord[x(n4->num)]) ;\ |
258 |
|
|
vmin[1] = min(coord[y(n1->num)],coord[y(n2->num)]) ;\ |
259 |
|
|
vmin[1] = min(vmin[1],coord[y(n3->num)]) ;\ |
260 |
|
|
if (n4 != NULL) vmin[1] = min(vmin[1],coord[y(n4->num)]) ;\ |
261 |
|
|
vmin[2] = min(coord[z(n1->num)],coord[z(n2->num)]) ;\ |
262 |
|
|
vmin[2] = min(vmin[2],coord[z(n3->num)]) ;\ |
263 |
|
|
if (n4 != NULL) vmin[2] = min(vmin[2],coord[z(n4->num)]) ;\ |
264 |
|
|
vmax[0] = max(coord[x(n1->num)],coord[x(n2->num)]) ;\ |
265 |
|
|
vmax[0] = max(vmax[0],coord[x(n3->num)]) ;\ |
266 |
|
|
if (n4 != NULL) vmax[0] = max(vmax[0],coord[x(n4->num)]) ;\ |
267 |
|
|
vmax[1] = max(coord[y(n1->num)],coord[y(n2->num)]) ;\ |
268 |
|
|
vmax[1] = max(vmax[1],coord[y(n3->num)]) ;\ |
269 |
|
|
if (n4 != NULL) vmax[1] = max(vmax[1],coord[y(n4->num)]) ;\ |
270 |
|
|
vmax[2] = max(coord[z(n1->num)],coord[z(n2->num)]) ;\ |
271 |
|
|
vmax[2] = max(vmax[2],coord[z(n3->num)]) ;\ |
272 |
|
|
if (n4 != NULL) vmax[2] = max(vmax[2],coord[z(n4->num)]) ; |
273 |
|
|
|
274 |
|
|
#define NOEUD_TETRA(tetra,noeud)\ |
275 |
|
|
if (((tetra->face2)->n1 != (tetra->face1)->n1) && ((tetra->face2)->n1 != (tetra->face1)->n2) && ((tetra->face2)->n1 != (tetra->face1)->n3)) \ |
276 |
|
|
noeud = (tetra->face2)->n1 ;\ |
277 |
|
|
else if (((tetra->face2)->n2 != (tetra->face1)->n1) && ((tetra->face2)->n2 != (tetra->face1)->n2) && ((tetra->face2)->n2 != (tetra->face1)->n3)) \ |
278 |
|
|
noeud = (tetra->face2)->n2 ;\ |
279 |
|
|
else noeud = (tetra->face2)->n3 ; |