73 char filename1[5000] =
"";
74 strcpy(filename1,getenv(
"TEMP"));
75 strcat(filename1,
"/CAD4FE_log.txt");
76 _logFile.open( filename1, ios::app );
83 char filename1[5000] =
"";
84 strcpy(filename1,getenv(
"TEMP"));
85 strcat(filename1,
"/CAD4FE_log.txt");
87 _logFile <<
"Fichier de log de CAD4FE" << std::endl;
106 char filename1[5000];
107 strcpy(filename1,getenv(
"TEMP"));
108 strcat(filename1,
"/void_2D.mai");
109 ofstream o4(filename1,ios::out|ios::trunc);
111 o4.setf(ios::showpoint);
115 char filename2[5000];
116 strcpy(filename2,getenv(
"TEMP"));
117 strcat(filename2,
"/CAD4FE_Mesher.iv");
118 file.open(filename2);
126 file << ivTextRefTess.
GetText();
133 char filename2[5000];
134 strcpy(filename2,getenv(
"TEMP"));
135 strcat(filename2,
"/CAD4FE_Mesher_MCSegments.iv");
136 file.open(filename2);
146 file <<
"DrawStyle {\nstyle LINES\nlineWidth 2\npointSize 3\n}\n";
147 LISTE_MG_SEGMENT::iterator itSegment;
150 if (seg->get_lien_topologie()->get_dimension() == 1)
151 file <<
"BaseColor { \n rgb 0.0 0.0 0.9\n }\n";
152 if (seg->get_lien_topologie()->get_dimension() == 2)
153 file <<
"BaseColor { \n rgb 0.0 0.0 0.0\n }\n";
189 std::string filename =
"/tmp/CAD4FE_MCFace";
192 std::ofstream out(filename.c_str());
193 float sleepTime = .1;
195 out <<
"sleepTime " << sleepTime<<
" \n";
196 out <<
"groupTriang 5 \n";
198 std::set <MG_ARETE*> lst_mg_edges;
199 std::set <MG_SOMMET*> lst_mg_vertices;
201 for (
unsigned it_loop = 0; it_loop < nb_loop; it_loop++)
206 for (
unsigned it_edge = 0; it_edge < nb_edge; it_edge++)
209 lst_mg_edges.insert(edge);
216 LISTE_MG_TRIANGLE::iterator itTriang;
217 std::set <MG_NOEUD*>lst_mg_noeud;
220 if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2
224 MG_NOEUD * nos[3]={triangle->get_noeud1(),triangle->get_noeud2(),triangle->get_noeud3()};
225 for (
int i=0; i<3; i++)
228 if (lst_mg_noeud.find(no) == lst_mg_noeud.end())
230 lst_mg_noeud.insert(no);
231 out <<
"add coord " << no->
get_id() ;
232 out <<
" " << no->
get_x();
233 out <<
" " << no->
get_y() ;
234 out <<
" " << no->
get_z() <<
" \n";
239 LISTE_MG_NOEUD::iterator itNo;
243 if (lst_mg_noeud.find(no) == lst_mg_noeud.end())
245 if (no->get_lien_topologie() != NULL && no->get_lien_topologie()->get_dimension() == 0
246 && lst_mg_vertices.find((
MG_SOMMET*)no->get_lien_topologie()) != lst_mg_vertices.end())
247 out <<
"add node " << no->get_id()<<
" \n";
252 LISTE_MG_SEGMENT::iterator itSegment;
255 if (seg->get_lien_topologie() == NULL || seg->get_lien_topologie()->get_dimension() != 1 ||
256 lst_mg_edges.find((
MG_ARETE*)seg->get_lien_topologie()) == lst_mg_edges.end())
258 out <<
"add segment " << seg->get_id() <<
" ";
259 out << seg->get_noeud1()->get_id() <<
" ";
260 out << seg->get_noeud2()->get_id() <<
" \n";
265 if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2
268 out <<
"add triangle " << triangle->get_id() <<
" ";
269 out << triangle->get_noeud1()->get_id() <<
" ";
270 out << triangle->get_noeud3()->get_id() <<
" ";
271 out << triangle->get_noeud2()->get_id() <<
" \n";
351 std::ofstream out(
"/tmp/CAD4FE.ivanim");
352 float sleepTime = .1;
354 out <<
"sleepTime " << sleepTime<<
" \n";
355 out <<
"groupTriang 5 \n";
357 std::map < MG_NOEUD * , unsigned int > indices;
358 LISTE_MG_NOEUD::iterator itNo;
362 out <<
"add coord " << no->get_id() ;
363 out <<
" " << no->get_x();
364 out <<
" " << no->get_y() ;
365 out <<
" " << no->get_z() <<
" \n";
366 if (no->get_lien_topologie() != NULL && no->get_lien_topologie()->get_dimension() == 0)
367 out <<
"add node " << no->get_id()<<
" \n";
370 LISTE_MG_SEGMENT::iterator itSegment;
373 if (seg->get_lien_topologie() == NULL || seg->get_lien_topologie()->get_dimension() != 1)
375 out <<
"add segment " << seg->get_id() <<
" ";
376 out << seg->get_noeud1()->get_id() <<
" ";
377 out << seg->get_noeud2()->get_id() <<
" \n";
380 LISTE_MG_TRIANGLE::iterator itTriang;
383 if (triangle->get_lien_topologie() == NULL || triangle->get_lien_topologie()->get_dimension() > 2)
385 out <<
"add triangle " << triangle->get_id() <<
" ";
386 out << triangle->get_noeud1()->get_id() <<
" ";
387 out << triangle->get_noeud3()->get_id() <<
" ";
388 out << triangle->get_noeud2()->get_id() <<
" \n";
397 for (
int i=0;i<nb_boucle;i++)
401 for (
int j=0;j<nb_coarete;j++)
406 for (
int k=0;k<nb_segment;k++)
411 if (mgsegtemp==NULL)
continue;
431 double bounding_box[6]={1E308,1E308,1E308,-1E308,-1E308,-1E308};
441 for (
unsigned int i=0; i<3; i++)
443 for (
unsigned int j=0; j<3; j++)
445 if (n[i]->get_coord()[j] < bounding_box[j])
446 bounding_box[j] = n[i]->get_coord()[j];
447 if (n[i]->get_coord()[j] > bounding_box[j+3])
448 bounding_box[j+3] = n[i]->get_coord()[j];
453 double xyz_taille [3];
454 for (
unsigned int i=0; i<3; i++)
455 xyz_taille[i] = (bounding_box[i]+bounding_box[i+3])*.5;
458 double density_tensor[9];
460 taille = pow(density_tensor[0],-0.5);
463 for (
unsigned i = 0; i < 3; i++)
465 double taille_cellule = taille;
467 if ( taille_cellule != 0 )
468 nb_cellule[i] = (bounding_box[i+3]-bounding_box[i])/taille_cellule;
472 if (nb_cellule[i] == 0)
476 const double NB_MAX_CELL = 20000000;
477 double alpha = NB_MAX_CELL / (nb_cellule[0]*nb_cellule[1]*nb_cellule[2]);
480 for (
unsigned i = 0; i < 3; i++)
482 nb_cellule[i] = (int)((
double)nb_cellule[i])*pow(alpha,.33);
483 if ( nb_cellule[i] == 0 )
486 printf(
"Nb cells = %d\n", nb_cellule[0]*nb_cellule[1]*nb_cellule[2]);
490 for (
int i=0; i<3; i++)
491 bounding_box[i] -= taille*1.0;
492 for (
int i=0; i<3; i++)
493 bounding_box[i+3] += taille*1.0;
496 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]);
498 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]);
500 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]);
505 std::set<MCVertex*> isolatedInteriorVertices;
508 for (
int iboucle=0;iboucle<nb_boucle;iboucle++)
522 if (noeudtemp==NULL) numnoeud++;
else bon_noeud=1;
525 MCNode* noeud_courant=noeud_de_depart;
528 unsigned int nbcoaretetraite=0;
530 if (nbcoaretetotale == 1 )
552 if (noeudtemp==NULL) numnoeud++;
else bon_noeud=1;
555 segment_courant=NULL;
556 int passe_aretefermee=0;
570 if ((mgsegment->
get_noeud1()==noeud_courant) || (mgsegment->
get_noeud2()==noeud_courant)) mgsegment_depart1=mgsegment;
573 while (mgsegment_depart1==NULL);
576 if ((mgsegment->
get_noeud1()==noeud_courant) || (mgsegment->
get_noeud2()==noeud_courant)) mgsegment_depart2=mgsegment;
579 while (mgsegment_depart2==NULL);
589 if (vecteur1*tangeante>0.)
591 mgsegment=mgsegment_depart1;
592 noeud_suivant=noeud1_2;
596 mgsegment=mgsegment_depart2;
597 noeud_suivant=noeud2_2;
603 front_precedent=front;
604 noeud_courant=noeud_suivant;
605 segment_courant=mgsegment;
615 if (mgsegment!=segment_courant)
626 front_precedent=front;
627 noeud_courant=noeud_suivant;
635 while (noeud_courant!=noeud_d_arrivee);
639 if (nbcoaretetraite != nbcoaretetotale)
651 std::map <MG_SEGMENT *, std::vector < MG_FRONT_2D *> > map_segment_fronts;
652 std::map <MG_SEGMENT *, std::vector < MG_FRONT_2D *> >::iterator it_map_segment_fronts;
657 it_map_segment_fronts = map_segment_fronts.find(seg);
658 if (it_map_segment_fronts == map_segment_fronts.end())
660 std::vector< MG_FRONT_2D *> tmp;
662 map_segment_fronts[seg] = tmp;
666 std::vector< MG_FRONT_2D *> & tmp = it_map_segment_fronts->second;
671 for (it_map_segment_fronts = map_segment_fronts.begin(); it_map_segment_fronts != map_segment_fronts.end(); it_map_segment_fronts++)
673 std::vector< MG_FRONT_2D *> & lst_front = it_map_segment_fronts->second;
674 if (lst_front.size() > 1)
675 for (
unsigned j=0; j<lst_front.size(); j++)
687 std::ostringstream out;
688 out <<
"Initializing front of mc face " << __mcFace->
get_id();
691 for (std::set<MCVertex*>::iterator itV = __isolatedInteriorVertices.begin();
692 itV != __isolatedInteriorVertices.end();
700 if (elem->get_type_entite()==
IDMCNODE)
704 int solution =
genere_noeud(__mcFace, mcNode, &front_rencontre, &noeud_solution);
737 int nbpas_compteur=2;
739 int compteur_min_oiv1=0;
740 int compteur_min_oiv2=32768;
742 clock_t compteur_temps, compteur_temps2;
743 compteur_temps = clock();
750 compteur_temps2 = clock();
751 if (compteur_temps2-compteur_temps > CLOCKS_PER_SEC*.1)
755 file <<
" id = " << __mcFace->
get_id()<<
" ";
756 file <<
"nb triangles = "<<
_nbTriangles[__mcFace]<<
" ";
760 compteur_temps = compteur_temps2;
765 std::ostringstream out;
766 out << std::endl <<
"progresse_front: iteration compteur # " << compteur;
774 std::set < MG_FRONT_2D * > visited;
775 unsigned cpt_front=0;
780 if (
id == 60101 ||
id==60099)
781 printf(
"* %d *, ",
id);
784 fc = fc->get_front_suivant();
785 if (visited.find(fc) != visited.end())
786 for (std::multimap<double,MG_FRONT_2D*>::iterator itFr=
front_courant.begin();
789 if ( visited.find(itFr->second) == visited.end())
802 ofstream o4(
"c:\\temp\\void_2D.mai",ios::out|ios::trunc);
804 o4.setf(ios::showpoint);
810 char filename2[5000];
811 sprintf(filename2,
"%s/CAD4FE_Mesher_%d.iv",getenv(
"TEMP"),
_nbTriangles[__mcFace]);
812 std::ofstream file(filename2);
820 file << ivTextRefTess.
GetText();
828 if ( compteur == 122458 )
830 char filename2[5000];
831 strcpy(filename2,getenv(
"TEMP"));
832 strcat(filename2,
"/CAD4FE_Mesher_MCSegments.iv");
833 std::ofstream file(filename2);
844 file <<
"DrawStyle {\nstyle LINES\nlineWidth 2\npointSize 3\n}\n";
845 LISTE_MG_SEGMENT::iterator itSegment;
848 if (seg->get_lien_topologie()->get_dimension() == 2 && seg->get_lien_topologie() != __mcFace)
855 if (seg->get_lien_topologie()->get_dimension() == 1)
856 file <<
"BaseColor { \n rgb 0.0 0.0 0.9\n }\n";
857 if (seg->get_lien_topologie()->get_dimension() == 2)
858 file <<
"BaseColor { \n rgb 0.0 0.0 0.0\n }\n";
871 bool ft_superpose =
false;
887 int ft_is_on_interior_edge = 0;
888 if (ft_dimension == 1)
903 double pcp=(-1)*(n1n2*pn1);
904 double psp=(-1)*(n*pn1);
906 if ((pcp>=0.1786481777)&&(psp>eps)) anglep=1;
else anglep=0;
911 double pcs=(-1.)*(n1n2*n2s);
914 if ((pcs>=0.1786481777)&&(pss>eps)) angles=1;
else angles=0;
915 int type_cas_front[10];
934 if (!type_cas_front[solution]) solution=
traite_front(solution,__mcFace,ftp,ft,fts);
else solution=
PASTROUVE;
937 if (ft_superpose ==
false)
948 file <<
" id = " << __mcFace->
get_id()<<
" ";
949 file <<
"nb triangles = "<<
_nbTriangles[__mcFace]<<
" ";
968 LISTE_MG_TRIANGLE::iterator itTri;
971 double qual=
OPERATEUR::qualite_triangle(mtri->get_noeud1()->get_coord(),mtri->get_noeud2()->get_coord(),mtri->get_noeud3()->get_coord());
972 mtri->change_qualite(qual);
973 lst_tri_qual.insert(std::make_pair(mtri->get_qualite(),mtri));
979 double expected_quality = 0.5;
981 std::set<MCSegment *> lstSegToUpdate;
982 for (
int phase=0;phase<2;phase++)
989 for (ORDRE_TRIANGLE::iterator itTriang=lst.begin(); itTriang!=lst.end(); itTriang++)
999 MCNode *noeud_optimal[3]={0,0,0};
1000 int ierr=
bouge_point(__mcFace,no[0],crit[0],&(noeud_optimal[0]));
1001 if (ierr==0) crit[0]=0.;
1002 ierr=
bouge_point(__mcFace,no[1],crit[1],&(noeud_optimal[1]));
1003 if (ierr==0) crit[1]=0.;
1004 ierr=
bouge_point(__mcFace,no[2],crit[2],&(noeud_optimal[2]));
1005 if (ierr==0) crit[2]=0.;
1006 double critopt=std::max(crit[0],crit[1]);
1007 critopt=std::max(critopt,crit[2]);
1011 if (critopt==crit[0]) num=0;
1012 if (critopt==crit[1]) num=1;
1013 if (critopt==crit[2]) num=2;
1021 for (
int i=0;i<nb_seg;i++)
1024 for (
int i=0;i<nb_tri;i++)
1031 if (noeud_optimal[0])
delete noeud_optimal[0];
1032 if (noeud_optimal[1])
delete noeud_optimal[1];
1033 if (noeud_optimal[2])
delete noeud_optimal[2];
1035 if ((tri->
get_qualite()<expected_quality) && (phase==0))
1037 std::pair<const double,M3D_MCTriangle*> tmp(1./tri->
get_qualite(),tri);
1044 for (std::set<MCSegment*>::iterator itSeg=lstSegToUpdate.begin();
1045 itSeg!=lstSegToUpdate.end();
1070 FRONT::iterator i=front.begin();
1071 for (
unsigned long j=0;j<num;j++) i++;
1072 return ((*i).second);
1078 return front.size();
1086 double longueur = (x2-x1).get_longueur();
1087 FRONT::iterator j, jmin, jmax;
1091 for (j=jmin; j!=jmax; j++)
1104 for (j=jmin; j!=jmax; j++)
1148 FRONT::iterator javant=j;
1180 while (ft!=(*j).second) j++;
1189 while (ft!=(*j).second) j++;
1190 front_original.erase(j);