ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/diamesh/src/r3d_struct.h
Revision: 253
Committed: Tue Jul 13 19:40:46 2010 UTC (14 years, 10 months ago) by francois
Content type: text/plain
File size: 7213 byte(s)
Log Message:
changement de hiearchie et utilisation de ccmake + mise a jour

File Contents

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