1 |
/*****************************************************************
|
2 |
|
3 |
r3d_c_octree.c Type:Func
|
4 |
|
5 |
application de l octree
|
6 |
|
7 |
Date de creation : Tue Jul 15 10:42:27 1997
|
8 |
|
9 |
Derniere version : Fri Aug 1 11:07:00 1997
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
Vincent FRANCOIS
|
20 |
|
21 |
*****************************************************************/
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
/**************************/
|
28 |
/* include */
|
29 |
#include <stdio.h>
|
30 |
#include <string.h>
|
31 |
#include <stdlib.h>
|
32 |
#include "const.h"
|
33 |
#include "memoire.h"
|
34 |
#include "struct.h"
|
35 |
#include "prototype.h"
|
36 |
|
37 |
/**************************/
|
38 |
/* variables globales */
|
39 |
extern struct environnement env;
|
40 |
extern struct s_mesh *mesh;
|
41 |
extern struct s_maillage *maillage;
|
42 |
extern struct s_acis *acis;
|
43 |
|
44 |
/**************************/
|
45 |
/* programme principal */
|
46 |
|
47 |
void r3d_c_octree(void)
|
48 |
{
|
49 |
char type[255],mess[255],path[255],c,message[255];
|
50 |
int nb_oct,i;
|
51 |
int n1,n2,n3,n4,n5,n6,n7,n8,num;
|
52 |
FILE *out;
|
53 |
struct s_mnoeud *mno;
|
54 |
struct s_octree *oct;
|
55 |
struct s_msegment *mse;
|
56 |
struct s_mtriangle *mtr;
|
57 |
struct s_mtetra *mte;
|
58 |
struct s_cone *cone;
|
59 |
struct s_face *face;
|
60 |
struct s_plane *plane;
|
61 |
struct s_edge *edge;
|
62 |
struct s_straight *straight;
|
63 |
struct s_ellipse *ellipse;
|
64 |
|
65 |
aff_text(R3D_C_OC);
|
66 |
r3d_file(mess);
|
67 |
n1=sscanf(mess,"%f %f %d %d",&env.epsilon,&env.dens,&env.relatif,&nb_oct);
|
68 |
for (i=0;i<nb_oct;i++)
|
69 |
{
|
70 |
NEW_ENTITE(oct,octree,mesh->);
|
71 |
oct->num=mesh->nb_octree-1;
|
72 |
}
|
73 |
mesh->first=ADRESSE(0,octree,mesh->);
|
74 |
for (i=0;i<mesh->nb_octree;i++)
|
75 |
{
|
76 |
oct=ADRESSE(i,octree,mesh->);
|
77 |
r3d_file(mess);
|
78 |
sscanf(mess,"%c %d %d %f %f %f %f",&c,&oct->num,&oct->feuille,&oct->x,&oct->y,&oct->z,&oct->taille);
|
79 |
if (oct->feuille!=1)
|
80 |
{
|
81 |
r3d_file(mess);
|
82 |
sscanf(mess,"%d %d %d %d %d %d %d %d",&n1,&n2,&n3,&n4,&n5,&n6,&n7,&n8);
|
83 |
oct->fils[0]=ADRESSE(n1,octree,mesh->);
|
84 |
oct->fils[1]=ADRESSE(n2,octree,mesh->);
|
85 |
oct->fils[2]=ADRESSE(n3,octree,mesh->);
|
86 |
oct->fils[3]=ADRESSE(n4,octree,mesh->);
|
87 |
oct->fils[4]=ADRESSE(n5,octree,mesh->);
|
88 |
oct->fils[5]=ADRESSE(n6,octree,mesh->);
|
89 |
oct->fils[6]=ADRESSE(n7,octree,mesh->);
|
90 |
oct->fils[7]=ADRESSE(n8,octree,mesh->);
|
91 |
}
|
92 |
else mesh->nb_feuille++;
|
93 |
}
|
94 |
sprintf(message,R3D_C_OC_RE,mesh->nb_octree);
|
95 |
aff_text(message);
|
96 |
sprintf(message,R3D_C_OC_FE,mesh->nb_feuille);
|
97 |
aff_text(message);
|
98 |
aff_text(R3D_C_OC_ME);
|
99 |
strcpy(path,env.fich2);
|
100 |
path[strlen(path)-4]=0;
|
101 |
strcat(path,"_3D.mai");
|
102 |
out=fopen(path,"rt");
|
103 |
if (out==NULL)
|
104 |
{
|
105 |
aff_text(R3D_C_OC_WA1);
|
106 |
env.d3=0;
|
107 |
}
|
108 |
else
|
109 |
{
|
110 |
env.d3=1;
|
111 |
fgets(mess,255,out);
|
112 |
sscanf(mess,"%d %d",&n1,&n2);
|
113 |
for (i=0;i<n1;i++)
|
114 |
{
|
115 |
fgets(mess,255,out);
|
116 |
NEW_ENTITE(mno,mnoeud,maillage->);
|
117 |
mno->num=maillage->nb_mnoeud-1;
|
118 |
sscanf(mess,"%d %f %f %f",&n8,&(mno->x),&(mno->y),&(mno->z));
|
119 |
mno->etat=GARDE;
|
120 |
mno->nv_num=(-1);
|
121 |
}
|
122 |
for (i=0;i<n2;i++)
|
123 |
{
|
124 |
fgets(mess,255,out);
|
125 |
NEW_ENTITE(mte,mtetra,maillage->);
|
126 |
mte->num=maillage->nb_mtetra-1;
|
127 |
sscanf(mess,"%d %d %d %d %d",&n8,&n3,&n4,&n5,&n6);
|
128 |
mte->n1=n3-1;
|
129 |
mte->n2=n4-1;
|
130 |
mte->n3=n5-1;
|
131 |
mte->n4=n6-1;
|
132 |
mno=ADRESSE(mte->n1,mnoeud,maillage->);
|
133 |
NEW_POINTEUR(num,mtetra,mno->);
|
134 |
mno->mtetra[num]=mte;
|
135 |
mno=ADRESSE(mte->n2,mnoeud,maillage->);
|
136 |
NEW_POINTEUR(num,mtetra,mno->);
|
137 |
mno->mtetra[num]=mte;
|
138 |
mno=ADRESSE(mte->n3,mnoeud,maillage->);
|
139 |
NEW_POINTEUR(num,mtetra,mno->);
|
140 |
mno->mtetra[num]=mte;
|
141 |
mno=ADRESSE(mte->n4,mnoeud,maillage->);
|
142 |
NEW_POINTEUR(num,mtetra,mno->);
|
143 |
mno->mtetra[num]=mte;
|
144 |
}
|
145 |
fclose(out);
|
146 |
}
|
147 |
strcpy(path,env.fich2);
|
148 |
path[strlen(path)-4]=0;
|
149 |
strcat(path,"_2D.mai");
|
150 |
out=fopen(path,"rt");
|
151 |
if (out==NULL)
|
152 |
{
|
153 |
aff_text(R3D_C_OC_WA2);
|
154 |
abort();
|
155 |
}
|
156 |
fgets(mess,255,out);
|
157 |
sscanf(mess,"%d %d",&n1,&n2);
|
158 |
for (i=0;i<n1;i++)
|
159 |
{
|
160 |
fgets(mess,255,out);
|
161 |
if (maillage->nb_mnoeud==i)
|
162 |
{
|
163 |
NEW_ENTITE(mno,mnoeud,maillage->);
|
164 |
mno->num=maillage->nb_mnoeud-1;
|
165 |
}
|
166 |
else mno=ADRESSE(i,mnoeud,maillage->);
|
167 |
sscanf(mess,"%d %f %f %f %s %d",&n8,&(mno->x),&(mno->y),&(mno->z),type,&(mno->num_ent));
|
168 |
mno->etat=GARDE;
|
169 |
mno->nv_num=(-1);
|
170 |
if (strcmp(type,"vertex")==0) mno->type=VERTEX;
|
171 |
if (strcmp(type,"edge")==0) mno->type=EDGE;
|
172 |
if (strcmp(type,"face")==0) mno->type=FACE;
|
173 |
}
|
174 |
for (i=0;i<n2;i++)
|
175 |
{
|
176 |
fgets(mess,255,out);
|
177 |
NEW_ENTITE(mtr,mtriangle,maillage->);
|
178 |
mtr->num=maillage->nb_mtriangle-1;
|
179 |
sscanf(mess,"%d %d %d %d %s %d",&n8,&n3,&n4,&n5,type,&n6);
|
180 |
mtr->type=FACE;
|
181 |
mtr->num_ent=n6;
|
182 |
mtr->n1=n3-1;
|
183 |
mtr->n2=n4-1;
|
184 |
mtr->n3=n5-1;
|
185 |
mno=ADRESSE(mtr->n1,mnoeud,maillage->);
|
186 |
NEW_POINTEUR(num,mtriangle,mno->);
|
187 |
mno->mtriangle[num]=mtr;
|
188 |
mno=ADRESSE(mtr->n2,mnoeud,maillage->);
|
189 |
NEW_POINTEUR(num,mtriangle,mno->);
|
190 |
mno->mtriangle[num]=mtr;
|
191 |
mno=ADRESSE(mtr->n3,mnoeud,maillage->);
|
192 |
NEW_POINTEUR(num,mtriangle,mno->);
|
193 |
mno->mtriangle[num]=mtr;
|
194 |
}
|
195 |
fclose(out);
|
196 |
strcpy(path,env.fich2);
|
197 |
path[strlen(path)-4]=0;
|
198 |
strcat(path,"_1D.mai");
|
199 |
out=fopen(path,"rt");
|
200 |
if (out==NULL)
|
201 |
{
|
202 |
aff_text(R3D_C_OC_WA3);
|
203 |
abort();
|
204 |
}
|
205 |
fgets(mess,255,out);
|
206 |
sscanf(mess,"%d %d",&n1,&n2);
|
207 |
for (i=0;i<n1;i++)
|
208 |
fgets(mess,255,out);
|
209 |
for (i=0;i<n2;i++)
|
210 |
{
|
211 |
fgets(mess,255,out);
|
212 |
NEW_ENTITE(mse,msegment,maillage->);
|
213 |
mse->num=maillage->nb_msegment-1;
|
214 |
sscanf(mess,"%d %d %d",&n8,&n3,&n4);
|
215 |
mse->n1=n3-1;
|
216 |
mse->n2=n4-1;
|
217 |
}
|
218 |
fclose(out);
|
219 |
sprintf(message,R3D_C_OC_RES1,maillage->nb_mnoeud);
|
220 |
aff_text(message);
|
221 |
sprintf(message,R3D_C_OC_RES2,maillage->nb_msegment);
|
222 |
aff_text(message);
|
223 |
sprintf(message,R3D_C_OC_RES3,maillage->nb_mtriangle);
|
224 |
aff_text(message);
|
225 |
sprintf(message,R3D_C_OC_RES4,maillage->nb_mtetra);
|
226 |
aff_text(message);
|
227 |
|
228 |
|
229 |
/* remplissage de l arbre */
|
230 |
|
231 |
for (i=0;i<acis->nb_vertex;i++)
|
232 |
oc_ins_obj(VERTEX,i,mesh->first);
|
233 |
for (i=0;i<acis->nb_edge;i++)
|
234 |
{
|
235 |
edge=ADRESSE(i,edge,acis->);
|
236 |
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
237 |
{
|
238 |
straight=(struct s_straight *)acis->entity[edge->curve];
|
239 |
m1d_param_straight(edge,straight);
|
240 |
}
|
241 |
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
242 |
{
|
243 |
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
244 |
m1d_param_ellipse(edge,ellipse);
|
245 |
}
|
246 |
oc_ins_obj(EDGE,i,mesh->first);
|
247 |
}
|
248 |
for (i=0;i<acis->nb_face;i++)
|
249 |
{
|
250 |
face=ADRESSE(i,face,acis->);
|
251 |
if (strcmp(acis->type_entite[face->surface],"cone-surface")==0)
|
252 |
{
|
253 |
cone=(struct s_cone *)acis->entity[face->surface];
|
254 |
m2d_param_cone(face,cone);
|
255 |
}
|
256 |
if (strcmp(acis->type_entite[face->surface],"plane-surface")==0)
|
257 |
{
|
258 |
plane=(struct s_plane *)acis->entity[face->surface];
|
259 |
m2d_param_plane(face,plane);
|
260 |
}
|
261 |
oc_ins_obj(FACE,i,mesh->first);
|
262 |
}
|
263 |
for (i=0;i<maillage->nb_mnoeud;i++)
|
264 |
oc_ins_obj(MNOEUD,i,mesh->first);
|
265 |
for (i=0;i<maillage->nb_msegment;i++)
|
266 |
oc_ins_obj(MSEGMENT,i,mesh->first);
|
267 |
for (i=0;i<maillage->nb_mtriangle;i++)
|
268 |
oc_ins_obj(MTRIANGLE,i,mesh->first);
|
269 |
for (i=0;i<maillage->nb_mtetra;i++)
|
270 |
oc_ins_obj(MTETRA,i,mesh->first);
|
271 |
/* pour visu geometrie */
|
272 |
m1d_geo();
|
273 |
}
|