1 |
foucault |
27 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// mailleur2d.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H23
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
foucault |
176 |
#include <vector>
|
25 |
|
|
using namespace std; |
26 |
foucault |
27 |
#include "gestionversion.h"
|
27 |
|
|
#include "CAD4FE_mailleur2d.h"
|
28 |
|
|
#include "ot_mathematique.h"
|
29 |
|
|
//#include "message.h"
|
30 |
|
|
//#include "affiche.h"
|
31 |
|
|
#include <fstream>
|
32 |
|
|
#include <math.h>
|
33 |
|
|
#include <time.h>
|
34 |
|
|
|
35 |
foucault |
64 |
#include <CAD4FE_MCEdge.h>
|
36 |
|
|
#include <CAD4FE_PolyCurve.h>
|
37 |
foucault |
27 |
#include <CAD4FE_MCVertex.h>
|
38 |
|
|
#include "CAD4FE_geometric_tools.h"
|
39 |
|
|
#include "CAD4FE_InventorText_MG_MAILLAGE.h"
|
40 |
|
|
#include "CAD4FE_InventorText_MCSegment.h"
|
41 |
|
|
#include "CAD4FE_OptimizeEdgeSwap.h"
|
42 |
|
|
|
43 |
|
|
using namespace CAD4FE;
|
44 |
|
|
|
45 |
|
|
MAILLEUR2D::MAILLEUR2D(MG_MAILLAGE* mgmai,MG_GEOMETRIE *mggeo,MCFace* __mcFace,FCT_TAILLE* fct_taille):MAILLEUR(),mg_maillage(mgmai),mg_geometrie(mggeo),_mcFace(__mcFace),metrique(fct_taille)
|
46 |
|
|
{
|
47 |
|
|
strcpy(filenameNbTriangles,getenv("TEMP"));
|
48 |
|
|
strcat(filenameNbTriangles,"CAD4FE_mailleur2d.txt");
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
MAILLEUR2D::~MAILLEUR2D()
|
54 |
|
|
{
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
void MAILLEUR2D::maille(void)
|
61 |
|
|
{
|
62 |
|
|
if (_mcFace!=NULL) maille(_mcFace);
|
63 |
|
|
else
|
64 |
|
|
{
|
65 |
|
|
// Il faudrait mailler les MC Face de la géométrie :
|
66 |
|
|
// A faire : une fonction qui parcours les MCFace de la géométrie
|
67 |
|
|
/* int nb_face=mg_geometrie->get_nb_mg_face();
|
68 |
|
|
for (int i=0;i<nb_face;i++)
|
69 |
|
|
{
|
70 |
|
|
MG_FACE* mgface=mg_geometrie->get_mg_face(i);
|
71 |
|
|
maille(mgface);
|
72 |
|
|
} */
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
void MAILLEUR2D::maille(MCFace * __mcFace)
|
77 |
|
|
{
|
78 |
|
|
creation_metrique=0;
|
79 |
|
|
lst_tri_qual.clear();
|
80 |
|
|
//afficheur << MAILLAGEFACE << mgface->get_id() << endaff;
|
81 |
|
|
initialise_frontiere(__mcFace);
|
82 |
|
|
cree_grille(__mcFace);
|
83 |
|
|
initialise_front(__mcFace);
|
84 |
|
|
|
85 |
|
|
if (metrique==NULL)
|
86 |
|
|
{
|
87 |
|
|
printf("Mailleur2D::Maille --> Abandon: \nLa fonction carte de taille doit être spécifiée !\n");
|
88 |
|
|
return;
|
89 |
|
|
}
|
90 |
foucault |
64 |
progresse_front(__mcFace);
|
91 |
|
|
export_ivanim_all_faces();
|
92 |
foucault |
27 |
if (debug){
|
93 |
|
|
char filename1[5000];
|
94 |
|
|
strcpy(filename1,getenv("TEMP"));
|
95 |
|
|
strcat(filename1,"\\void_2D.mai");
|
96 |
|
|
ofstream o4(filename1,ios::out|ios::trunc);
|
97 |
|
|
o4.precision(16);
|
98 |
|
|
o4.setf(ios::showpoint);
|
99 |
|
|
mg_maillage->enregistrer_sous_mesh_2D(o4);
|
100 |
|
|
|
101 |
|
|
std::ofstream file;
|
102 |
|
|
char filename2[5000];
|
103 |
|
|
strcpy(filename2,getenv("TEMP"));
|
104 |
|
|
strcat(filename2,"\\CAD4FE_Mesher.iv");
|
105 |
|
|
file.open(filename2);
|
106 |
|
|
CAD4FE::InventorText_MG_MAILLAGE ivTextRefTess (mg_maillage);
|
107 |
|
|
ivTextRefTess.ShowFaceSegments = true;
|
108 |
|
|
ivTextRefTess.ShowSegmentId = false;
|
109 |
|
|
ivTextRefTess.ShowTriangleId = false;
|
110 |
|
|
ivTextRefTess.ShowNodeId = false;
|
111 |
|
|
ivTextRefTess.InverseTriangleNormals = true;
|
112 |
|
|
ivTextRefTess.TriangleColor=1;
|
113 |
|
|
file << ivTextRefTess.GetText();
|
114 |
|
|
file << "\n}\n";
|
115 |
|
|
file.close();
|
116 |
|
|
}
|
117 |
|
|
if ( 0 ) |
118 |
|
|
{ |
119 |
|
|
std::ofstream file; |
120 |
|
|
char filename2[5000];
|
121 |
|
|
strcpy(filename2,getenv("TEMP"));
|
122 |
|
|
strcat(filename2,"\\CAD4FE_Mesher_MCSegments.iv"); |
123 |
|
|
file.open(filename2);
|
124 |
|
|
InventorText_MG_MAILLAGE meshIvText (mg_maillage);
|
125 |
|
|
meshIvText.ShowFaceSegments = true;
|
126 |
|
|
meshIvText.ShowSegmentId = true;
|
127 |
|
|
meshIvText.ShowTriangleId = true;
|
128 |
|
|
meshIvText.ShowNodeId = true;
|
129 |
|
|
meshIvText.InverseTriangleNormals = true;
|
130 |
|
|
meshIvText.TriangleColor=1;
|
131 |
|
|
file<<meshIvText.GetText(); |
132 |
|
|
|
133 |
|
|
file << "DrawStyle {\nstyle LINES\nlineWidth 2\npointSize 3\n}\n"; |
134 |
|
|
LISTE_MG_SEGMENT::iterator itSegment; |
135 |
|
|
for (MG_SEGMENT * seg = mg_maillage->get_premier_segment(itSegment); seg; seg = mg_maillage->get_suivant_segment(itSegment)) |
136 |
|
|
{ |
137 |
|
|
if (seg->get_lien_topologie()->get_dimension() == 1) |
138 |
|
|
file << "BaseColor { \n rgb 0.0 0.0 0.9\n }\n"; |
139 |
|
|
if (seg->get_lien_topologie()->get_dimension() == 2) |
140 |
|
|
file << "BaseColor { \n rgb 0.0 0.0 0.0\n }\n"; |
141 |
|
|
MCSegment * mcSeg = (MCSegment *) seg; |
142 |
|
|
InventorText_MCSegment mcSegTxt (mcSeg); |
143 |
|
|
file << mcSegTxt.GetText(); |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
file << "\n}\n"; |
147 |
|
|
file.close(); |
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
optimise_bascule_segment(__mcFace);
|
151 |
|
|
optimise(__mcFace);
|
152 |
|
|
|
153 |
|
|
{
|
154 |
|
|
std::ofstream file(filenameNbTriangles);
|
155 |
|
|
file.clear();
|
156 |
|
|
file.flush();
|
157 |
|
|
file.close();
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
if (creation_metrique==1)
|
162 |
|
|
{
|
163 |
|
|
delete metrique;
|
164 |
|
|
metrique=NULL;
|
165 |
|
|
}
|
166 |
|
|
delete grille_de_segment;
|
167 |
|
|
delete grille_de_frontiere;
|
168 |
|
|
delete grille_de_front;
|
169 |
|
|
segment_frontiere.vide();
|
170 |
|
|
noeud_frontiere.vide();
|
171 |
|
|
//ofstream o3("test_2D.mai",ios::out|ios::trunc);
|
172 |
|
|
//o3.precision(16);
|
173 |
|
|
//o3.setf(ios::showpoint);
|
174 |
|
|
//mg_maillage->enregistrer_sous_mesh_2D(o3);
|
175 |
|
|
}
|
176 |
|
|
|
177 |
foucault |
64 |
void MAILLEUR2D::export_ivanim()
|
178 |
|
|
{
|
179 |
|
|
MG_MAILLAGE * _mesh = mg_maillage;
|
180 |
foucault |
27 |
|
181 |
foucault |
64 |
std::string filename = "c:\\gilles\\out_";
|
182 |
|
|
filename += std::string(_mcFace->get_idoriginal())+".ivanim";
|
183 |
foucault |
27 |
|
184 |
foucault |
64 |
std::ofstream out(filename.c_str()); |
185 |
|
|
float sleepTime = .1; |
186 |
|
|
|
187 |
|
|
out << "sleepTime " << sleepTime<<" \n"; |
188 |
|
|
out << "groupTriang 5 \n"; |
189 |
|
|
|
190 |
|
|
std::set <MG_ARETE*> lst_mg_edges; |
191 |
|
|
std::set <MG_SOMMET*> lst_mg_vertices; |
192 |
|
|
unsigned nb_loop = _mcFace->get_nb_mg_boucle();
|
193 |
|
|
for (unsigned it_loop = 0; it_loop < nb_loop; it_loop++)
|
194 |
|
|
{
|
195 |
|
|
MG_BOUCLE * loop = _mcFace->get_mg_boucle(it_loop);
|
196 |
|
|
unsigned nb_edge = loop->get_nb_mg_coarete();
|
197 |
foucault |
27 |
|
198 |
foucault |
64 |
for (unsigned it_edge = 0; it_edge < nb_edge; it_edge++)
|
199 |
|
|
{
|
200 |
|
|
MG_ARETE * edge = (MG_ARETE*)loop->get_mg_coarete(it_edge)->get_arete();
|
201 |
|
|
lst_mg_edges.insert(edge);
|
202 |
foucault |
27 |
|
203 |
foucault |
64 |
lst_mg_vertices.insert ((MG_SOMMET*)edge->get_cosommet1()->get_sommet());
|
204 |
|
|
lst_mg_vertices.insert ((MG_SOMMET*)edge->get_cosommet2()->get_sommet());
|
205 |
|
|
}
|
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
LISTE_MG_TRIANGLE::iterator itTriang; |
209 |
|
|
std::set <MG_NOEUD*>lst_mg_noeud; |
210 |
|
|
for (MG_TRIANGLE * triangle = _mesh->get_premier_triangle(itTriang); triangle; triangle = _mesh->get_suivant_triangle(itTriang)) |
211 |
|
|
{ |
212 |
|
|
if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2 |
213 |
|
|
|| (MG_FACE*)triangle->get_lien_topologie() != _mcFace) |
214 |
|
|
continue; |
215 |
|
|
|
216 |
|
|
MG_NOEUD * nos[3]={triangle->get_noeud1(),triangle->get_noeud2(),triangle->get_noeud3()}; |
217 |
|
|
for (int i=0; i<3; i++) |
218 |
|
|
{ |
219 |
|
|
MG_NOEUD * no = nos[i]; |
220 |
|
|
if (lst_mg_noeud.find(no) == lst_mg_noeud.end()) |
221 |
|
|
{ |
222 |
|
|
lst_mg_noeud.insert(no); |
223 |
|
|
out << "add coord " << no->get_id() ; |
224 |
|
|
out << " " << no->get_x(); |
225 |
|
|
out << " " << no->get_y() ; |
226 |
|
|
out << " " << no->get_z() << " \n"; |
227 |
|
|
} |
228 |
|
|
} |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
LISTE_MG_NOEUD::iterator itNo; |
232 |
|
|
int i=0; |
233 |
|
|
for (MG_NOEUD * no = _mesh->get_premier_noeud(itNo); no; no=_mesh->get_suivant_noeud(itNo)) |
234 |
|
|
{ |
235 |
|
|
if (lst_mg_noeud.find(no) == lst_mg_noeud.end()) |
236 |
|
|
{ |
237 |
|
|
if (no->get_lien_topologie() != NULL && no->get_lien_topologie()->get_dimension() == 0 |
238 |
|
|
&& lst_mg_vertices.find((MG_SOMMET*)no->get_lien_topologie()) != lst_mg_vertices.end()) |
239 |
|
|
out << "add node " << no->get_id()<<" \n"; |
240 |
|
|
} |
241 |
|
|
} |
242 |
|
|
|
243 |
|
|
|
244 |
|
|
LISTE_MG_SEGMENT::iterator itSegment; |
245 |
|
|
for (MG_SEGMENT * seg = _mesh->get_premier_segment(itSegment); seg; seg = _mesh->get_suivant_segment(itSegment)) |
246 |
|
|
{ |
247 |
|
|
if (seg->get_lien_topologie() == NULL || seg->get_lien_topologie()->get_dimension() != 1 || |
248 |
|
|
lst_mg_edges.find((MG_ARETE*)seg->get_lien_topologie()) == lst_mg_edges.end()) |
249 |
|
|
continue; |
250 |
|
|
out << "add segment " << seg->get_id() << " "; |
251 |
|
|
out << seg->get_noeud1()->get_id() << " "; |
252 |
|
|
out << seg->get_noeud2()->get_id() << " \n"; |
253 |
|
|
} |
254 |
|
|
|
255 |
|
|
for (MG_TRIANGLE * triangle = _mesh->get_premier_triangle(itTriang); triangle; triangle = _mesh->get_suivant_triangle(itTriang)) |
256 |
|
|
{ |
257 |
|
|
if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2 |
258 |
|
|
|| (MG_FACE*)triangle->get_lien_topologie() != _mcFace) |
259 |
|
|
continue; |
260 |
|
|
out << "add triangle " << triangle->get_id() << " "; |
261 |
|
|
out << triangle->get_noeud1()->get_id() << " "; |
262 |
|
|
out << triangle->get_noeud3()->get_id() << " "; |
263 |
|
|
out << triangle->get_noeud2()->get_id() << " \n"; |
264 |
|
|
} |
265 |
|
|
/* |
266 |
|
|
|
267 |
|
|
void MAILLEUR2D::export_ivanim2() |
268 |
|
|
for (std::set <MG_ARETE*>::iterator it_mg_edges = lst_mg_edges.begin(); it_mg_edges != lst_mg_edges.end(); it_mg_edges++) |
269 |
|
|
{ |
270 |
|
|
MG_ARETE * edge = *it_mg_edges; |
271 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*> * lien_maillage = edge->get_lien_maillage(); |
272 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it; |
273 |
|
|
MG_ELEMENT_MAILLAGE* element; |
274 |
|
|
int nb = lien_maillage->get_nb(); |
275 |
|
|
int i=0; |
276 |
|
|
for (element = lien_maillage->get_premier(it); i++ < nb && element ; element = lien_maillage->get_suivant(it) ) |
277 |
|
|
{ |
278 |
|
|
MG_SEGMENT * seg = (MG_SEGMENT *)element; |
279 |
|
|
if (mg_maillage->contient(seg) == 0) continue; |
280 |
|
|
out << "add segment " << seg->get_id() << " "; |
281 |
|
|
out << seg->get_noeud1()->get_id() << " "; |
282 |
|
|
out << seg->get_noeud2()->get_id() << " \n"; |
283 |
|
|
} |
284 |
|
|
} |
285 |
|
|
|
286 |
|
|
for (std::set <MG_SOMMET*>::iterator it_mg_vertices = lst_mg_vertices.begin(); it_mg_vertices != lst_mg_vertices.end(); it_mg_vertices++) |
287 |
|
|
{ |
288 |
|
|
MG_SOMMET * vertex = *it_mg_vertices; |
289 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*> * lien_maillage = vertex->get_lien_maillage(); |
290 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it; |
291 |
|
|
MG_ELEMENT_MAILLAGE* element; |
292 |
|
|
int nb = lien_maillage->get_nb(); |
293 |
|
|
int i=0; |
294 |
|
|
for (element = lien_maillage->get_premier(it); i++ < nb && element ; element = lien_maillage->get_suivant(it) ) |
295 |
|
|
{ |
296 |
|
|
MG_NOEUD * node = (MG_NOEUD *)element; |
297 |
|
|
if (mg_maillage->contient(node) == 0) continue; |
298 |
|
|
} |
299 |
|
|
} */ |
300 |
|
|
/* |
301 |
|
|
std::map < MG_NOEUD * , unsigned int > indices; |
302 |
|
|
LISTE_MG_NOEUD::iterator itNo; |
303 |
|
|
int i=0; |
304 |
|
|
for (MG_NOEUD * no = _mesh->get_premier_noeud(itNo); no; no=_mesh->get_suivant_noeud(itNo)) |
305 |
|
|
{ |
306 |
|
|
out << "add coord " << no->get_id() ; |
307 |
|
|
out << " " << no->get_x(); |
308 |
|
|
out << " " << no->get_y() ; |
309 |
|
|
out << " " << no->get_z() << " \n"; |
310 |
|
|
if (no->get_lien_topologie() != NULL && no->get_lien_topologie()->get_dimension() == 0) |
311 |
|
|
out << "add node " << no->get_id()<<" \n"; |
312 |
|
|
} |
313 |
|
|
|
314 |
|
|
LISTE_MG_SEGMENT::iterator itSegment; |
315 |
|
|
for (MG_SEGMENT * seg = _mesh->get_premier_segment(itSegment); seg; seg = _mesh->get_suivant_segment(itSegment)) |
316 |
|
|
{ |
317 |
|
|
if (seg->get_lien_topologie() == NULL || seg->get_lien_topologie()->get_dimension() != 1) |
318 |
|
|
continue; |
319 |
|
|
out << "add segment " << seg->get_id() << " "; |
320 |
|
|
out << seg->get_noeud1()->get_id() << " "; |
321 |
|
|
out << seg->get_noeud2()->get_id() << " \n"; |
322 |
|
|
} */ |
323 |
|
|
|
324 |
|
|
/*LISTE_MG_TRIANGLE::iterator itTriang; |
325 |
|
|
for (MG_TRIANGLE * triangle = _mesh->get_premier_triangle(itTriang); triangle; triangle = _mesh->get_suivant_triangle(itTriang)) |
326 |
|
|
{ |
327 |
|
|
if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2) |
328 |
|
|
continue; |
329 |
|
|
out << "add triangle " << triangle->get_id() << " "; |
330 |
|
|
out << triangle->get_noeud1()->get_id() << " "; |
331 |
|
|
out << triangle->get_noeud3()->get_id() << " "; |
332 |
|
|
out << triangle->get_noeud2()->get_id() << " \n"; |
333 |
|
|
} */ |
334 |
|
|
|
335 |
|
|
out.close();
|
336 |
|
|
}
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
void MAILLEUR2D::export_ivanim_all_faces()
|
340 |
|
|
{
|
341 |
|
|
MG_MAILLAGE * _mesh = mg_maillage;
|
342 |
|
|
|
343 |
|
|
std::ofstream out("c:\\gilles\\out.ivanim"); |
344 |
|
|
float sleepTime = .1; |
345 |
|
|
|
346 |
|
|
out << "sleepTime " << sleepTime<<" \n"; |
347 |
|
|
out << "groupTriang 5 \n"; |
348 |
|
|
|
349 |
|
|
std::map < MG_NOEUD * , unsigned int > indices; |
350 |
|
|
LISTE_MG_NOEUD::iterator itNo; |
351 |
|
|
int i=0; |
352 |
|
|
for (MG_NOEUD * no = _mesh->get_premier_noeud(itNo); no; no=_mesh->get_suivant_noeud(itNo)) |
353 |
|
|
{ |
354 |
|
|
out << "add coord " << no->get_id() ; |
355 |
|
|
out << " " << no->get_x(); |
356 |
|
|
out << " " << no->get_y() ; |
357 |
|
|
out << " " << no->get_z() << " \n"; |
358 |
|
|
if (no->get_lien_topologie() != NULL && no->get_lien_topologie()->get_dimension() == 0) |
359 |
|
|
out << "add node " << no->get_id()<<" \n"; |
360 |
|
|
} |
361 |
|
|
|
362 |
|
|
LISTE_MG_SEGMENT::iterator itSegment; |
363 |
|
|
for (MG_SEGMENT * seg = _mesh->get_premier_segment(itSegment); seg; seg = _mesh->get_suivant_segment(itSegment)) |
364 |
|
|
{ |
365 |
|
|
if (seg->get_lien_topologie() == NULL || seg->get_lien_topologie()->get_dimension() != 1) |
366 |
|
|
continue; |
367 |
|
|
out << "add segment " << seg->get_id() << " "; |
368 |
|
|
out << seg->get_noeud1()->get_id() << " "; |
369 |
|
|
out << seg->get_noeud2()->get_id() << " \n"; |
370 |
|
|
} |
371 |
|
|
|
372 |
|
|
LISTE_MG_TRIANGLE::iterator itTriang; |
373 |
|
|
for (MG_TRIANGLE * triangle = _mesh->get_premier_triangle(itTriang); triangle; triangle = _mesh->get_suivant_triangle(itTriang)) |
374 |
|
|
{ |
375 |
|
|
if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2) |
376 |
|
|
continue; |
377 |
|
|
out << "add triangle " << triangle->get_id() << " "; |
378 |
|
|
out << triangle->get_noeud1()->get_id() << " "; |
379 |
|
|
out << triangle->get_noeud3()->get_id() << " "; |
380 |
|
|
out << triangle->get_noeud2()->get_id() << " \n"; |
381 |
|
|
} |
382 |
|
|
|
383 |
|
|
out.close();
|
384 |
|
|
}
|
385 |
|
|
|
386 |
foucault |
27 |
void MAILLEUR2D::initialise_frontiere(MCFace* __mcFace)
|
387 |
|
|
{
|
388 |
|
|
int nb_boucle=__mcFace->get_nb_mg_boucle();
|
389 |
|
|
for (int i=0;i<nb_boucle;i++)
|
390 |
|
|
{
|
391 |
|
|
MG_BOUCLE* mgboucle=__mcFace->get_mg_boucle(i);
|
392 |
|
|
int nb_coarete=mgboucle->get_nb_mg_coarete();
|
393 |
|
|
for (int j=0;j<nb_coarete;j++)
|
394 |
|
|
{
|
395 |
|
|
MG_COARETE* coarete=mgboucle->get_mg_coarete(j);
|
396 |
|
|
MCEdge* mgarete=(MCEdge*)coarete->get_arete();
|
397 |
|
|
int nb_segment=mgarete->get_lien_maillage()->get_nb();
|
398 |
|
|
for (int k=0;k<nb_segment;k++)
|
399 |
|
|
{
|
400 |
|
|
refresh();
|
401 |
|
|
MG_SEGMENT* mgsegment=(MG_SEGMENT*)mgarete->get_lien_maillage()->get(k);
|
402 |
|
|
MG_SEGMENT* mgsegtemp=(MG_SEGMENT*)mg_maillage->get_mg_segmentid(mgsegment->get_id());
|
403 |
|
|
if (mgsegtemp==NULL) continue;
|
404 |
|
|
MCSegment * mcSegment = (MCSegment*) mgsegment;
|
405 |
|
|
MCNode* mcNode=(MCNode*)mcSegment->get_noeud1();
|
406 |
|
|
segment_frontiere.ajouter(mcSegment);
|
407 |
|
|
noeud_frontiere.ajouter(mcNode);
|
408 |
|
|
mcNode=(MCNode*)mcSegment->get_noeud2();
|
409 |
|
|
if (!noeud_frontiere.est_dans_la_liste(mcNode));
|
410 |
|
|
{
|
411 |
|
|
noeud_frontiere.ajouter(mcNode);
|
412 |
|
|
}
|
413 |
|
|
}
|
414 |
|
|
|
415 |
|
|
}
|
416 |
|
|
}
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
}
|
420 |
|
|
|
421 |
|
|
void MAILLEUR2D::cree_grille(MCFace* __mcFace)
|
422 |
|
|
{
|
423 |
|
|
double bounding_box[6]={1E308,1E308,1E308,-1E308,-1E308,-1E308};
|
424 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR itElem;
|
425 |
|
|
for (MG_ELEMENT_MAILLAGE* elem = __mcFace->get_lien_maillage()->get_premier(itElem);
|
426 |
|
|
elem; elem = __mcFace->get_lien_maillage()->get_suivant(itElem))
|
427 |
|
|
{
|
428 |
|
|
MG_TRIANGLE * triang = (MG_TRIANGLE *) elem;
|
429 |
|
|
MG_NOEUD * n[3];
|
430 |
|
|
n[0] = triang->get_noeud1();
|
431 |
|
|
n[1] = triang->get_noeud2();
|
432 |
|
|
n[2] = triang->get_noeud3();
|
433 |
|
|
for (unsigned int i=0; i<3; i++)
|
434 |
|
|
{
|
435 |
|
|
for (unsigned int j=0; j<3; j++)
|
436 |
|
|
{
|
437 |
|
|
if (n[i]->get_coord()[j] < bounding_box[j])
|
438 |
|
|
bounding_box[j] = n[i]->get_coord()[j];
|
439 |
|
|
if (n[i]->get_coord()[j] > bounding_box[j+3])
|
440 |
|
|
bounding_box[j+3] = n[i]->get_coord()[j];
|
441 |
|
|
}
|
442 |
|
|
}
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
double xyz_taille [3];
|
446 |
|
|
for (unsigned int i=0; i<3; i++)
|
447 |
|
|
xyz_taille[i] = (bounding_box[i]+bounding_box[i+3])*.5;
|
448 |
|
|
|
449 |
|
|
double taille;
|
450 |
|
|
double density_tensor[9]; |
451 |
|
|
metrique->evaluer(xyz_taille, density_tensor);
|
452 |
|
|
taille = pow(density_tensor[0],-0.5);
|
453 |
|
|
|
454 |
|
|
int nb_cellule[3]; |
455 |
|
|
for (unsigned i = 0; i < 3; i++) |
456 |
|
|
{ |
457 |
|
|
double taille_cellule = taille; |
458 |
|
|
|
459 |
|
|
if ( taille_cellule != 0 ) |
460 |
|
|
nb_cellule[i] = (bounding_box[i+3]-bounding_box[i])/taille_cellule; |
461 |
|
|
else |
462 |
|
|
nb_cellule[i] = 1; |
463 |
|
|
|
464 |
|
|
if (nb_cellule[i] == 0) |
465 |
|
|
nb_cellule[i] ++; |
466 |
|
|
}
|
467 |
|
|
|
468 |
|
|
const double NB_MAX_CELL = 200000;
|
469 |
|
|
double alpha = NB_MAX_CELL / (nb_cellule[0]*nb_cellule[1]*nb_cellule[2]);
|
470 |
|
|
if (alpha < 1)
|
471 |
|
|
{
|
472 |
|
|
for (unsigned i = 0; i < 3; i++)
|
473 |
|
|
{
|
474 |
|
|
nb_cellule[i] = (int)((double)nb_cellule[i])*pow(alpha,.33);
|
475 |
|
|
if ( nb_cellule[i] == 0 )
|
476 |
|
|
nb_cellule[i] = 1;
|
477 |
|
|
}
|
478 |
|
|
printf("Nb cells = %d\n", nb_cellule[0]*nb_cellule[1]*nb_cellule[2]);
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
// increase grid's size by 100% of mesh size
|
482 |
|
|
for (int i=0; i<3; i++)
|
483 |
|
|
bounding_box[i] -= taille*1.0;
|
484 |
|
|
for (int i=0; i<3; i++)
|
485 |
|
|
bounding_box[i+3] += taille*1.0;
|
486 |
|
|
|
487 |
|
|
grille_de_segment = new TPL_GRILLE<MCSegment*>;
|
488 |
|
|
grille_de_segment->initialiser(bounding_box[0], bounding_box[1], bounding_box[2], bounding_box[3], bounding_box[4], bounding_box[5], nb_cellule[0], nb_cellule[1], nb_cellule[2]);
|
489 |
|
|
grille_de_frontiere = new TPL_GRILLE<MCSegment*>;
|
490 |
|
|
grille_de_frontiere->initialiser(bounding_box[0], bounding_box[1], bounding_box[2], bounding_box[3], bounding_box[4], bounding_box[5], nb_cellule[0], nb_cellule[1], nb_cellule[2]);
|
491 |
|
|
grille_de_front = new TPL_GRILLE<MG_FRONT_2D*>;
|
492 |
|
|
grille_de_front->initialiser(bounding_box[0], bounding_box[1], bounding_box[2], bounding_box[3], bounding_box[4], bounding_box[5], nb_cellule[0], nb_cellule[1], nb_cellule[2]);
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
void MAILLEUR2D::initialise_front(MCFace* __mcFace)
|
496 |
|
|
{
|
497 |
foucault |
64 |
std::set<MCVertex*> isolatedInteriorVertices;
|
498 |
foucault |
27 |
MG_FRONT_2D::initialise_compteur_id();
|
499 |
|
|
int nb_boucle=__mcFace->get_nb_mg_boucle();
|
500 |
|
|
for (int iboucle=0;iboucle<nb_boucle;iboucle++)
|
501 |
|
|
{
|
502 |
|
|
unsigned int nb_front_avant_cette_boucle=get_nb_front(front_courant);
|
503 |
|
|
MG_BOUCLE* mgboucle=__mcFace->get_mg_boucle(iboucle);
|
504 |
|
|
unsigned int nbcoaretetotale=mgboucle->get_nb_mg_coarete();
|
505 |
|
|
MG_COARETE* mgcoarete=mgboucle->get_mg_coarete(0);
|
506 |
|
|
MCNode* noeud_de_depart;
|
507 |
|
|
int bon_noeud=0;
|
508 |
|
|
int numnoeud=0;
|
509 |
|
|
while (bon_noeud==0)
|
510 |
|
|
{
|
511 |
|
|
if (mgcoarete->get_orientation()==MEME_SENS) noeud_de_depart=(MCNode*)mgcoarete->get_arete()->get_cosommet1()->get_sommet()->get_lien_maillage()->get(numnoeud);
|
512 |
|
|
else noeud_de_depart=(MCNode*)mgcoarete->get_arete()->get_cosommet2()->get_sommet()->get_lien_maillage()->get(numnoeud);
|
513 |
|
|
MG_NOEUD* noeudtemp=mg_maillage->get_mg_noeudid(noeud_de_depart->get_id());
|
514 |
|
|
if (noeudtemp==NULL) numnoeud++; else bon_noeud=1;
|
515 |
|
|
}
|
516 |
|
|
MG_FRONT_2D* premier_front;
|
517 |
|
|
MCNode* noeud_courant=noeud_de_depart;
|
518 |
|
|
MCSegment* segment_courant=NULL;
|
519 |
|
|
MG_FRONT_2D* front_precedent=NULL;
|
520 |
|
|
unsigned int nbcoaretetraite=0;
|
521 |
foucault |
64 |
|
522 |
|
|
if (nbcoaretetotale == 1 ) // this edge is a point isolated in the domain of a face
|
523 |
|
|
{
|
524 |
|
|
MCEdge * mcEdge = (MCEdge*)mgboucle->get_mg_coarete(0)->get_arete();
|
525 |
|
|
if (mcEdge->GetPolyCurve()->get_longueur() == 0)
|
526 |
|
|
{
|
527 |
|
|
isolatedInteriorVertices.insert( (MCVertex*) mcEdge->get_cosommet1()->get_sommet() );
|
528 |
|
|
continue;
|
529 |
|
|
}
|
530 |
|
|
}
|
531 |
|
|
|
532 |
|
|
|
533 |
foucault |
27 |
do
|
534 |
|
|
{
|
535 |
|
|
nbcoaretetraite++;
|
536 |
|
|
MCNode* noeud_d_arrivee;
|
537 |
|
|
int bon_noeud=0;
|
538 |
|
|
int numnoeud=0;
|
539 |
|
|
while (bon_noeud==0)
|
540 |
|
|
{
|
541 |
|
|
if (mgcoarete->get_orientation()==MEME_SENS) noeud_d_arrivee=(MCNode*)mgcoarete->get_arete()->get_cosommet2()->get_sommet()->get_lien_maillage()->get(numnoeud);
|
542 |
|
|
else noeud_d_arrivee=(MCNode*)mgcoarete->get_arete()->get_cosommet1()->get_sommet()->get_lien_maillage()->get(numnoeud);
|
543 |
|
|
MG_NOEUD* noeudtemp=mg_maillage->get_mg_noeudid(noeud_d_arrivee->get_id());
|
544 |
|
|
if (noeudtemp==NULL) numnoeud++; else bon_noeud=1;
|
545 |
|
|
}
|
546 |
|
|
MCEdge* mgarete=(MCEdge*)mgcoarete->get_arete();
|
547 |
|
|
segment_courant=NULL;
|
548 |
|
|
int passe_aretefermee=0;
|
549 |
|
|
do
|
550 |
|
|
{
|
551 |
|
|
int trouve=0;
|
552 |
|
|
int i;
|
553 |
|
|
if ((mgcoarete->get_arete()->get_cosommet1()->get_sommet()==mgcoarete->get_arete()->get_cosommet2()->get_sommet())&&(passe_aretefermee==0))
|
554 |
|
|
{
|
555 |
|
|
passe_aretefermee=1;
|
556 |
|
|
MCSegment* mgsegment_depart1=NULL;
|
557 |
|
|
MCSegment* mgsegment_depart2=NULL;
|
558 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it;
|
559 |
|
|
MCSegment* mgsegment=(MCSegment*)mgarete->get_lien_maillage()->get_premier(it);
|
560 |
|
|
do
|
561 |
|
|
{
|
562 |
|
|
if ((mgsegment->get_noeud1()==noeud_courant) || (mgsegment->get_noeud2()==noeud_courant)) mgsegment_depart1=mgsegment;
|
563 |
|
|
mgsegment=(MCSegment*)mgarete->get_lien_maillage()->get_suivant(it);
|
564 |
|
|
}
|
565 |
|
|
while (mgsegment_depart1==NULL);
|
566 |
|
|
do
|
567 |
|
|
{
|
568 |
|
|
if ((mgsegment->get_noeud1()==noeud_courant) || (mgsegment->get_noeud2()==noeud_courant)) mgsegment_depart2=mgsegment;
|
569 |
|
|
mgsegment=(MCSegment*)mgarete->get_lien_maillage()->get_suivant(it);
|
570 |
|
|
}
|
571 |
|
|
while (mgsegment_depart2==NULL);
|
572 |
|
|
MCNode* noeud1_2;
|
573 |
|
|
MCNode* noeud2_2;
|
574 |
|
|
if (mgsegment_depart1->get_noeud1()==noeud_courant) noeud1_2=(MCNode*)mgsegment_depart1->get_noeud2(); else noeud1_2=(MCNode*)mgsegment_depart1->get_noeud1();
|
575 |
|
|
if (mgsegment_depart2->get_noeud1()==noeud_courant) noeud2_2=(MCNode*)mgsegment_depart2->get_noeud2(); else noeud2_2=(MCNode*)mgsegment_depart2->get_noeud1();
|
576 |
|
|
OT_VECTEUR_3D vecteur1(noeud1_2->get_x()-noeud_courant->get_x(),noeud1_2->get_y()-noeud_courant->get_y(),noeud1_2->get_z()-noeud_courant->get_z());
|
577 |
|
|
double coo[3];
|
578 |
|
|
mgarete->deriver(mgarete->get_tmin(),coo);
|
579 |
|
|
OT_VECTEUR_3D tangeante(coo[0]*mgcoarete->get_orientation(),coo[1]*mgcoarete->get_orientation(),coo[2]*mgcoarete->get_orientation());
|
580 |
|
|
MCNode* noeud_suivant;
|
581 |
|
|
if (vecteur1*tangeante>0.)
|
582 |
|
|
{
|
583 |
|
|
mgsegment=mgsegment_depart1;
|
584 |
|
|
noeud_suivant=noeud1_2;
|
585 |
|
|
}
|
586 |
|
|
else
|
587 |
|
|
{
|
588 |
|
|
mgsegment=mgsegment_depart2;
|
589 |
|
|
noeud_suivant=noeud2_2;
|
590 |
|
|
}
|
591 |
|
|
MG_FRONT_2D* front=ajouter_front(front_courant,noeud_courant,noeud_suivant,mgsegment);
|
592 |
|
|
grille_de_segment->inserer(mgsegment);
|
593 |
|
|
if (get_nb_front(front_courant)==nb_front_avant_cette_boucle+1) premier_front=front;
|
594 |
|
|
front->changer_front_precedent(front_precedent);
|
595 |
|
|
front_precedent=front;
|
596 |
|
|
noeud_courant=noeud_suivant;
|
597 |
|
|
segment_courant=mgsegment;
|
598 |
|
|
}
|
599 |
|
|
else
|
600 |
|
|
{
|
601 |
|
|
trouve=0;
|
602 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it;
|
603 |
|
|
MG_SEGMENT* mgsegment=(MG_SEGMENT*)mgarete->get_lien_maillage()->get_premier(it);
|
604 |
|
|
do
|
605 |
|
|
{
|
606 |
|
|
if ((mgsegment->get_noeud1()==noeud_courant) || (mgsegment->get_noeud2()==noeud_courant))
|
607 |
|
|
if (mgsegment!=segment_courant)
|
608 |
|
|
{
|
609 |
|
|
trouve=1;
|
610 |
|
|
MCNode* noeud_suivant;
|
611 |
|
|
if (mgsegment->get_noeud1()==noeud_courant) noeud_suivant=(MCNode*)mgsegment->get_noeud2();
|
612 |
|
|
else if (mgsegment->get_noeud2()==noeud_courant) noeud_suivant=(MCNode*)mgsegment->get_noeud1();
|
613 |
|
|
MG_FRONT_2D* front=ajouter_front(front_courant,noeud_courant,noeud_suivant,(MCSegment*)mgsegment);
|
614 |
|
|
grille_de_segment->inserer((MCSegment*)mgsegment);
|
615 |
|
|
if (get_nb_front(front_courant)==nb_front_avant_cette_boucle+1) premier_front=front;
|
616 |
|
|
else front_precedent->changer_front_suivant(front);
|
617 |
|
|
front->changer_front_precedent(front_precedent);
|
618 |
|
|
front_precedent=front;
|
619 |
|
|
noeud_courant=noeud_suivant;
|
620 |
|
|
segment_courant=(MCSegment*)mgsegment;
|
621 |
|
|
}
|
622 |
|
|
mgsegment=(MG_SEGMENT*)mgarete->get_lien_maillage()->get_suivant(it);
|
623 |
|
|
}
|
624 |
|
|
while (trouve==0);
|
625 |
|
|
}
|
626 |
|
|
}
|
627 |
|
|
while (noeud_courant!=noeud_d_arrivee);
|
628 |
|
|
|
629 |
|
|
int trouve=0;
|
630 |
|
|
|
631 |
|
|
if (nbcoaretetraite != nbcoaretetotale)
|
632 |
|
|
mgcoarete = mgboucle->get_mg_coarete(nbcoaretetraite);
|
633 |
|
|
else
|
634 |
|
|
mgcoarete = NULL;
|
635 |
|
|
}
|
636 |
|
|
while ( mgcoarete );
|
637 |
|
|
front_precedent->changer_front_suivant(premier_front);
|
638 |
|
|
premier_front->changer_front_precedent(front_precedent);
|
639 |
|
|
}
|
640 |
|
|
|
641 |
foucault |
64 |
initialise_front (__mcFace, isolatedInteriorVertices);
|
642 |
foucault |
27 |
}
|
643 |
|
|
|
644 |
foucault |
64 |
void MAILLEUR2D::initialise_front (MCFace * __mcFace, std::set<MCVertex*> __isolatedInteriorVertices)
|
645 |
|
|
{
|
646 |
|
|
for (std::set<MCVertex*>::iterator itV = __isolatedInteriorVertices.begin();
|
647 |
|
|
itV != __isolatedInteriorVertices.end();
|
648 |
|
|
itV ++ )
|
649 |
|
|
{
|
650 |
|
|
MCVertex * mcVertex = *itV;
|
651 |
|
|
MCNode * mcNode = 0;
|
652 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it_elem;
|
653 |
|
|
for (MG_ELEMENT_MAILLAGE* elem = mcVertex->get_lien_maillage()->get_premier(it_elem);
|
654 |
|
|
elem;elem = mcVertex->get_lien_maillage()->get_suivant(it_elem))
|
655 |
|
|
if (elem->get_type_entite()==IDMCNODE)
|
656 |
|
|
mcNode = (MCNode*)elem;
|
657 |
|
|
MG_FRONT_2D *front_rencontre;
|
658 |
|
|
MCNode *noeud_solution;
|
659 |
|
|
int solution = genere_noeud(__mcFace, mcNode, &front_rencontre, &noeud_solution);
|
660 |
|
|
|
661 |
|
|
MCSegment* mgsegment;
|
662 |
|
|
int ierr = insere_segment(__mcFace,&mgsegment,mcNode,noeud_solution,TOUS_FRONT);
|
663 |
|
|
|
664 |
|
|
if (solution==FRONT_RENCONTRE)
|
665 |
|
|
{
|
666 |
|
|
MG_FRONT_2D *ft2=front_rencontre;
|
667 |
|
|
MG_FRONT_2D *ft1=front_rencontre->get_front_precedent();
|
668 |
|
|
MG_FRONT_2D *nv_ft1=ajouter_front(front_courant,noeud_solution,mcNode,mgsegment);
|
669 |
|
|
MG_FRONT_2D *nv_ft2=ajouter_front(front_courant,mcNode,noeud_solution,mgsegment);
|
670 |
|
|
nv_ft1->changer_front_precedent(ft1);
|
671 |
|
|
ft1->changer_front_suivant(nv_ft1);
|
672 |
|
|
nv_ft2->changer_front_precedent(nv_ft1);
|
673 |
|
|
nv_ft1->changer_front_suivant(nv_ft2);
|
674 |
|
|
nv_ft2->changer_front_suivant(ft2);
|
675 |
|
|
ft2->changer_front_precedent(nv_ft2);
|
676 |
|
|
}
|
677 |
|
|
else if (solution==NOEUD_CREE)
|
678 |
|
|
{
|
679 |
|
|
MG_FRONT_2D *nv_ft1=ajouter_front(front_courant,noeud_solution,mcNode,mgsegment);
|
680 |
|
|
MG_FRONT_2D *nv_ft2=ajouter_front(front_courant,mcNode,noeud_solution,mgsegment);
|
681 |
|
|
nv_ft1->changer_front_suivant(nv_ft2);
|
682 |
|
|
nv_ft1->changer_front_precedent(nv_ft2);
|
683 |
|
|
nv_ft2->changer_front_suivant(nv_ft1);
|
684 |
|
|
nv_ft2->changer_front_precedent(nv_ft1);
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
}
|
688 |
|
|
|
689 |
foucault |
27 |
void MAILLEUR2D::progresse_front(MCFace * __mcFace)
|
690 |
|
|
{
|
691 |
|
|
int compteur=0;
|
692 |
|
|
int nbpas_compteur=100;
|
693 |
|
|
int compteur_min=100;
|
694 |
|
|
int compteur_min_oiv1=100;
|
695 |
|
|
int compteur_min_oiv2=9000000;
|
696 |
|
|
_nbTriangles[__mcFace] = 0;
|
697 |
|
|
clock_t compteur_temps, compteur_temps2;
|
698 |
|
|
compteur_temps = clock();
|
699 |
|
|
|
700 |
|
|
while (get_nb_front(front_courant)!=0)
|
701 |
|
|
{
|
702 |
foucault |
64 |
|
703 |
foucault |
27 |
compteur++;
|
704 |
|
|
|
705 |
|
|
compteur_temps2 = clock();
|
706 |
|
|
if (compteur_temps2-compteur_temps > CLOCKS_PER_SEC*.1)
|
707 |
|
|
{
|
708 |
|
|
std::ofstream file(filenameNbTriangles);
|
709 |
|
|
|
710 |
|
|
file << " id = " << __mcFace->get_id()<< " ";
|
711 |
|
|
file << "nb triangles = "<<_nbTriangles[__mcFace]<< " ";
|
712 |
|
|
file << "nb fronts = "<< get_nb_front(front_courant)+get_nb_front(front_attente);
|
713 |
|
|
file.flush();
|
714 |
|
|
file.close();
|
715 |
|
|
compteur_temps = compteur_temps2;
|
716 |
|
|
}
|
717 |
|
|
|
718 |
|
|
if (debug && _nbTriangles[__mcFace] >= compteur_min && (_nbTriangles[__mcFace]%nbpas_compteur==0))
|
719 |
|
|
{
|
720 |
|
|
if(0)
|
721 |
|
|
{
|
722 |
|
|
MG_FRONT_2D *f1=get_front(front_courant,0), *fc=f1;
|
723 |
|
|
std::set < MG_FRONT_2D * > visited;
|
724 |
|
|
unsigned cpt_front=0;
|
725 |
|
|
while (cpt_front < get_nb_front(front_courant))
|
726 |
|
|
{
|
727 |
|
|
visited.insert (fc);
|
728 |
|
|
unsigned id = fc->get_noeud1()->get_id();
|
729 |
|
|
if (id == 60101 || id==60099)
|
730 |
|
|
printf("* %d *, ",id);
|
731 |
|
|
else
|
732 |
|
|
printf("%d, ", id);
|
733 |
|
|
fc = fc->get_front_suivant();
|
734 |
|
|
if (visited.find(fc) != visited.end())
|
735 |
|
|
for (std::multimap<double,MG_FRONT_2D*>::iterator itFr=front_courant.begin();
|
736 |
|
|
itFr != front_courant.end();
|
737 |
|
|
itFr++)
|
738 |
|
|
if ( visited.find(itFr->second) == visited.end())
|
739 |
|
|
{
|
740 |
|
|
fc = itFr->second;
|
741 |
|
|
printf("--\n");
|
742 |
|
|
break;
|
743 |
|
|
}
|
744 |
|
|
|
745 |
|
|
cpt_front++;
|
746 |
|
|
} ;
|
747 |
|
|
printf("\n\n");
|
748 |
|
|
}
|
749 |
|
|
|
750 |
|
|
{
|
751 |
|
|
ofstream o4("c:\\temp\\void_2D.mai",ios::out|ios::trunc);
|
752 |
|
|
o4.precision(16);
|
753 |
|
|
o4.setf(ios::showpoint);
|
754 |
|
|
mg_maillage->enregistrer_sous_mesh_2D(o4);
|
755 |
|
|
}
|
756 |
|
|
|
757 |
|
|
if ( _nbTriangles[__mcFace]>=compteur_min_oiv1)
|
758 |
|
|
{
|
759 |
|
|
char filename2[5000];
|
760 |
|
|
sprintf(filename2,"%s\\CAD4FE_Mesher_%d.iv",getenv("TEMP"),_nbTriangles[__mcFace]);
|
761 |
|
|
std::ofstream file(filename2);
|
762 |
|
|
CAD4FE::InventorText_MG_MAILLAGE ivTextRefTess (mg_maillage);
|
763 |
|
|
ivTextRefTess.ShowFaceSegments = true;
|
764 |
|
|
ivTextRefTess.ShowSegmentId = false;
|
765 |
|
|
ivTextRefTess.ShowTriangleId = false;
|
766 |
|
|
ivTextRefTess.ShowNodeId = true;
|
767 |
|
|
ivTextRefTess.InverseTriangleNormals = true;
|
768 |
|
|
ivTextRefTess.TriangleColor=1;
|
769 |
|
|
file << ivTextRefTess.GetText();
|
770 |
|
|
file << "\n}\n";
|
771 |
|
|
file.close();
|
772 |
|
|
}
|
773 |
|
|
|
774 |
|
|
if (compteur>=compteur_min_oiv2 ) |
775 |
|
|
{ |
776 |
|
|
char filename2[5000];
|
777 |
|
|
strcpy(filename2,getenv("TEMP"));
|
778 |
|
|
strcat(filename2,"\\CAD4FE_Mesher_MCSegments.iv");
|
779 |
|
|
std::ofstream file(filename2); |
780 |
|
|
|
781 |
|
|
InventorText_MG_MAILLAGE meshIvText (mg_maillage);
|
782 |
|
|
meshIvText.ShowFaceSegments = true;
|
783 |
|
|
meshIvText.ShowSegmentId = true;
|
784 |
|
|
meshIvText.ShowTriangleId = true;
|
785 |
|
|
meshIvText.ShowNodeId = true;
|
786 |
|
|
meshIvText.InverseTriangleNormals = true;
|
787 |
|
|
meshIvText.TriangleColor=1;
|
788 |
|
|
file<<meshIvText.GetText(); |
789 |
|
|
|
790 |
|
|
file << "DrawStyle {\nstyle LINES\nlineWidth 2\npointSize 3\n}\n"; |
791 |
|
|
LISTE_MG_SEGMENT::iterator itSegment; |
792 |
|
|
for (MG_SEGMENT * seg = mg_maillage->get_premier_segment(itSegment); seg; seg = mg_maillage->get_suivant_segment(itSegment)) |
793 |
|
|
{ |
794 |
|
|
if (seg->get_lien_topologie()->get_dimension() == 1) |
795 |
|
|
file << "BaseColor { \n rgb 0.0 0.0 0.9\n }\n"; |
796 |
|
|
if (seg->get_lien_topologie()->get_dimension() == 2) |
797 |
|
|
file << "BaseColor { \n rgb 0.0 0.0 0.0\n }\n"; |
798 |
|
|
MCSegment * mcSeg = (MCSegment *) seg; |
799 |
|
|
InventorText_MCSegment mcSegTxt (mcSeg); |
800 |
|
|
file << mcSegTxt.GetText(); |
801 |
|
|
} |
802 |
|
|
|
803 |
|
|
file << "\n}\n"; |
804 |
|
|
file.close(); |
805 |
|
|
}
|
806 |
|
|
}
|
807 |
|
|
|
808 |
|
|
|
809 |
|
|
refresh();
|
810 |
|
|
MG_FRONT_2D* ft=get_front(front_courant,0);
|
811 |
|
|
MG_FRONT_2D* ftp=ft->get_front_precedent();
|
812 |
|
|
MG_FRONT_2D* fts=ft->get_front_suivant();
|
813 |
|
|
double eps=0.0001*ft->get_segment()->get_longueur();
|
814 |
|
|
MCNode* nop=ftp->get_noeud1();
|
815 |
|
|
MCNode* no1=ft->get_noeud1();
|
816 |
|
|
MCNode* no2=ft->get_noeud2();
|
817 |
|
|
MCNode* nos=fts->get_noeud2();
|
818 |
|
|
/* angle precedent et angle suivant */
|
819 |
|
|
OT_VECTEUR_3D n1n2(no1->get_coord(),no2->get_coord());
|
820 |
|
|
OT_VECTEUR_3D n2s(no2->get_coord(),nos->get_coord());
|
821 |
|
|
OT_VECTEUR_3D pn1(nop->get_coord(),no1->get_coord());
|
822 |
|
|
n1n2.norme();
|
823 |
|
|
n2s.norme();
|
824 |
|
|
pn1.norme();
|
825 |
|
|
double coo[3];
|
826 |
|
|
int nbRefFaces;
|
827 |
|
|
__mcFace->calcul_normale_unitaire(no1->GetRefFaceMapping(), coo, &nbRefFaces);
|
828 |
|
|
// MCFace_calcul_normale_unitaire(__mcFace,no1,coo);
|
829 |
|
|
OT_VECTEUR_3D nplan(coo);
|
830 |
|
|
OT_VECTEUR_3D n=nplan&n1n2;
|
831 |
|
|
n.norme();
|
832 |
|
|
double pcp=(-1)*(n1n2*pn1);
|
833 |
|
|
double psp=(-1)*(n*pn1);
|
834 |
|
|
int anglep;
|
835 |
|
|
if ((pcp>=0.1786481777)&&(psp>eps)) anglep=1; else anglep=0;
|
836 |
|
|
// MCFace_calcul_normale_unitaire(__mcFace,no2,coo);
|
837 |
|
|
__mcFace->calcul_normale_unitaire(no2->GetRefFaceMapping(), coo, &nbRefFaces);
|
838 |
|
|
OT_VECTEUR_3D nplan2(coo);
|
839 |
|
|
n=nplan2&n1n2;
|
840 |
|
|
n.norme();
|
841 |
|
|
double pcs=(-1.)*(n1n2*n2s);
|
842 |
|
|
double pss=n*n2s;
|
843 |
|
|
int angles;
|
844 |
|
|
if ((pcs>=0.1786481777)&&(pss>eps)) angles=1; else angles=0;
|
845 |
|
|
int type_cas_front[10];
|
846 |
|
|
if ( (ftp==fts->get_front_suivant()) && (no1!=nos) && (no2!=nop) ) type_cas_front[CAS_FRONT_3]=1; else type_cas_front[CAS_FRONT_3]=0;
|
847 |
|
|
if (identifie_front_cas_front_3x(ftp,ft,fts)) type_cas_front[CAS_FRONT_3X]=1; else type_cas_front[CAS_FRONT_3X]=0;
|
848 |
|
|
if ( ftp->get_front_precedent()==fts->get_front_suivant() && (nos!=no1) && (no2!=nop) ) type_cas_front[CAS_FRONT_4]=1; else type_cas_front[CAS_FRONT_4]=0;
|
849 |
|
|
if ( (anglep==1) && (angles==1) ) type_cas_front[CAS_FERME_CAVITE]=1; else type_cas_front[CAS_FERME_CAVITE]=0;
|
850 |
|
|
if ( anglep==1 ) type_cas_front[CAS_FERME_CAVITE_P]=1; else type_cas_front[CAS_FERME_CAVITE_P]=0;
|
851 |
|
|
if ( angles==1 ) type_cas_front[CAS_FERME_CAVITE_S]=1; else type_cas_front[CAS_FERME_CAVITE_S]=0;
|
852 |
|
|
type_cas_front[CAS_GENERAL]=1;
|
853 |
|
|
int solution=PASTROUVE;
|
854 |
|
|
if (type_cas_front[CAS_FRONT_3]) solution=traite_front(CAS_FRONT_3,__mcFace,ftp,ft,fts);
|
855 |
|
|
if ((solution==PASTROUVE) && (type_cas_front[CAS_FRONT_3X])) solution=traite_front(CAS_FRONT_3X,__mcFace,ftp,ft,fts);
|
856 |
|
|
if ((solution==PASTROUVE) && (type_cas_front[CAS_FRONT_4])) solution=traite_front(CAS_FRONT_4,__mcFace,ftp,ft,fts);
|
857 |
|
|
if ((solution==PASTROUVE) && (type_cas_front[CAS_FERME_CAVITE])) solution=traite_front(CAS_FERME_CAVITE,__mcFace,ftp,ft,fts);
|
858 |
|
|
if ((solution==PASTROUVE) && (type_cas_front[CAS_FERME_CAVITE_P])) solution=traite_front(CAS_FERME_CAVITE_P,__mcFace,ftp,ft,fts);
|
859 |
|
|
if ((solution==PASTROUVE) && (type_cas_front[CAS_FERME_CAVITE_S])) solution=traite_front(CAS_FERME_CAVITE_S,__mcFace,ftp,ft,fts);
|
860 |
|
|
if ((solution==PASTROUVE) && (type_cas_front[CAS_GENERAL]))
|
861 |
|
|
{
|
862 |
|
|
solution=traite_front(CAS_GENERAL,__mcFace,ftp,ft,fts);
|
863 |
|
|
if ((solution!=PASTROUVE)&&(solution!=TROUVE))
|
864 |
|
|
if (!type_cas_front[solution]) solution=traite_front(solution,__mcFace,ftp,ft,fts); else solution=PASTROUVE;
|
865 |
|
|
if (solution==PASTROUVE)
|
866 |
|
|
{
|
867 |
|
|
echange_de_front(front_courant,front_attente,ft);
|
868 |
|
|
ft->incremente_ifail();
|
869 |
|
|
solution=TROUVE;
|
870 |
|
|
}
|
871 |
|
|
}
|
872 |
|
|
if (get_nb_front(front_courant)==0) front_courant.swap(front_attente);
|
873 |
|
|
}
|
874 |
|
|
|
875 |
|
|
{
|
876 |
|
|
std::ofstream file(filenameNbTriangles);
|
877 |
|
|
file << " id = " << __mcFace->get_id()<< " ";
|
878 |
|
|
file << "nb triangles = "<<_nbTriangles[__mcFace]<< " ";
|
879 |
|
|
file << "nb fronts = "<< get_nb_front(front_courant)+get_nb_front(front_attente);
|
880 |
|
|
file.flush();
|
881 |
|
|
file.close();
|
882 |
|
|
}
|
883 |
|
|
|
884 |
|
|
}
|
885 |
|
|
|
886 |
|
|
void MAILLEUR2D::optimise_bascule_segment(MCFace* __mcFace)
|
887 |
|
|
{
|
888 |
|
|
OptimizeEdgeSwap edgeSwapper(mg_maillage);
|
889 |
|
|
edgeSwapper.Optimize(__mcFace);
|
890 |
|
|
initialise_lst_tri_qual(__mcFace);
|
891 |
|
|
}
|
892 |
|
|
|
893 |
|
|
void MAILLEUR2D::initialise_lst_tri_qual(MCFace* __mcFace)
|
894 |
|
|
{
|
895 |
|
|
lst_tri_qual.clear();
|
896 |
|
|
lst_tri_qual2.clear();
|
897 |
|
|
LISTE_MG_TRIANGLE::iterator itTri;
|
898 |
|
|
for (M3D_MCTriangle * mtri = (M3D_MCTriangle *)mg_maillage->get_premier_triangle(itTri);mtri; mtri = (M3D_MCTriangle *)mg_maillage->get_suivant_triangle(itTri))
|
899 |
|
|
{
|
900 |
|
|
double qual=OPERATEUR::qualite_triangle(mtri->get_noeud1()->get_coord(),mtri->get_noeud2()->get_coord(),mtri->get_noeud3()->get_coord());
|
901 |
|
|
mtri->change_qualite(qual);
|
902 |
|
|
lst_tri_qual.insert(std::make_pair(mtri->get_qualite(),mtri));
|
903 |
|
|
}
|
904 |
|
|
}
|
905 |
|
|
|
906 |
|
|
void MAILLEUR2D::optimise(MCFace* __mcFace)
|
907 |
|
|
{
|
908 |
|
|
initialise_lst_tri_qual(__mcFace);
|
909 |
|
|
std::set<MCSegment *> lstSegToUpdate;
|
910 |
|
|
for (int phase=0;phase<2;phase++)
|
911 |
|
|
{
|
912 |
|
|
ORDRE_TRIANGLE& lst=lst_tri_qual;
|
913 |
|
|
if (phase==1)
|
914 |
|
|
lst=lst_tri_qual2;
|
915 |
|
|
int ok=0;
|
916 |
|
|
do
|
917 |
|
|
{
|
918 |
|
|
ORDRE_TRIANGLE::iterator i=lst.begin();
|
919 |
|
|
if (i==lst.end())
|
920 |
|
|
{
|
921 |
|
|
ok=1;
|
922 |
|
|
continue;
|
923 |
|
|
}
|
924 |
|
|
M3D_MCTriangle* tri=(*i).second;
|
925 |
|
|
if (tri->get_qualite()<0.5)
|
926 |
|
|
{
|
927 |
|
|
MCNode* no[3];
|
928 |
|
|
no[0]=(MCNode*)tri->get_noeud1();
|
929 |
|
|
no[1]=(MCNode*)tri->get_noeud2();
|
930 |
|
|
no[2]=(MCNode*)tri->get_noeud3();
|
931 |
|
|
double crit[3];//,u[3],v[3],x[3],y[3],z[3];
|
932 |
|
|
MCNode *noeud_optimal[3]={0,0,0};
|
933 |
|
|
int ierr=bouge_point(__mcFace,no[0],crit[0],&(noeud_optimal[0]));
|
934 |
|
|
if (ierr==0) crit[0]=0.;
|
935 |
|
|
ierr=bouge_point(__mcFace,no[1],crit[1],&(noeud_optimal[1]));
|
936 |
|
|
if (ierr==0) crit[1]=0.;
|
937 |
|
|
ierr=bouge_point(__mcFace,no[2],crit[2],&(noeud_optimal[2]));
|
938 |
|
|
if (ierr==0) crit[2]=0.;
|
939 |
|
|
double critopt=std::max(crit[0],crit[1]);
|
940 |
|
|
critopt=std::max(critopt,crit[2]);
|
941 |
|
|
int num=-1;
|
942 |
|
|
if (critopt>tri->get_qualite())
|
943 |
|
|
{
|
944 |
|
|
if (critopt==crit[0]) num=0;
|
945 |
|
|
if (critopt==crit[1]) num=1;
|
946 |
|
|
if (critopt==crit[2]) num=2;
|
947 |
|
|
}
|
948 |
|
|
if (num!=-1)
|
949 |
|
|
{
|
950 |
|
|
no[num]->CopyGeometry(*noeud_optimal[num]);
|
951 |
|
|
int nb_seg=no[num]->get_lien_segment()->get_nb();
|
952 |
|
|
// the geometry of adjacent segment (path in the reference BRep)
|
953 |
|
|
// must be updated according to the new position of the node
|
954 |
|
|
for (int i=0;i<nb_seg;i++)
|
955 |
|
|
lstSegToUpdate.insert((MCSegment*)no[num]->get_lien_segment()->get(i));
|
956 |
|
|
int nb_tri=no[num]->get_lien_triangle()->get_nb();
|
957 |
|
|
for (int i=0;i<nb_tri;i++)
|
958 |
|
|
{
|
959 |
|
|
M3D_MCTriangle* mtri=(M3D_MCTriangle*)no[num]->get_lien_triangle()->get(i);
|
960 |
|
|
double qual=OPERATEUR::qualite_triangle(mtri->get_noeud1()->get_coord(),mtri->get_noeud2()->get_coord(),mtri->get_noeud3()->get_coord());
|
961 |
|
|
mtri->change_qualite(qual);
|
962 |
|
|
}
|
963 |
|
|
}
|
964 |
|
|
if (noeud_optimal[0]) delete noeud_optimal[0];
|
965 |
|
|
if (noeud_optimal[1]) delete noeud_optimal[1];
|
966 |
|
|
if (noeud_optimal[2]) delete noeud_optimal[2];
|
967 |
|
|
}
|
968 |
|
|
else ok=1;
|
969 |
|
|
if ((tri->get_qualite()<0.5) && (phase==0))
|
970 |
|
|
{
|
971 |
|
|
std::pair<const double,M3D_MCTriangle*> tmp(1./tri->get_qualite(),tri);
|
972 |
|
|
lst_tri_qual2.insert(tmp);
|
973 |
|
|
}
|
974 |
|
|
lst.erase(i);
|
975 |
|
|
}
|
976 |
|
|
while (ok==0);
|
977 |
|
|
}
|
978 |
|
|
|
979 |
|
|
// update the geometry of segments which nodes have been moved
|
980 |
|
|
for (std::set<MCSegment*>::iterator itSeg=lstSegToUpdate.begin();
|
981 |
|
|
itSeg!=lstSegToUpdate.end();
|
982 |
|
|
itSeg++)
|
983 |
|
|
{
|
984 |
|
|
MCSegment * seg = * itSeg;
|
985 |
|
|
seg->UpdateGeometry();
|
986 |
|
|
}
|
987 |
|
|
}
|
988 |
|
|
|
989 |
|
|
|
990 |
|
|
/*void MAILLEUR2D::optimise(MG_FACE* mgface)
|
991 |
|
|
{
|
992 |
|
|
for (int phase=0;phase<2;phase++)
|
993 |
|
|
{
|
994 |
|
|
ORDRE_TRIANGLE& lst=lst_tri_qual;
|
995 |
|
|
if (phase==1)
|
996 |
|
|
lst=lst_tri_qual2;
|
997 |
|
|
int ok=0;
|
998 |
|
|
do
|
999 |
|
|
{
|
1000 |
|
|
ORDRE_TRIANGLE::iterator i=lst.begin();
|
1001 |
|
|
if (i==lst.end())
|
1002 |
|
|
{
|
1003 |
|
|
ok=1;
|
1004 |
|
|
continue;
|
1005 |
|
|
}
|
1006 |
|
|
M3D_MCTriangle* tri=(*i).second;
|
1007 |
|
|
if (tri->get_qualite()<0.5)
|
1008 |
|
|
{
|
1009 |
|
|
MG_NOEUD* no[3];
|
1010 |
|
|
no[0]=tri->get_noeud1();
|
1011 |
|
|
no[1]=tri->get_noeud2();
|
1012 |
|
|
no[2]=tri->get_noeud3();
|
1013 |
|
|
double crit[3],u[3],v[3],x[3],y[3],z[3];
|
1014 |
|
|
int ierr=bouge_point(mgface,no[0],crit[0],u[0],v[0],x[0],y[0],z[0]);
|
1015 |
|
|
if (ierr==0) crit[0]=0.;
|
1016 |
|
|
ierr=bouge_point(mgface,no[1],crit[1],u[1],v[1],x[1],y[1],z[1]);
|
1017 |
|
|
if (ierr==0) crit[1]=0.;
|
1018 |
|
|
ierr=bouge_point(mgface,no[2],crit[2],u[2],v[2],x[2],y[2],z[2]);
|
1019 |
|
|
if (ierr==0) crit[2]=0.;
|
1020 |
|
|
double critopt=std::max(crit[0],crit[1]);
|
1021 |
|
|
critopt=std::max(critopt,crit[2]);
|
1022 |
|
|
int num=-1;
|
1023 |
|
|
if (critopt>tri->get_qualite())
|
1024 |
|
|
{
|
1025 |
|
|
if (critopt==crit[0]) num=0;
|
1026 |
|
|
if (critopt==crit[1]) num=1;
|
1027 |
|
|
if (critopt==crit[2]) num=2;
|
1028 |
|
|
}
|
1029 |
|
|
if (num!=-1)
|
1030 |
|
|
{
|
1031 |
|
|
no[num]->change_u(u[num]);
|
1032 |
|
|
no[num]->change_v(v[num]);
|
1033 |
|
|
no[num]->change_x(x[num]);
|
1034 |
|
|
no[num]->change_y(y[num]);
|
1035 |
|
|
no[num]->change_z(z[num]);
|
1036 |
|
|
int nb_tri=no[num]->get_lien_triangle()->get_nb();
|
1037 |
|
|
for (int i=0;i<nb_tri;i++)
|
1038 |
|
|
{
|
1039 |
|
|
M3D_MCTriangle* mtri=(M3D_MCTriangle*)no[num]->get_lien_triangle()->get(i);
|
1040 |
|
|
double qual=OPERATEUR::qualite_triangle(mtri->get_noeud1()->get_coord(),mtri->get_noeud2()->get_coord(),mtri->get_noeud3()->get_coord());
|
1041 |
|
|
mtri->change_qualite(qual);
|
1042 |
|
|
}
|
1043 |
|
|
}
|
1044 |
|
|
}
|
1045 |
|
|
else ok=1;
|
1046 |
|
|
if ((tri->get_qualite()<0.5) && (phase==0))
|
1047 |
|
|
{
|
1048 |
|
|
std::pair<const double,M3D_MCTriangle*> tmp(1./tri->get_qualite(),tri);
|
1049 |
|
|
lst_tri_qual2.insert(tmp);
|
1050 |
|
|
}
|
1051 |
|
|
lst.erase(i);
|
1052 |
|
|
}
|
1053 |
|
|
while (ok==0);
|
1054 |
|
|
}
|
1055 |
|
|
} */
|
1056 |
|
|
|
1057 |
|
|
|
1058 |
|
|
|
1059 |
|
|
|
1060 |
|
|
// FONCTIONS GERANT L ENTITE FRONT (ajout suppression et tout le bordel)
|
1061 |
|
|
MG_FRONT_2D* MAILLEUR2D::ajouter_front(FRONT& front,MCNode* noeud1,MCNode* noeud2,MCSegment* segment)
|
1062 |
|
|
{
|
1063 |
|
|
MG_FRONT_2D* ft=new MG_FRONT_2D(noeud1,noeud2,segment);
|
1064 |
|
|
ajouter_front(front,ft);
|
1065 |
|
|
grille_de_front->inserer(ft);
|
1066 |
|
|
return ft;
|
1067 |
|
|
}
|
1068 |
|
|
|
1069 |
|
|
void MAILLEUR2D::ajouter_front(FRONT& front,MG_FRONT_2D *ft)
|
1070 |
|
|
{
|
1071 |
|
|
std::pair<const double,MG_FRONT_2D*> tmp(ft->get_segment()->get_longueur(),ft);
|
1072 |
|
|
front.insert(tmp);
|
1073 |
|
|
}
|
1074 |
|
|
|
1075 |
|
|
MG_FRONT_2D* MAILLEUR2D::get_front(FRONT& front,unsigned int num)
|
1076 |
|
|
{
|
1077 |
|
|
FRONT::iterator i=front.begin();
|
1078 |
|
|
for (unsigned long j=0;j<num;j++) i++;
|
1079 |
|
|
return ((*i).second);
|
1080 |
|
|
}
|
1081 |
|
|
|
1082 |
|
|
|
1083 |
|
|
unsigned int MAILLEUR2D::get_nb_front(FRONT& front)
|
1084 |
|
|
{
|
1085 |
|
|
return front.size();
|
1086 |
|
|
}
|
1087 |
|
|
|
1088 |
|
|
|
1089 |
|
|
MG_FRONT_2D * MAILLEUR2D::trouver_front(MG_NOEUD * no1, MG_NOEUD * no2)
|
1090 |
|
|
{
|
1091 |
|
|
FRONT::iterator j;
|
1092 |
|
|
MG_FRONT_2D *ft = 0;
|
1093 |
|
|
for (j=front_courant.begin(); j!=front_courant.end(); j++)
|
1094 |
|
|
{
|
1095 |
|
|
MG_FRONT_2D * ftj = j->second;
|
1096 |
|
|
if ( ftj->get_noeud1() == no1 && ftj->get_noeud2() == no2 )
|
1097 |
|
|
{
|
1098 |
|
|
ft = ftj;
|
1099 |
|
|
break;
|
1100 |
|
|
}
|
1101 |
|
|
}
|
1102 |
|
|
if (ft == 0)
|
1103 |
|
|
for (j=front_attente.begin(); j!=front_attente.end(); j++)
|
1104 |
|
|
{
|
1105 |
|
|
MG_FRONT_2D * ftj = j->second;
|
1106 |
|
|
if ( ftj->get_noeud1() == no1 && ftj->get_noeud2() == no2 )
|
1107 |
|
|
{
|
1108 |
|
|
ft = ftj;
|
1109 |
|
|
break;
|
1110 |
|
|
}
|
1111 |
|
|
}
|
1112 |
|
|
return ft;
|
1113 |
|
|
}
|
1114 |
|
|
|
1115 |
|
|
void MAILLEUR2D::supprimer_front(MG_FRONT_2D* ft)
|
1116 |
|
|
{
|
1117 |
|
|
grille_de_front->supprimer(ft);
|
1118 |
|
|
|
1119 |
|
|
FRONT::iterator j=front_courant.lower_bound(ft->get_segment()->get_longueur());
|
1120 |
|
|
int ok=0;
|
1121 |
|
|
if (j==front_courant.end()) ok=2;
|
1122 |
|
|
while (ok==0&&(j!=front_courant.end()))
|
1123 |
|
|
{
|
1124 |
|
|
MG_FRONT_2D* fttmp=(*j).second;
|
1125 |
|
|
if (ft==fttmp) {ok=1;front_courant.erase(j);}
|
1126 |
|
|
if (fttmp->get_segment()->get_longueur()>ft->get_segment()->get_longueur()) ok=2;
|
1127 |
|
|
j++;
|
1128 |
|
|
}
|
1129 |
|
|
if (ok!=1)
|
1130 |
|
|
{
|
1131 |
|
|
j=front_attente.lower_bound(ft->get_segment()->get_longueur());
|
1132 |
|
|
while (ft!=(*j).second) j++;
|
1133 |
|
|
front_attente.erase(j);
|
1134 |
|
|
}
|
1135 |
|
|
|
1136 |
|
|
delete ft;
|
1137 |
|
|
}
|
1138 |
|
|
|
1139 |
|
|
void MAILLEUR2D::echange_de_front(FRONT& front_original,FRONT& front_destination,MG_FRONT_2D* ft)
|
1140 |
|
|
{
|
1141 |
|
|
FRONT::iterator j=front_original.lower_bound(ft->get_segment()->get_longueur());
|
1142 |
|
|
while (ft!=(*j).second) j++;
|
1143 |
|
|
front_original.erase(j);
|
1144 |
|
|
ajouter_front(front_destination,ft);
|
1145 |
|
|
}
|