1 |
|
5 |
//---------------------------------------------------------------------------
|
2 |
|
|
#include "gestionversion.h"
|
3 |
|
|
#include <vcl.h>
|
4 |
|
|
#pragma hdrstop
|
5 |
|
|
|
6 |
|
|
#include <math.h>
|
7 |
|
|
#include "importcarte.h"
|
8 |
|
|
#include "mg_gestionnaire.h"
|
9 |
|
|
#include "ot_mathematique.h"
|
10 |
|
|
#include "visuctt.h"
|
11 |
|
|
//---------------------------------------------------------------------------
|
12 |
|
|
#pragma package(smart_init)
|
13 |
|
|
#pragma resource "*.dfm"
|
14 |
|
|
Tfimcarte *fimcarte;
|
15 |
|
|
//---------------------------------------------------------------------------
|
16 |
|
|
__fastcall Tfimcarte::Tfimcarte(TComponent* Owner,MG_GESTIONNAIRE *magic)
|
17 |
|
|
: TForm(Owner),gest(magic)
|
18 |
|
|
{
|
19 |
|
|
}
|
20 |
|
|
//---------------------------------------------------------------------------
|
21 |
|
|
void __fastcall Tfimcarte::Button3Click(TObject *Sender)
|
22 |
|
|
{
|
23 |
|
|
Close();
|
24 |
|
|
}
|
25 |
|
|
//---------------------------------------------------------------------------
|
26 |
|
|
void __fastcall Tfimcarte::FormClose(TObject *Sender, TCloseAction &Action)
|
27 |
|
|
{
|
28 |
|
|
Action=caFree;
|
29 |
|
|
}
|
30 |
|
|
//---------------------------------------------------------------------------
|
31 |
|
|
void __fastcall Tfimcarte::Button2Click(TObject *Sender)
|
32 |
|
|
{
|
33 |
|
|
if (OpenDialog1->Execute()) Edit1->Text=OpenDialog1->FileName;
|
34 |
|
|
}
|
35 |
|
|
//---------------------------------------------------------------------------
|
36 |
|
|
|
37 |
|
|
void __fastcall Tfimcarte::Button7Click(TObject *Sender)
|
38 |
|
|
{
|
39 |
|
|
if (OpenDialog1->Execute()) Edit2->Text=OpenDialog1->FileName;
|
40 |
|
|
}
|
41 |
|
|
//---------------------------------------------------------------------------
|
42 |
|
|
|
43 |
|
|
void __fastcall Tfimcarte::Button1Click(TObject *Sender)
|
44 |
|
|
{
|
45 |
|
|
MG_MAILLAGE* mgmai=gest->get_mg_maillageid(atol(ComboBox1->Text.c_str()));
|
46 |
|
|
if (mgmai!=NULL)
|
47 |
|
|
{
|
48 |
|
|
int nb_noeud=mgmai->get_nb_mg_noeud();
|
49 |
|
|
char nomfichier[500];
|
50 |
|
|
strcpy(nomfichier,Caption.c_str());
|
51 |
|
|
nomfichier[strlen(nomfichier)-6]=0;
|
52 |
|
|
int nb_sol=gest->get_nb_mg_solution()+gest->get_nb_fem_solution();
|
53 |
|
|
char mess[30];
|
54 |
|
|
sprintf(mess,".sol%d",nb_sol+1);
|
55 |
|
|
strcat(nomfichier,mess);
|
56 |
|
|
string nomsol="Carte de taille reelle";
|
57 |
|
|
MG_SOLUTION* mgsol=new MG_SOLUTION(mgmai,1,nomfichier,nb_noeud,nomsol);
|
58 |
|
|
gest->ajouter_mg_solution(mgsol);
|
59 |
|
|
mgsol->change_legende(0,"F(x,y,z)");
|
60 |
|
|
for (int j=0;j<nb_noeud;j++)
|
61 |
|
|
{
|
62 |
|
|
MG_NOEUD* noeud=mgmai->get_mg_noeud(j);
|
63 |
|
|
int nb_segment=noeud->get_lien_segment()->get_nb();
|
64 |
|
|
double ec=0.;int nbr=0;
|
65 |
|
|
for (int k=0;k<nb_segment;k++)
|
66 |
|
|
{
|
67 |
|
|
MG_SEGMENT* seg=noeud->get_lien_segment()->get(k);
|
68 |
|
|
MG_SEGMENT* segtmp=mgmai->get_mg_segmentid(seg->get_id());
|
69 |
|
|
if (segtmp!=NULL)
|
70 |
|
|
{
|
71 |
|
|
nbr++;
|
72 |
|
|
ec=ec+seg->get_longueur();
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
}
|
76 |
|
|
ec=ec/nbr;
|
77 |
|
|
mgsol->ecrire(j,0,ec);
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
gest->enregistrer(Caption.c_str());
|
81 |
|
|
}
|
82 |
|
|
//---------------------------------------------------------------------------
|
83 |
|
|
|
84 |
|
|
void __fastcall Tfimcarte::Button5Click(TObject *Sender)
|
85 |
|
|
{
|
86 |
|
|
FEM_MAILLAGE* femmai=gest->get_fem_maillageid(atol(ComboBox2->Text.c_str()));
|
87 |
|
|
if (femmai!=NULL)
|
88 |
|
|
{
|
89 |
|
|
int nb_noeud=femmai->get_nb_fem_noeud();
|
90 |
|
|
char nomfichier[500];
|
91 |
|
|
strcpy(nomfichier,Caption.c_str());
|
92 |
|
|
nomfichier[strlen(nomfichier)-6]=0;
|
93 |
|
|
int nb_sol=gest->get_nb_mg_solution()+gest->get_nb_fem_solution();
|
94 |
|
|
char mess[30];
|
95 |
|
|
sprintf(mess,".sol%d",nb_sol+1);
|
96 |
|
|
strcat(nomfichier,mess);
|
97 |
|
|
string nomsol="Carte de taille reelle";
|
98 |
|
|
FEM_SOLUTION* femsol=new FEM_SOLUTION(femmai,1,nomfichier,nb_noeud,nomsol);
|
99 |
|
|
gest->ajouter_fem_solution(femsol);
|
100 |
|
|
femsol->change_legende(0,"F(x,y,z)");
|
101 |
|
|
int nbseg=femmai->get_nb_fem_segment();
|
102 |
|
|
int nbtri=femmai->get_nb_fem_triangle();
|
103 |
|
|
int nbtet=femmai->get_nb_fem_tetra();
|
104 |
|
|
int base;
|
105 |
|
|
if (nbtet!=0) base=3; else if (nbtri!=0) base=2; else if (nbseg!=0) base=1; else base=0;
|
106 |
|
|
for (int j=0;j<nb_noeud;j++)
|
107 |
|
|
{
|
108 |
|
|
double ec=0.;
|
109 |
|
|
int nbr=0;
|
110 |
|
|
FEM_NOEUD* noeud=femmai->get_fem_noeud(j);
|
111 |
|
|
int nb;
|
112 |
|
|
double longueur;
|
113 |
|
|
if (base==1)
|
114 |
|
|
{
|
115 |
|
|
nb=noeud->get_lien_segment()->get_nb();
|
116 |
|
|
for (int k=0;k<nb;k++)
|
117 |
|
|
{
|
118 |
|
|
FEM_SEGMENT* segment=noeud->get_lien_segment()->get(k);
|
119 |
|
|
calcule_longueur_segment(noeud,segment,ec,nbr);
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
if (base==2)
|
123 |
|
|
{
|
124 |
|
|
nb=noeud->get_lien_triangle()->get_nb();
|
125 |
|
|
for (int k=0;k<nb;k++)
|
126 |
|
|
{
|
127 |
|
|
FEM_TRIANGLE* triangle=noeud->get_lien_triangle()->get(k);
|
128 |
|
|
calcule_longueur_triangle(noeud,triangle,ec,nbr);
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
if (base==3)
|
132 |
|
|
{
|
133 |
|
|
nb=noeud->get_lien_tetra()->get_nb();
|
134 |
|
|
for (int k=0;k<nb;k++)
|
135 |
|
|
{
|
136 |
|
|
FEM_TETRA* tetra=noeud->get_lien_tetra()->get(k);
|
137 |
|
|
calcule_longueur_tetra(noeud,tetra,ec,nbr);
|
138 |
|
|
}
|
139 |
|
|
}
|
140 |
|
|
if (nbr==0) ec=-1.; else ec=ec/nbr;
|
141 |
|
|
femsol->ecrire(j,0,ec);
|
142 |
|
|
}
|
143 |
|
|
gest->enregistrer(Caption.c_str());
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
//---------------------------------------------------------------------------
|
147 |
|
|
void __fastcall Tfimcarte::calcule_longueur_segment(FEM_NOEUD* noeud,FEM_SEGMENT* segment,double &ec,int &nbr)
|
148 |
|
|
{
|
149 |
|
|
int nb=segment->get_nb_fem_noeud();
|
150 |
|
|
if (nb==2)
|
151 |
|
|
{
|
152 |
|
|
double l=calcul_dist_noeud_noeud(segment->get_fem_noeud(0),segment->get_fem_noeud(1));
|
153 |
|
|
ec=ec+l;
|
154 |
|
|
nbr++;
|
155 |
|
|
}
|
156 |
|
|
if (nb==3)
|
157 |
|
|
{
|
158 |
|
|
FEM_NOEUD* noeud1=segment->get_fem_noeud(0);
|
159 |
|
|
FEM_NOEUD* noeud2=segment->get_fem_noeud(1);
|
160 |
|
|
FEM_NOEUD* noeud3=segment->get_fem_noeud(2);
|
161 |
|
|
if (noeud==noeud1)
|
162 |
|
|
{
|
163 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
164 |
|
|
ec=ec+l;
|
165 |
|
|
nbr++;
|
166 |
|
|
}
|
167 |
|
|
if (noeud==noeud2)
|
168 |
|
|
{
|
169 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
170 |
|
|
ec=ec+l;
|
171 |
|
|
nbr++;
|
172 |
|
|
}
|
173 |
|
|
if (noeud==noeud3)
|
174 |
|
|
{
|
175 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
176 |
|
|
ec=ec+l;
|
177 |
|
|
nbr=nbr++;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
//---------------------------------------------------------------------------
|
183 |
|
|
void __fastcall Tfimcarte::calcule_longueur_triangle(FEM_NOEUD* noeud,FEM_TRIANGLE* triangle,double &ec,int &nbr)
|
184 |
|
|
{
|
185 |
|
|
int nb=triangle->get_nb_fem_noeud();
|
186 |
|
|
if (nb==3)
|
187 |
|
|
{
|
188 |
|
|
FEM_NOEUD* noeud1=triangle->get_fem_noeud(0);
|
189 |
|
|
FEM_NOEUD* noeud2=triangle->get_fem_noeud(1);
|
190 |
|
|
FEM_NOEUD* noeud3=triangle->get_fem_noeud(2);
|
191 |
|
|
if (noeud==noeud1)
|
192 |
|
|
{
|
193 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2);
|
194 |
|
|
ec=ec+l;
|
195 |
|
|
nbr++;
|
196 |
|
|
l=calcul_dist_noeud_noeud(noeud1,noeud3);
|
197 |
|
|
ec=ec+l;
|
198 |
|
|
nbr++;
|
199 |
|
|
}
|
200 |
|
|
if (noeud==noeud2)
|
201 |
|
|
{
|
202 |
|
|
double l=calcul_dist_noeud_noeud(noeud2,noeud2);
|
203 |
|
|
ec=ec+l;
|
204 |
|
|
nbr++;
|
205 |
|
|
l=calcul_dist_noeud_noeud(noeud2,noeud3);
|
206 |
|
|
ec=ec+l;
|
207 |
|
|
nbr++;
|
208 |
|
|
}
|
209 |
|
|
if (noeud==noeud3)
|
210 |
|
|
{
|
211 |
|
|
double l=calcul_dist_noeud_noeud(noeud3,noeud1);
|
212 |
|
|
ec=ec+l;
|
213 |
|
|
nbr++;
|
214 |
|
|
l=calcul_dist_noeud_noeud(noeud3,noeud2);
|
215 |
|
|
ec=ec+l;
|
216 |
|
|
nbr++;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
}
|
220 |
|
|
if (nb==6)
|
221 |
|
|
{
|
222 |
|
|
FEM_NOEUD* noeud1=triangle->get_fem_noeud(0);
|
223 |
|
|
FEM_NOEUD* noeud2=triangle->get_fem_noeud(1);
|
224 |
|
|
FEM_NOEUD* noeud3=triangle->get_fem_noeud(2);
|
225 |
|
|
FEM_NOEUD* noeud4=triangle->get_fem_noeud(3);
|
226 |
|
|
FEM_NOEUD* noeud5=triangle->get_fem_noeud(4);
|
227 |
|
|
FEM_NOEUD* noeud6=triangle->get_fem_noeud(5);
|
228 |
|
|
if (noeud==noeud1)
|
229 |
|
|
{
|
230 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
231 |
|
|
ec=ec+l;
|
232 |
|
|
nbr++;
|
233 |
|
|
l=calcul_dist_noeud_noeud(noeud1,noeud6)+calcul_dist_noeud_noeud(noeud6,noeud5);
|
234 |
|
|
ec=ec+l;
|
235 |
|
|
nbr++;
|
236 |
|
|
}
|
237 |
|
|
if (noeud==noeud2)
|
238 |
|
|
{
|
239 |
|
|
double l=calcul_dist_noeud_noeud(noeud2,noeud1)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
240 |
|
|
ec=ec+l;
|
241 |
|
|
nbr++;
|
242 |
|
|
}
|
243 |
|
|
if (noeud==noeud3)
|
244 |
|
|
{
|
245 |
|
|
double l=calcul_dist_noeud_noeud(noeud3,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud1);
|
246 |
|
|
ec=ec+l;
|
247 |
|
|
nbr++;
|
248 |
|
|
l=calcul_dist_noeud_noeud(noeud3,noeud4)+calcul_dist_noeud_noeud(noeud4,noeud5);
|
249 |
|
|
ec=ec+l;
|
250 |
|
|
nbr++;
|
251 |
|
|
}
|
252 |
|
|
if (noeud==noeud4)
|
253 |
|
|
{
|
254 |
|
|
double l=calcul_dist_noeud_noeud(noeud4,noeud3)+calcul_dist_noeud_noeud(noeud4,noeud5);
|
255 |
|
|
ec=ec+l;
|
256 |
|
|
nbr++;
|
257 |
|
|
}
|
258 |
|
|
if (noeud==noeud5)
|
259 |
|
|
{
|
260 |
|
|
double l=calcul_dist_noeud_noeud(noeud5,noeud4)+calcul_dist_noeud_noeud(noeud4,noeud3);
|
261 |
|
|
ec=ec+l;
|
262 |
|
|
nbr++;
|
263 |
|
|
l=calcul_dist_noeud_noeud(noeud5,noeud6)+calcul_dist_noeud_noeud(noeud6,noeud1);
|
264 |
|
|
ec=ec+l;
|
265 |
|
|
nbr++;
|
266 |
|
|
}
|
267 |
|
|
if (noeud==noeud6)
|
268 |
|
|
{
|
269 |
|
|
double l=calcul_dist_noeud_noeud(noeud6,noeud5)+calcul_dist_noeud_noeud(noeud6,noeud1);
|
270 |
|
|
ec=ec+l;
|
271 |
|
|
nbr++;
|
272 |
|
|
}
|
273 |
|
|
}
|
274 |
|
|
}
|
275 |
|
|
//---------------------------------------------------------------------------
|
276 |
|
|
void __fastcall Tfimcarte::calcule_longueur_tetra(FEM_NOEUD* noeud,FEM_TETRA* tetra,double &ec,int &nbr)
|
277 |
|
|
{
|
278 |
|
|
int nb=tetra->get_nb_fem_noeud();
|
279 |
|
|
if (nb==4)
|
280 |
|
|
{
|
281 |
|
|
FEM_NOEUD* noeud1=tetra->get_fem_noeud(0);
|
282 |
|
|
FEM_NOEUD* noeud2=tetra->get_fem_noeud(1);
|
283 |
|
|
FEM_NOEUD* noeud3=tetra->get_fem_noeud(2);
|
284 |
|
|
FEM_NOEUD* noeud4=tetra->get_fem_noeud(3);
|
285 |
|
|
if (noeud==noeud1)
|
286 |
|
|
{
|
287 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2);
|
288 |
|
|
ec=ec+l;
|
289 |
|
|
nbr++;
|
290 |
|
|
l=calcul_dist_noeud_noeud(noeud1,noeud3);
|
291 |
|
|
ec=ec+l;
|
292 |
|
|
nbr++;
|
293 |
|
|
l=calcul_dist_noeud_noeud(noeud1,noeud4);
|
294 |
|
|
ec=ec+l;
|
295 |
|
|
nbr++;
|
296 |
|
|
}
|
297 |
|
|
if (noeud==noeud2)
|
298 |
|
|
{
|
299 |
|
|
double l=calcul_dist_noeud_noeud(noeud2,noeud1);
|
300 |
|
|
ec=ec+l;
|
301 |
|
|
nbr++;
|
302 |
|
|
l=calcul_dist_noeud_noeud(noeud2,noeud3);
|
303 |
|
|
ec=ec+l;
|
304 |
|
|
nbr++;
|
305 |
|
|
l=calcul_dist_noeud_noeud(noeud2,noeud4);
|
306 |
|
|
ec=ec+l;
|
307 |
|
|
nbr++;
|
308 |
|
|
}
|
309 |
|
|
if (noeud==noeud3)
|
310 |
|
|
{
|
311 |
|
|
double l=calcul_dist_noeud_noeud(noeud3,noeud1);
|
312 |
|
|
ec=ec+l;
|
313 |
|
|
nbr++;
|
314 |
|
|
l=calcul_dist_noeud_noeud(noeud3,noeud2);
|
315 |
|
|
ec=ec+l;
|
316 |
|
|
nbr++;
|
317 |
|
|
l=calcul_dist_noeud_noeud(noeud3,noeud4);
|
318 |
|
|
ec=ec+l;
|
319 |
|
|
nbr++;
|
320 |
|
|
}
|
321 |
|
|
if (noeud==noeud4)
|
322 |
|
|
{
|
323 |
|
|
double l=calcul_dist_noeud_noeud(noeud4,noeud1);
|
324 |
|
|
ec=ec+l;
|
325 |
|
|
nbr++;
|
326 |
|
|
l=calcul_dist_noeud_noeud(noeud4,noeud2);
|
327 |
|
|
ec=ec+l;
|
328 |
|
|
nbr++;
|
329 |
|
|
l=calcul_dist_noeud_noeud(noeud4,noeud3);
|
330 |
|
|
ec=ec+l;
|
331 |
|
|
nbr++;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
}
|
335 |
|
|
if (nb==10)
|
336 |
|
|
{
|
337 |
|
|
FEM_NOEUD* noeud1=tetra->get_fem_noeud(0);
|
338 |
|
|
FEM_NOEUD* noeud2=tetra->get_fem_noeud(1);
|
339 |
|
|
FEM_NOEUD* noeud3=tetra->get_fem_noeud(2);
|
340 |
|
|
FEM_NOEUD* noeud4=tetra->get_fem_noeud(3);
|
341 |
|
|
FEM_NOEUD* noeud5=tetra->get_fem_noeud(4);
|
342 |
|
|
FEM_NOEUD* noeud6=tetra->get_fem_noeud(5);
|
343 |
|
|
FEM_NOEUD* noeud7=tetra->get_fem_noeud(6);
|
344 |
|
|
FEM_NOEUD* noeud8=tetra->get_fem_noeud(7);
|
345 |
|
|
FEM_NOEUD* noeud9=tetra->get_fem_noeud(8);
|
346 |
|
|
FEM_NOEUD* noeud10=tetra->get_fem_noeud(9);
|
347 |
|
|
if (noeud==noeud1)
|
348 |
|
|
{
|
349 |
|
|
double l=calcul_dist_noeud_noeud(noeud1,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
350 |
|
|
ec=ec+l;
|
351 |
|
|
nbr++;
|
352 |
|
|
l=calcul_dist_noeud_noeud(noeud1,noeud6)+calcul_dist_noeud_noeud(noeud6,noeud5);
|
353 |
|
|
ec=ec+l;
|
354 |
|
|
nbr++;
|
355 |
|
|
l=calcul_dist_noeud_noeud(noeud1,noeud7)+calcul_dist_noeud_noeud(noeud7,noeud10);;
|
356 |
|
|
ec=ec+l;
|
357 |
|
|
nbr++;
|
358 |
|
|
}
|
359 |
|
|
if (noeud==noeud2)
|
360 |
|
|
{
|
361 |
|
|
double l=calcul_dist_noeud_noeud(noeud2,noeud1)+calcul_dist_noeud_noeud(noeud2,noeud3);
|
362 |
|
|
ec=ec+l;
|
363 |
|
|
nbr++;
|
364 |
|
|
}
|
365 |
|
|
if (noeud==noeud3)
|
366 |
|
|
{
|
367 |
|
|
double l=calcul_dist_noeud_noeud(noeud3,noeud2)+calcul_dist_noeud_noeud(noeud2,noeud1);
|
368 |
|
|
ec=ec+l;
|
369 |
|
|
nbr++;
|
370 |
|
|
l=calcul_dist_noeud_noeud(noeud3,noeud4)+calcul_dist_noeud_noeud(noeud4,noeud5);
|
371 |
|
|
ec=ec+l;
|
372 |
|
|
nbr++;
|
373 |
|
|
l=calcul_dist_noeud_noeud(noeud3,noeud8)+calcul_dist_noeud_noeud(noeud1,noeud10);
|
374 |
|
|
ec=ec+l;
|
375 |
|
|
nbr++;
|
376 |
|
|
}
|
377 |
|
|
if (noeud==noeud4)
|
378 |
|
|
{
|
379 |
|
|
double l=calcul_dist_noeud_noeud(noeud4,noeud3)+calcul_dist_noeud_noeud(noeud4,noeud5);
|
380 |
|
|
ec=ec+l;
|
381 |
|
|
nbr++;
|
382 |
|
|
}
|
383 |
|
|
if (noeud==noeud5)
|
384 |
|
|
{
|
385 |
|
|
double l=calcul_dist_noeud_noeud(noeud5,noeud4)+calcul_dist_noeud_noeud(noeud4,noeud3);
|
386 |
|
|
ec=ec+l;
|
387 |
|
|
nbr++;
|
388 |
|
|
l=calcul_dist_noeud_noeud(noeud5,noeud6)+calcul_dist_noeud_noeud(noeud6,noeud1);
|
389 |
|
|
ec=ec+l;
|
390 |
|
|
nbr++;
|
391 |
|
|
l=calcul_dist_noeud_noeud(noeud5,noeud9)+calcul_dist_noeud_noeud(noeud9,noeud10);
|
392 |
|
|
ec=ec+l;
|
393 |
|
|
nbr++;
|
394 |
|
|
}
|
395 |
|
|
if (noeud==noeud6)
|
396 |
|
|
{
|
397 |
|
|
double l=calcul_dist_noeud_noeud(noeud6,noeud5)+calcul_dist_noeud_noeud(noeud6,noeud1);
|
398 |
|
|
ec=ec+l;
|
399 |
|
|
nbr++;
|
400 |
|
|
}
|
401 |
|
|
if (noeud==noeud7)
|
402 |
|
|
{
|
403 |
|
|
double l=calcul_dist_noeud_noeud(noeud7,noeud1)+calcul_dist_noeud_noeud(noeud7,noeud10);
|
404 |
|
|
ec=ec+l;
|
405 |
|
|
nbr++;
|
406 |
|
|
}
|
407 |
|
|
if (noeud==noeud8)
|
408 |
|
|
{
|
409 |
|
|
double l=calcul_dist_noeud_noeud(noeud8,noeud3)+calcul_dist_noeud_noeud(noeud8,noeud10);
|
410 |
|
|
ec=ec+l;
|
411 |
|
|
nbr++;
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
if (noeud==noeud9)
|
415 |
|
|
{
|
416 |
|
|
double l=calcul_dist_noeud_noeud(noeud9,noeud5)+calcul_dist_noeud_noeud(noeud9,noeud10);
|
417 |
|
|
ec=ec+l;
|
418 |
|
|
nbr++;
|
419 |
|
|
}
|
420 |
|
|
if (noeud==noeud10)
|
421 |
|
|
{
|
422 |
|
|
double l=calcul_dist_noeud_noeud(noeud10,noeud7)+calcul_dist_noeud_noeud(noeud7,noeud1);
|
423 |
|
|
ec=ec+l;
|
424 |
|
|
nbr++;
|
425 |
|
|
l=calcul_dist_noeud_noeud(noeud10,noeud8)+calcul_dist_noeud_noeud(noeud8,noeud3);
|
426 |
|
|
ec=ec+l;
|
427 |
|
|
nbr++;
|
428 |
|
|
l=calcul_dist_noeud_noeud(noeud10,noeud9)+calcul_dist_noeud_noeud(noeud9,noeud5);
|
429 |
|
|
ec=ec+l;
|
430 |
|
|
nbr++;
|
431 |
|
|
}
|
432 |
|
|
|
433 |
|
|
}
|
434 |
|
|
}
|
435 |
|
|
|
436 |
|
|
//---------------------------------------------------------------------------
|
437 |
|
|
|
438 |
|
|
double __fastcall Tfimcarte::calcul_dist_noeud_noeud(FEM_NOEUD* noeud1,FEM_NOEUD* noeud2)
|
439 |
|
|
{
|
440 |
|
|
double *xyz1=noeud1->get_coord();
|
441 |
|
|
double *xyz2=noeud2->get_coord();
|
442 |
|
|
OT_VECTEUR_3D vec(xyz1,xyz2);
|
443 |
|
|
return vec.get_longueur();
|
444 |
|
|
}
|
445 |
|
|
|
446 |
|
|
//---------------------------------------------------------------------------
|
447 |
|
|
void __fastcall Tfimcarte::Button4Click(TObject *Sender)
|
448 |
|
|
{
|
449 |
|
|
vector<celluleaff*> lst_cellule;
|
450 |
|
|
FILE *in=fopen(Edit1->Text.c_str(),"rt");
|
451 |
|
|
char mess[400];
|
452 |
|
|
fgets(mess,400,in);
|
453 |
bournival |
34 |
if (!(mess[0]=='0' ||mess[0]=='1' ||mess[0]=='2'||mess[0]=='3'||mess[0]=='4'||mess[0]=='5'||mess[0]=='6'||mess[0]=='7'||mess[0]=='8'||mess[0]=='9'))
|
454 |
|
|
{
|
455 |
|
|
mess[0]='0';
|
456 |
|
|
mess[1]='0';
|
457 |
|
|
mess[2]='0';
|
458 |
|
|
}
|
459 |
|
5 |
int nb_renseignement;
|
460 |
|
|
sscanf(mess,"%d",&nb_renseignement);
|
461 |
|
|
char nomfichier[500];
|
462 |
|
|
strcpy(nomfichier,Caption.c_str());
|
463 |
|
|
nomfichier[strlen(nomfichier)-6]=0;
|
464 |
|
|
int nb_sol=gest->get_nb_mg_solution()+gest->get_nb_fem_solution();
|
465 |
|
|
sprintf(mess,".sol%d",nb_sol+1);
|
466 |
|
|
strcat(nomfichier,mess);
|
467 |
|
|
MG_MAILLAGE* mgmai=gest->get_mg_maillage(ComboBox1->ItemIndex);
|
468 |
|
|
if (mgmai==NULL) return;
|
469 |
|
|
AnsiString InputString = InputBox("Entrez le nom de la solution ?", "Information", "nom");
|
470 |
|
|
char messtmp[1000];
|
471 |
|
|
strcpy(messtmp,InputString.c_str());
|
472 |
|
|
string nomsol=messtmp;
|
473 |
|
|
int nb_noeud=mgmai->get_nb_mg_noeud();
|
474 |
|
|
MG_SOLUTION* mgsol=new MG_SOLUTION(mgmai,nb_renseignement,nomfichier,nb_noeud,nomsol);
|
475 |
|
|
gest->ajouter_mg_solution(mgsol);
|
476 |
|
|
for (int i=0;i<nb_renseignement;i++)
|
477 |
|
|
{
|
478 |
|
|
fgets(mess,400,in);
|
479 |
|
|
mess[strlen(mess)-1]=0;
|
480 |
|
|
mgsol->change_legende(i,mess);
|
481 |
|
|
}
|
482 |
|
|
if (in!=NULL)
|
483 |
|
|
{
|
484 |
|
|
while (feof(in)==0)
|
485 |
|
|
{
|
486 |
|
|
char mess[400];
|
487 |
|
|
celluleaff* cell=new celluleaff(nb_renseignement);
|
488 |
|
|
fgets(mess,400,in);
|
489 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt1[0]),&(cell->coordpt1[1]),&(cell->coordpt1[2]));
|
490 |
|
|
char *p=strchr(mess,' ')+1;
|
491 |
|
|
p=strchr(p,' ')+1;
|
492 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
493 |
|
|
{
|
494 |
|
|
double val;
|
495 |
|
|
p=strchr(p,' ')+1;
|
496 |
|
|
sscanf(p,"%lf",&val);
|
497 |
|
|
cell->change_valeur(l,0,val);
|
498 |
|
|
}
|
499 |
|
|
fgets(mess,400,in);
|
500 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt2[0]),&(cell->coordpt2[1]),&(cell->coordpt2[2]));
|
501 |
|
|
p=strchr(mess,' ')+1;
|
502 |
|
|
p=strchr(p,' ')+1;
|
503 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
504 |
|
|
{
|
505 |
|
|
double val;
|
506 |
|
|
p=strchr(p,' ')+1;
|
507 |
|
|
sscanf(p,"%lf",&val);
|
508 |
|
|
cell->change_valeur(l,1,val);
|
509 |
|
|
}
|
510 |
|
|
fgets(mess,400,in);
|
511 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt3[0]),&(cell->coordpt3[1]),&(cell->coordpt3[2]));
|
512 |
|
|
p=strchr(mess,' ')+1;
|
513 |
|
|
p=strchr(p,' ')+1;
|
514 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
515 |
|
|
{
|
516 |
|
|
double val;
|
517 |
|
|
p=strchr(p,' ')+1;
|
518 |
|
|
sscanf(p,"%lf",&val);
|
519 |
|
|
cell->change_valeur(l,2,val);
|
520 |
|
|
}
|
521 |
|
|
fgets(mess,400,in);
|
522 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt4[0]),&(cell->coordpt4[1]),&(cell->coordpt4[2]));
|
523 |
|
|
p=strchr(mess,' ')+1;
|
524 |
|
|
p=strchr(p,' ')+1;
|
525 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
526 |
|
|
{
|
527 |
|
|
double val;
|
528 |
|
|
p=strchr(p,' ')+1;
|
529 |
|
|
sscanf(p,"%lf",&val);
|
530 |
|
|
cell->change_valeur(l,3,val);
|
531 |
|
|
}
|
532 |
|
|
fgets(mess,400,in);
|
533 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt5[0]),&(cell->coordpt5[1]),&(cell->coordpt5[2]));
|
534 |
|
|
p=strchr(mess,' ')+1;
|
535 |
|
|
p=strchr(p,' ')+1;
|
536 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
537 |
|
|
{
|
538 |
|
|
double val;
|
539 |
|
|
p=strchr(p,' ')+1;
|
540 |
|
|
sscanf(p,"%lf",&val);
|
541 |
|
|
cell->change_valeur(l,4,val);
|
542 |
|
|
}
|
543 |
|
|
fgets(mess,400,in);
|
544 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt6[0]),&(cell->coordpt6[1]),&(cell->coordpt6[2]));
|
545 |
|
|
p=strchr(mess,' ')+1;
|
546 |
|
|
p=strchr(p,' ')+1;
|
547 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
548 |
|
|
{
|
549 |
|
|
double val;
|
550 |
|
|
p=strchr(p,' ')+1;
|
551 |
|
|
sscanf(p,"%lf",&val);
|
552 |
|
|
cell->change_valeur(l,5,val);
|
553 |
|
|
}
|
554 |
|
|
fgets(mess,400,in);
|
555 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt7[0]),&(cell->coordpt7[1]),&(cell->coordpt7[2]));
|
556 |
|
|
p=strchr(mess,' ')+1;
|
557 |
|
|
p=strchr(p,' ')+1;
|
558 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
559 |
|
|
{
|
560 |
|
|
double val;
|
561 |
|
|
p=strchr(p,' ')+1;
|
562 |
|
|
sscanf(p,"%lf",&val);
|
563 |
|
|
cell->change_valeur(l,6,val);
|
564 |
|
|
}
|
565 |
|
|
fgets(mess,400,in);
|
566 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt8[0]),&(cell->coordpt8[1]),&(cell->coordpt8[2]));
|
567 |
|
|
p=strchr(mess,' ')+1;
|
568 |
|
|
p=strchr(p,' ')+1;
|
569 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
570 |
|
|
{
|
571 |
|
|
double val;
|
572 |
|
|
p=strchr(p,' ')+1;
|
573 |
|
|
sscanf(p,"%lf",&val);
|
574 |
|
|
cell->change_valeur(l,7,val);
|
575 |
|
|
}
|
576 |
|
|
lst_cellule.insert(lst_cellule.end(),cell);
|
577 |
|
|
}
|
578 |
|
|
double xmin,ymin,zmin,xmax,ymax,zmax;
|
579 |
|
|
for (int i=0;i<nb_noeud;i++)
|
580 |
|
|
{
|
581 |
|
|
double *xyz=mgmai->get_mg_noeud(i)->get_coord();
|
582 |
|
|
if (i==0)
|
583 |
|
|
{
|
584 |
|
|
xmin=xyz[0];
|
585 |
|
|
xmax=xyz[0];
|
586 |
|
|
ymin=xyz[1];
|
587 |
|
|
ymax=xyz[1];
|
588 |
|
|
zmin=xyz[2];
|
589 |
|
|
zmax=xyz[2];
|
590 |
|
|
}
|
591 |
|
|
else
|
592 |
|
|
{
|
593 |
|
|
if (xyz[0]<xmin) xmin=xyz[0];
|
594 |
|
|
if (xyz[0]>xmax) xmax=xyz[0];
|
595 |
|
|
if (xyz[1]<ymin) ymin=xyz[1];
|
596 |
|
|
if (xyz[1]>ymax) ymax=xyz[1];
|
597 |
|
|
if (xyz[2]<zmin) zmin=xyz[2];
|
598 |
|
|
if (xyz[2]>zmax) zmax=xyz[2];
|
599 |
|
|
}
|
600 |
|
|
}
|
601 |
|
|
double dx=(xmax-xmin)*0.05;
|
602 |
|
|
double dy=(ymax-ymin)*0.05;
|
603 |
|
|
double dz=(zmax-zmin)*0.05;
|
604 |
|
|
xmin=xmin-dx;
|
605 |
|
|
ymin=ymin-dy;
|
606 |
|
|
zmin=zmin-dz;
|
607 |
|
|
xmax=xmax+dx;
|
608 |
|
|
ymax=ymax+dy;
|
609 |
|
|
zmax=zmax+dz;
|
610 |
|
|
TPL_GRILLE<MG_NOEUD*> grille;
|
611 |
|
|
int pas=(int)(pow(nb_noeud,0.33333333333333)+1);
|
612 |
|
|
grille.initialiser(xmin,ymin,zmin,xmax,ymax,zmax,pas,pas,pas);
|
613 |
|
|
for (int i=0;i<nb_noeud;i++)
|
614 |
|
|
{
|
615 |
|
|
MG_NOEUD* noeud=mgmai->get_mg_noeud(i);
|
616 |
|
|
noeud->change_nouveau_numero(i);
|
617 |
|
|
grille.inserer(noeud);
|
618 |
|
|
}
|
619 |
|
|
int nb_cell=lst_cellule.size();
|
620 |
|
|
for (int i=0;i<nb_cell;i++)
|
621 |
|
|
{
|
622 |
|
|
celluleaff* cell=lst_cellule[i];
|
623 |
|
|
double *xyz1=cell->coordpt1;
|
624 |
|
|
double *xyz7=cell->coordpt7;
|
625 |
|
|
BOITE_3D boite1(xyz1[0],xyz1[1],xyz1[2],xyz7[0],xyz7[1],xyz7[2]);
|
626 |
|
|
TPL_MAP_ENTITE<MG_NOEUD*> lst_noeud;
|
627 |
|
|
grille.rechercher(boite1.get_xcentre(),boite1.get_ycentre(),boite1.get_zcentre(),boite1.get_rayon(),lst_noeud);
|
628 |
|
|
int nb_noeud_trouve=lst_noeud.get_nb();
|
629 |
|
|
for (int j=0;j<nb_noeud_trouve;j++)
|
630 |
|
|
{
|
631 |
|
|
MG_NOEUD* mgnoeud=lst_noeud.get(j);
|
632 |
|
|
if (mgnoeud->get_boite_3D()*boite1)
|
633 |
|
|
{
|
634 |
|
|
double xsi=-1+2*(mgnoeud->get_x()-boite1.get_xmin())/(boite1.get_xmax()-boite1.get_xmin());
|
635 |
|
|
double eta=-1+2*(mgnoeud->get_y()-boite1.get_ymin())/(boite1.get_ymax()-boite1.get_ymin());
|
636 |
|
|
double psi=-1+2*(mgnoeud->get_z()-boite1.get_zmin())/(boite1.get_zmax()-boite1.get_zmin());
|
637 |
|
|
double a1=1+xsi;
|
638 |
|
|
double b1=1+eta;
|
639 |
|
|
double c1=1+psi;
|
640 |
|
|
double a2=1-xsi;
|
641 |
|
|
double b2=1-eta;
|
642 |
|
|
double c2=1-psi;
|
643 |
|
|
double N1=a2*b2*c2;
|
644 |
|
|
double N3=a1*b1*c2;
|
645 |
|
|
double N2=a1*b2*c2;
|
646 |
|
|
double N4=a2*b1*c2;
|
647 |
|
|
double N5=a2*b2*c1;
|
648 |
|
|
double N6=a1*b2*c1;
|
649 |
|
|
double N7=a1*b1*c1;
|
650 |
|
|
double N8=a2*b1*c1;
|
651 |
|
|
for (int k=0;k<nb_renseignement;k++)
|
652 |
|
|
{
|
653 |
|
|
double valeur1=cell->get_valeur(k,0);
|
654 |
|
|
double valeur2=cell->get_valeur(k,1);
|
655 |
|
|
double valeur3=cell->get_valeur(k,2);
|
656 |
|
|
double valeur4=cell->get_valeur(k,3);
|
657 |
|
|
double valeur5=cell->get_valeur(k,4);
|
658 |
|
|
double valeur6=cell->get_valeur(k,5);
|
659 |
|
|
double valeur7=cell->get_valeur(k,6);
|
660 |
|
|
double valeur8=cell->get_valeur(k,7);
|
661 |
|
|
double res=N1*valeur1+N2*valeur2+N3*valeur3+N4*valeur4+N5*valeur5+N6*valeur6+N7*valeur7+N8*valeur8;
|
662 |
|
|
res=res/8.;
|
663 |
|
|
mgsol->ecrire(mgnoeud->get_nouveau_numero(),k,res);
|
664 |
|
|
}
|
665 |
|
|
}
|
666 |
|
|
|
667 |
|
|
}
|
668 |
|
|
}
|
669 |
|
|
|
670 |
|
|
fclose(in);
|
671 |
|
|
gest->enregistrer(Caption.c_str());
|
672 |
|
|
return;
|
673 |
|
|
|
674 |
|
|
}
|
675 |
|
|
MessageBox(Handle,"Fichier non valide","Erreur",MB_OK);
|
676 |
|
|
}
|
677 |
|
|
//---------------------------------------------------------------------------
|
678 |
|
|
|
679 |
|
|
|
680 |
|
|
void __fastcall Tfimcarte::Button6Click(TObject *Sender)
|
681 |
|
|
{
|
682 |
|
|
vector<celluleaff*> lst_cellule;
|
683 |
|
|
FILE *in=fopen(Edit2->Text.c_str(),"rt");
|
684 |
|
|
char mess[400];
|
685 |
|
|
fgets(mess,400,in);
|
686 |
|
|
int nb_renseignement;
|
687 |
|
|
sscanf(mess,"%d",&nb_renseignement);
|
688 |
|
|
char nomfichier[500];
|
689 |
|
|
strcpy(nomfichier,Caption.c_str());
|
690 |
|
|
nomfichier[strlen(nomfichier)-6]=0;
|
691 |
|
|
int nb_sol=gest->get_nb_mg_solution()+gest->get_nb_fem_solution();
|
692 |
|
|
sprintf(mess,".sol%d",nb_sol+1);
|
693 |
|
|
strcat(nomfichier,mess);
|
694 |
|
|
FEM_MAILLAGE* mai=gest->get_fem_maillage(ComboBox2->ItemIndex);
|
695 |
|
|
if (mai==NULL) return;
|
696 |
|
|
AnsiString InputString = InputBox("Entrez le nom de la solution ?", "Information", "nom");
|
697 |
|
|
char messtmp[1000];
|
698 |
|
|
strcpy(messtmp,InputString.c_str());
|
699 |
|
|
string nomsol=messtmp;
|
700 |
|
|
int nb_noeud=mai->get_nb_fem_noeud();
|
701 |
|
|
FEM_SOLUTION* sol=new FEM_SOLUTION(mai,nb_renseignement,nomfichier,nb_noeud,nomsol);
|
702 |
|
|
gest->ajouter_fem_solution(sol);
|
703 |
|
|
for (int i=0;i<nb_renseignement;i++)
|
704 |
|
|
{
|
705 |
|
|
fgets(mess,400,in);
|
706 |
|
|
mess[strlen(mess)-1]=0;
|
707 |
|
|
sol->change_legende(i,mess);
|
708 |
|
|
}
|
709 |
|
|
if (in!=NULL)
|
710 |
|
|
{
|
711 |
|
|
while (feof(in)==0)
|
712 |
|
|
{
|
713 |
|
|
char mess[400];
|
714 |
|
|
celluleaff* cell=new celluleaff(nb_renseignement);
|
715 |
|
|
fgets(mess,400,in);
|
716 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt1[0]),&(cell->coordpt1[1]),&(cell->coordpt1[2]));
|
717 |
|
|
char *p=strchr(mess,' ')+1;
|
718 |
|
|
p=strchr(p,' ')+1;
|
719 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
720 |
|
|
{
|
721 |
|
|
double val;
|
722 |
|
|
p=strchr(p,' ')+1;
|
723 |
|
|
sscanf(p,"%lf",&val);
|
724 |
|
|
cell->change_valeur(l,0,val);
|
725 |
|
|
}
|
726 |
|
|
fgets(mess,400,in);
|
727 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt2[0]),&(cell->coordpt2[1]),&(cell->coordpt2[2]));
|
728 |
|
|
p=strchr(mess,' ')+1;
|
729 |
|
|
p=strchr(p,' ')+1;
|
730 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
731 |
|
|
{
|
732 |
|
|
double val;
|
733 |
|
|
p=strchr(p,' ')+1;
|
734 |
|
|
sscanf(p,"%lf",&val);
|
735 |
|
|
cell->change_valeur(l,1,val);
|
736 |
|
|
}
|
737 |
|
|
fgets(mess,400,in);
|
738 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt3[0]),&(cell->coordpt3[1]),&(cell->coordpt3[2]));
|
739 |
|
|
p=strchr(mess,' ')+1;
|
740 |
|
|
p=strchr(p,' ')+1;
|
741 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
742 |
|
|
{
|
743 |
|
|
double val;
|
744 |
|
|
p=strchr(p,' ')+1;
|
745 |
|
|
sscanf(p,"%lf",&val);
|
746 |
|
|
cell->change_valeur(l,2,val);
|
747 |
|
|
}
|
748 |
|
|
fgets(mess,400,in);
|
749 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt4[0]),&(cell->coordpt4[1]),&(cell->coordpt4[2]));
|
750 |
|
|
p=strchr(mess,' ')+1;
|
751 |
|
|
p=strchr(p,' ')+1;
|
752 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
753 |
|
|
{
|
754 |
|
|
double val;
|
755 |
|
|
p=strchr(p,' ')+1;
|
756 |
|
|
sscanf(p,"%lf",&val);
|
757 |
|
|
cell->change_valeur(l,3,val);
|
758 |
|
|
}
|
759 |
|
|
fgets(mess,400,in);
|
760 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt5[0]),&(cell->coordpt5[1]),&(cell->coordpt5[2]));
|
761 |
|
|
p=strchr(mess,' ')+1;
|
762 |
|
|
p=strchr(p,' ')+1;
|
763 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
764 |
|
|
{
|
765 |
|
|
double val;
|
766 |
|
|
p=strchr(p,' ')+1;
|
767 |
|
|
sscanf(p,"%lf",&val);
|
768 |
|
|
cell->change_valeur(l,4,val);
|
769 |
|
|
}
|
770 |
|
|
fgets(mess,400,in);
|
771 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt6[0]),&(cell->coordpt6[1]),&(cell->coordpt6[2]));
|
772 |
|
|
p=strchr(mess,' ')+1;
|
773 |
|
|
p=strchr(p,' ')+1;
|
774 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
775 |
|
|
{
|
776 |
|
|
double val;
|
777 |
|
|
p=strchr(p,' ')+1;
|
778 |
|
|
sscanf(p,"%lf",&val);
|
779 |
|
|
cell->change_valeur(l,5,val);
|
780 |
|
|
}
|
781 |
|
|
fgets(mess,400,in);
|
782 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt7[0]),&(cell->coordpt7[1]),&(cell->coordpt7[2]));
|
783 |
|
|
p=strchr(mess,' ')+1;
|
784 |
|
|
p=strchr(p,' ')+1;
|
785 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
786 |
|
|
{
|
787 |
|
|
double val;
|
788 |
|
|
p=strchr(p,' ')+1;
|
789 |
|
|
sscanf(p,"%lf",&val);
|
790 |
|
|
cell->change_valeur(l,6,val);
|
791 |
|
|
}
|
792 |
|
|
fgets(mess,400,in);
|
793 |
|
|
sscanf(mess,"%lf %lf %lf",&(cell->coordpt8[0]),&(cell->coordpt8[1]),&(cell->coordpt8[2]));
|
794 |
|
|
p=strchr(mess,' ')+1;
|
795 |
|
|
p=strchr(p,' ')+1;
|
796 |
|
|
for (int l=0;l<nb_renseignement;l++)
|
797 |
|
|
{
|
798 |
|
|
double val;
|
799 |
|
|
p=strchr(p,' ')+1;
|
800 |
|
|
sscanf(p,"%lf",&val);
|
801 |
|
|
cell->change_valeur(l,7,val);
|
802 |
|
|
}
|
803 |
|
|
lst_cellule.insert(lst_cellule.end(),cell);
|
804 |
|
|
}
|
805 |
|
|
double xmin,ymin,zmin,xmax,ymax,zmax;
|
806 |
|
|
for (int i=0;i<nb_noeud;i++)
|
807 |
|
|
{
|
808 |
|
|
double *xyz=mai->get_fem_noeud(i)->get_coord();
|
809 |
|
|
if (i==0)
|
810 |
|
|
{
|
811 |
|
|
xmin=xyz[0];
|
812 |
|
|
xmax=xyz[0];
|
813 |
|
|
ymin=xyz[1];
|
814 |
|
|
ymax=xyz[1];
|
815 |
|
|
zmin=xyz[2];
|
816 |
|
|
zmax=xyz[2];
|
817 |
|
|
}
|
818 |
|
|
else
|
819 |
|
|
{
|
820 |
|
|
if (xyz[0]<xmin) xmin=xyz[0];
|
821 |
|
|
if (xyz[0]>xmax) xmax=xyz[0];
|
822 |
|
|
if (xyz[1]<ymin) ymin=xyz[1];
|
823 |
|
|
if (xyz[1]>ymax) ymax=xyz[1];
|
824 |
|
|
if (xyz[2]<zmin) zmin=xyz[2];
|
825 |
|
|
if (xyz[2]>zmax) zmax=xyz[2];
|
826 |
|
|
}
|
827 |
|
|
}
|
828 |
|
|
double dx=(xmax-xmin)*0.05;
|
829 |
|
|
double dy=(ymax-ymin)*0.05;
|
830 |
|
|
double dz=(zmax-zmin)*0.05;
|
831 |
|
|
xmin=xmin-dx;
|
832 |
|
|
ymin=ymin-dy;
|
833 |
|
|
zmin=zmin-dz;
|
834 |
|
|
xmax=xmax+dx;
|
835 |
|
|
ymax=ymax+dy;
|
836 |
|
|
zmax=zmax+dz;
|
837 |
|
|
TPL_GRILLE<FEM_NOEUD*> grille;
|
838 |
|
|
int pas=(int)(pow(nb_noeud,0.33333333333333)+1);
|
839 |
|
|
grille.initialiser(xmin,ymin,zmin,xmax,ymax,zmax,pas,pas,pas);
|
840 |
|
|
for (int i=0;i<nb_noeud;i++)
|
841 |
|
|
{
|
842 |
|
|
FEM_NOEUD* noeud=mai->get_fem_noeud(i);
|
843 |
|
|
noeud->change_numero(i);
|
844 |
|
|
grille.inserer(noeud);
|
845 |
|
|
}
|
846 |
|
|
int nb_cell=lst_cellule.size();
|
847 |
|
|
for (int i=0;i<nb_cell;i++)
|
848 |
|
|
{
|
849 |
|
|
celluleaff* cell=lst_cellule[i];
|
850 |
|
|
double *xyz1=cell->coordpt1;
|
851 |
|
|
double *xyz7=cell->coordpt7;
|
852 |
|
|
BOITE_3D boite1(xyz1[0],xyz1[1],xyz1[2],xyz7[0],xyz7[1],xyz7[2]);
|
853 |
|
|
TPL_MAP_ENTITE<FEM_NOEUD*> lst_noeud;
|
854 |
|
|
grille.rechercher(boite1.get_xcentre(),boite1.get_ycentre(),boite1.get_zcentre(),boite1.get_rayon(),lst_noeud);
|
855 |
|
|
int nb_noeud_trouve=lst_noeud.get_nb();
|
856 |
|
|
for (int j=0;j<nb_noeud_trouve;j++)
|
857 |
|
|
{
|
858 |
|
|
FEM_NOEUD* noeud=lst_noeud.get(j);
|
859 |
|
|
if (noeud->get_boite_3D()*boite1)
|
860 |
|
|
{
|
861 |
|
|
double xsi=-1+2*(noeud->get_x()-boite1.get_xmin())/(boite1.get_xmax()-boite1.get_xmin());
|
862 |
|
|
double eta=-1+2*(noeud->get_y()-boite1.get_ymin())/(boite1.get_ymax()-boite1.get_ymin());
|
863 |
|
|
double psi=-1+2*(noeud->get_z()-boite1.get_zmin())/(boite1.get_zmax()-boite1.get_zmin());
|
864 |
|
|
double a1=1+xsi;
|
865 |
|
|
double b1=1+eta;
|
866 |
|
|
double c1=1+psi;
|
867 |
|
|
double a2=1-xsi;
|
868 |
|
|
double b2=1-eta;
|
869 |
|
|
double c2=1-psi;
|
870 |
|
|
double N1=a2*b2*c2;
|
871 |
|
|
double N3=a1*b1*c2;
|
872 |
|
|
double N2=a1*b2*c2;
|
873 |
|
|
double N4=a2*b1*c2;
|
874 |
|
|
double N5=a2*b2*c1;
|
875 |
|
|
double N6=a1*b2*c1;
|
876 |
|
|
double N7=a1*b1*c1;
|
877 |
|
|
double N8=a2*b1*c1;
|
878 |
|
|
for (int k=0;k<nb_renseignement;k++)
|
879 |
|
|
{
|
880 |
|
|
double valeur1=cell->get_valeur(k,0);
|
881 |
|
|
double valeur2=cell->get_valeur(k,1);
|
882 |
|
|
double valeur3=cell->get_valeur(k,2);
|
883 |
|
|
double valeur4=cell->get_valeur(k,3);
|
884 |
|
|
double valeur5=cell->get_valeur(k,4);
|
885 |
|
|
double valeur6=cell->get_valeur(k,5);
|
886 |
|
|
double valeur7=cell->get_valeur(k,6);
|
887 |
|
|
double valeur8=cell->get_valeur(k,7);
|
888 |
|
|
double res=N1*valeur1+N2*valeur2+N3*valeur3+N4*valeur4+N5*valeur5+N6*valeur6+N7*valeur7+N8*valeur8;
|
889 |
|
|
res=res/8.;
|
890 |
|
|
sol->ecrire(noeud->get_numero(),k,res);
|
891 |
|
|
}
|
892 |
|
|
}
|
893 |
|
|
|
894 |
|
|
}
|
895 |
|
|
}
|
896 |
|
|
|
897 |
|
|
fclose(in);
|
898 |
|
|
gest->enregistrer(Caption.c_str());
|
899 |
|
|
return;
|
900 |
|
|
|
901 |
|
|
}
|
902 |
|
|
MessageBox(Handle,"Fichier non valide","Erreur",MB_OK);
|
903 |
|
|
}
|
904 |
|
|
//---------------------------------------------------------------------------
|
905 |
|
|
|