40 std::vector<SQ_NOEUD*> lst_noeuds;
46 std::fgets(ligne,100,fichier_cg);
47 while((std::fgets(ligne,100,fichier_cg)!=
nullptr)&&(ligne[0]==
'v'))
49 std::sscanf(ligne,
"%c %lf %lf %lf",&c,&xx,&yy,&zz);
51 lst_noeuds.push_back(no_sq);
56 std::sscanf(ligne,
"%c %d %d",&c,&n1,&n2);
60 while((std::fgets(ligne,100,fichier_cg)!=
nullptr)&&(ligne[0]==
'e'));
61 std::fclose (fichier_cg);
76 LISTE_MG_NOEUD::iterator itNo;
82 for (
int i=0;i<nbvolume;i++)
86 for(
int i=0;i<LstNoND.
get_nb();i++)
90 for(
int j=0;j<nbseg;j++)
104 for (
int i=0;i<nbvolume;i++)
108 for (
int j=0;j<nbco;j++)
112 for (
int k=0;k<nbface;k++)
116 for (
int l=0;l<nbseg;l++)
133 std::multimap<double,double,std::less<double> > intersection;
149 vecteur_dir=directeur;
154 double ps1=n*directeur;
155 if (fabs(ps1)<1e-6) i++;
159 intersection.clear();
160 for (
int j=0;j<lsttrifront[numvol].
get_nb();j++)
173 std::pair<double,double> tmp(t,t);
174 intersection.insert(tmp);
180 std::multimap<double,double,std::less <double> >::iterator it=intersection.begin();
183 while (it!=intersection.end())
187 double t=(*it).second;
194 if (nbinterneg%2==1)
return 1;
210 double eps=0.333333333333*(g1.
diff()+g2.
diff()+g3.
diff());
217 double eps2=0.333333333333*(g1.
diff()+g2.
diff()+g3b.
diff());
218 eps2=18.*eps2*eps2*eps2*1e-6;
241 double alpha1=n1n4*g1b;
242 double alpha2=n1n4*g2b;
243 double alpha3=-(n1n4*g3b);
244 double alpha4=1-alpha1-alpha2;
246 if ((alpha1>-eps) && (alpha1<1.+eps))
247 if ((alpha2>-eps) && (alpha2<1.+eps))
248 if ((alpha4>-eps) && (alpha4<1.+eps)) {
261 LISTE_MG_NOEUD::iterator ItLstNo;
266 std::vector<std::vector<MG_NOEUD*>> LstContour;
276 std::vector<MG_NOEUD*> Contour;
277 Contour.push_back(no);
279 LstContour.push_back(Contour);
292 for(
int i=0;i<LstContour.size();i++)
307 std::vector<MG_NOEUD*> Section;
308 for(
int j=0;j<LstContour[i].size();j++)
312 Section.push_back(no_sec);
320 for(
int i=0;i<LstNoExtr.
get_nb();i++)
322 double dist_min=std::numeric_limits<double>::max();
323 for(
int j=0;j<LstNoCntr.
get_nb();j++)
326 if(dist_min>
V.get_longueur())
328 dist_min=
V.get_longueur();
338 for(
int i=0;i<LstNoCntr.
get_nb();i++)
340 double dist_min=std::numeric_limits< double >::max();
345 if((no!=LstNoCntr.
get(i))&&(dist_min>
V.get_longueur()))
347 dist_min=
V.get_longueur();
361 LISTE_MG_NOEUD::iterator ItLstNo;
363 LISTE_MG_SEGMENT::iterator ItLstSeg;
365 LISTE_MG_TRIANGLE::iterator ItLstTri;
367 double max=std::numeric_limits<double>::max();
383 BOITE_3D boite(xmin,ymin,zmin,xmax,ymax,zmax);
405 while(no_suivant!=Contour->front())
414 Contour->push_back(no_suivant);
415 LstNoInter->
ajouter(no_suivant);
433 for(
int i=0;i<Contour->size();i++)
440 C[0]/=Contour->size();
441 C[1]/=Contour->size();
442 C[2]/=Contour->size();
455 LISTE_MG_NOEUD::iterator ItLstNo;
456 std::vector<SQ_NOEUD*> branche;
462 for(
int i=0;i<LstNoExtr.
get_nb();i++)
464 no_extr=LstNoExtr.
get(i);
468 branche.push_back(no_sq);
473 branche.push_back(no_sq);
474 no_precedent=no_extr;
483 if(no_suivant!=no_precedent)
486 branche.push_back(no_sq);
493 bool enregistree=
false;
496 if(((branche.front()==
LstBranches[k]->get_branche().back())&&(branche.back()==
LstBranches[k]->get_branche().front()))||
497 ((branche.front()==
LstBranches[k]->get_branche().front())&&(branche.back()==
LstBranches[k]->get_branche().back())))
499 if(enregistree==
false)
501 if(branche.back()->get_nb_reference()==1)
503 double dist_min=std::numeric_limits<double>::max();
509 std::vector<MG_NOEUD*> section=
LstBranches[k]->get_section(0);
512 if(dist_min>
V.get_longueur())
514 dist_min=
V.get_longueur();
540 std::vector<SQ_NOEUD*> branche=Bran->
get_branche();
541 for(
int j=1;j<branche.size()-1;j++)
543 OT_VECTEUR_3D v1(branche[j-1]->get_coord(),branche[j]->get_coord());
544 OT_VECTEUR_3D v2(branche[j]->get_coord(),branche[j+1]->get_coord());
547 branche[j]->change_normal_section(n);
555 std::vector<std::pair<int,SQ_NOEUD*>> LstPosSections;
556 std::map<unsigned long,double> MapNoJonc;
557 std::map<unsigned long,double>::iterator ItMap;
558 std::vector<MG_NOEUD*> section;
559 std::vector<SQ_NOEUD*> branche;
582 if((branche.front()->get_nb_reference()!=1)&&(MapNoJonc[branche.front()->get_id()]<Rmoy))
583 MapNoJonc[branche.front()->get_id()]=Rmoy;
584 if((branche.back()->get_nb_reference()!=1)&&(MapNoJonc[branche.back()->get_id()]<Rmoy))
585 MapNoJonc[branche.back()->get_id()]=Rmoy;
597 (
LstBranches[i]->get_branche().front()->get_nb_reference()==1)||
598 (
LstBranches[i]->get_branche().back()->get_nb_reference()==1))
613 if(branche.front()->get_nb_reference()!=1)
615 for(ItMap=MapNoJonc.begin();ItMap!=MapNoJonc.end();ItMap++)
616 if((*ItMap).first==branche.front()->get_id())
618 Rmoy1=(*ItMap).second;
621 for(
int j=0;j<branche.size()/2;j++)
622 if(j==branche.size()/2-1)
623 LstPosSections.push_back(std::make_pair(i,branche[j]));
626 OT_VECTEUR_3D V(branche[j]->get_coord(),branche[j+1]->get_coord());
627 dist1+=
V.get_longueur();
628 if(dist1>param_dist*Rmoy1)
630 LstPosSections.push_back(std::make_pair(i,branche[j+1]));
636 if(branche.back()->get_nb_reference()!=1)
638 for(ItMap=MapNoJonc.begin();ItMap!=MapNoJonc.end();ItMap++)
639 if((*ItMap).first==branche.back()->get_id())
641 Rmoy2=(*ItMap).second;
644 for(
int j=branche.size()-1;j>branche.size()/2-1;j--)
645 if(j==branche.size()/2)
646 LstPosSections.push_back(std::make_pair(i,branche[j+branche.size()%2]));
649 OT_VECTEUR_3D V(branche[j-1]->get_coord(),branche[j]->get_coord());
650 dist2+=
V.get_longueur();
652 if(dist2>param_dist*Rmoy2)
654 LstPosSections.push_back(std::make_pair(i,branche[j-1]));
663 double param_voisinage=6.;
664 for(
int i=0;i<LstPosSections.size();i++)
667 GrilleSeg.
rechercher(LstPosSections[i].second->get_x(),LstPosSections[i].second->get_y(),LstPosSections[i].second->get_z(),param_voisinage*
LstBranches[LstPosSections[i].first]->get_rayon_max(),MapSeg);
668 calcul_section(&MapSeg,LstPosSections[i].second->get_coord(),LstPosSections[i].second->get_normal_section().get_xyz(),eps,§ion);
669 LstBranches[LstPosSections[i].first]->ajouter_section(LstPosSections[i].second,section);
671 double Rmax=
rayon_max(§ion,LstPosSections[i].second);
672 if(Rmax>
LstBranches[LstPosSections[i].first]->get_rayon_max())
LstBranches[LstPosSections[i].first]->change_rayon_max(Rmax);
680 std::vector<SQ_NOEUD*> Branche=
LstBranches[i]->get_branche();
681 std::vector<SQ_NOEUD*> BranGuide;
684 for(
int j=0;j<Branche.size();j++)
688 BranGuide.push_back(Branche[j]);
693 BranGuide.push_back(Branche[j]);
697 BranGuide.push_back(Branche[j]);
699 if(BranGuide.size()<4)
LstBranches[i]->change_validite(
false);
710 std::vector<SQ_NOEUD*> Branche=Bran->
get_branche();
715 for(
int i=1;i<Branche.size()-1;i++)
717 OT_VECTEUR_3D vec1(Branche[i]->get_coord(),Branche[i-1]->get_coord());
718 OT_VECTEUR_3D vec2(Branche[i]->get_coord(),Branche[i+1]->get_coord());
720 if(angle<angle_seuil)
722 double x_i=Branche[i]->
get_x(), x_i_prec=Branche[i-1]->get_x(), x_i_suiv=Branche[i+1]->get_x();
723 double y_i=Branche[i]->get_y(), y_i_prec=Branche[i-1]->get_y(), y_i_suiv=Branche[i+1]->get_y();
724 double z_i=Branche[i]->get_z(), z_i_prec=Branche[i-1]->get_z(), z_i_suiv=Branche[i+1]->get_z();
726 double delta_x=0.5*(x_i_prec+x_i_suiv)-x_i;
727 double delta_y=0.5*(y_i_prec+y_i_suiv)-y_i;
728 double delta_z=0.5*(z_i_prec+z_i_suiv)-z_i;
730 double x_i_prime=x_i+lambda*delta_x;
731 double y_i_prime=y_i+lambda*delta_y;
732 double z_i_prime=z_i+lambda*delta_z;
734 Branche[i]->change_x(x_i_prime);
735 Branche[i]->change_y(y_i_prime);
736 Branche[i]->change_z(z_i_prime);
748 std::vector<MG_NOEUD*> section;
750 double theta=2*M_PI/NbPtsInterp;
755 for(
int j=0;j<PosSecs.size();j++)
756 if(PosSecs[j]->get_nb_reference()!=1)
759 LISTE_MG_TRIANGLE::iterator it_lst_tri;
763 for(
int k=0;k<NbPtsInterp;k++)
766 if(no_prj!=no_sq) section.push_back(no_prj);
776 std::vector<MG_NOEUD*> section0=
LstBranches[i]->get_section(0);
781 for(
int k=0;k<NbPtsInterp;k++)
784 std::vector<MG_NOEUD*> LstNoInter;
787 for(
int l=0;l<section0.size();l++)
791 if(l<section0.size()-1) P1=
OT_VECTEUR_3D(section0[l+1]->get_coord());
797 LstNoInter.push_back(no);
800 if(section.size()==0)
801 section.push_back(LstNoInter[0]);
809 section.push_back(LstNoInter[0]);
810 else section.push_back(LstNoInter[1]);
844 double min=std::numeric_limits<double>::max();
846 for(
int i=1;i<branche->size()-1;i++)
853 OT_VECTEUR_3D V((*branche)[j]->get_coord(),(*branche)[j+1]->get_coord());
854 dist1+=
V.get_longueur();
856 for(
int j=i;j<branche->size()-1;j++)
858 OT_VECTEUR_3D V((*branche)[j]->get_coord(),(*branche)[j+1]->get_coord());
859 dist2+=
V.get_longueur();
861 if(min>fabs(dist1-dist2))
863 min=fabs(dist1-dist2);
864 no_sq_milieu=(*branche)[i];
875 for(
int i=0;i<section->size();i++)
878 Rmoy+=
V.get_longueur();
880 Rmoy/=section->size();
889 for(
int i=0;i<section->size();i++)
892 if(Rmax<
V.get_longueur()) Rmax=
V.get_longueur();
902 LISTE_MG_SEGMENT::iterator ItLstSeg;
903 std::vector<std::pair<MG_NOEUD*,std::pair<long unsigned int,long unsigned int>>> LstNo;
923 double Rmin=std::numeric_limits< double >::max();
926 for(
int i=0;i<LstNo.size();i++)
937 std::pair<MG_NOEUD*,std::pair<long unsigned int,long unsigned int>> No_debut;
938 std::pair<MG_NOEUD*,std::pair<long unsigned int,long unsigned int>> No;
942 section->push_back(LstNo[ii].first);
947 for(
int i=0;i<LstNo.size();i++)
949 if((LstNo[i].first->get_origine()!=
MAGIC::ORIGINE::SECTION)&&((No.second.first==LstNo[i].second.first)||(No.second.first==LstNo[i].second.second)||(No.second.second==LstNo[i].second.first)||(No.second.second==LstNo[i].second.second)))
951 section->push_back(LstNo[i].first);
957 if(LstNo[i]==LstNo.back())
962 if(i==LstNo.size()-1)
976 std::vector<SQ_NOEUD*> PosSecs;
978 PosSecs.push_back(BranGuide.front());
982 if(NbSecs<3) PosSecs.push_back(BranGuide.back());
986 for(
int i=0;i<BranGuide.size()-1;i++)
988 OT_VECTEUR_3D V(BranGuide[i]->get_coord(),BranGuide[i+1]->get_coord());
989 Longueur+=
V.get_longueur();
992 for(
int i=0;i<NbSecs-2;i++)
997 OT_VECTEUR_3D V(BranGuide[j]->get_coord(),BranGuide[j+1]->get_coord());
998 dist+=
V.get_longueur();
1001 while(dist<Longueur/(NbSecs-1));
1002 PosSecs.push_back(BranGuide[j]);
1004 PosSecs.push_back(BranGuide.back());
1007 else PosSecs.push_back(BranGuide.back());
1015 std::vector<MG_NOEUD*> section;
1018 for(
int j=0;j<
LstBranches[i]->get_nb_sections();j++)
1021 for(
int k=0;k<section.size();k++)
1028 for(
int j=0;j<
LstBranches[i]->get_nb_sections();j++)
1031 for(
int k=0;k<section.size()-1;k++)
1046 std::vector<MG_NOEUD*> section;
1048 if((
LstBranches[i]->get_nb_sections2()>2)||((
LstBranches[i]->get_branche().back()->get_nb_reference()==1)))
1049 for(
int j=1;j<
LstBranches[i]->get_nb_sections2();j++)
1052 for(
int k=0;k<section.size();k++)
1055 if((
LstBranches[i]->get_branche().back()->get_nb_reference()!=1)&&(j==
LstBranches[i]->get_nb_sections2()-2))
break;
1059 if((
LstBranches[i]->get_nb_sections2()>2)||((
LstBranches[i]->get_branche().back()->get_nb_reference()==1)))
1060 for(
int j=1;j<
LstBranches[i]->get_nb_sections2();j++)
1063 for(
int k=0;k<section.size()-1;k++)
1070 if((
LstBranches[i]->get_branche().back()->get_nb_reference()!=1)&&(j==
LstBranches[i]->get_nb_sections2()-2))
break;
1081 LISTE_MG_TRIANGLE::iterator it_lst_tri;
1085 std::vector<SQ_NOEUD*> BranGuide=
LstBranches[i]->get_branche_guide();
1087 for(
int j=0;j<4;j++)
1089 std::vector<MG_NOEUD*> Guide;
1092 for(
int k=0;k<BranGuide.size();k++)
1100 if(no_prj!=no_sq) Guide.push_back(no_prj);
1108 if(no_prj!=no_sq) Guide.push_back(no_prj);
1113 if(BranGuide.back()->get_nb_reference()==1)
1114 for(
int k=0;k<Guide.size()-1;k++)
1118 Guide.erase(Guide.begin()+k+1,Guide.end());
1123 if(BranGuide.back()->get_nb_reference()==1)
1138 for(
int i=0;i<section->size();i++)
1139 for(
int j=0;j<section->size();j++)
1141 OT_VECTEUR_3D V((*section)[i]->get_coord(),(*section)[j]->get_coord());
1153 LISTE_MG_TRIANGLE::iterator ItLstTri;
1155 double t_min=std::numeric_limits<double>::max();
1160 if(t_min!=std::numeric_limits<double>::max())
1176 std::vector<SQ_NOEUD*> BranGuide=
LstBranches[i]->get_branche_guide();
1178 for(
int j=1;j<BranGuide.size();j++)
1180 OT_VECTEUR_3D seg(BranGuide[j-1]->get_coord(),BranGuide[j]->get_coord());
1183 algo.
Intr3D_Plane_Plane(norm1.
get_xyz(),BranGuide[j-1]->get_coord(),BranGuide[j]->get_normal_section().get_xyz(),BranGuide[j]->get_coord(),u);
1186 BranGuide[j]->change_dir(dir);
1194 #define EPS_BASE_RELATIVE 1e-14
1197 if((noeud4==noeud1)||(noeud4==noeud2)||(noeud4==noeud3)) nb_commun++;
1198 if((noeud5==noeud1)||(noeud5==noeud2)||(noeud5==noeud3)) nb_commun++;
1199 if(nb_commun==2)
return(
false);
1207 double eps=0.333333333333*(g1.
diff()+g2.
diff()+g3.
diff());
1214 double eps2=0.333333333333*(g1.
diff()+g2.
diff()+g3b.
diff());
1226 if ((noeud4==noeud1)||(noeud4==noeud2)||(noeud4==noeud3))
return false;
1227 if ((noeud5==noeud1)||(noeud5==noeud2)||(noeud5==noeud3))
return false;
1242 double alpha1=n1n4*g1b;
1243 double alpha2=n1n4*g2b;
1244 double alpha3=-(n1n4*g3b);
1245 double alpha4=1-alpha1-alpha2;
1248 if((alpha1>-eps)&&(alpha1<1.+eps))
1249 if((alpha2>-eps)&&(alpha2<1.+eps))
1250 if((alpha3>-eps)&&(alpha3<1.+eps))
1251 if((alpha4>-eps) && (alpha4<1.+eps))
return true;
1294 if(((AC*AD>ZERO)||(AC*AD==ZERO))&&((AC*u<ZERO)||(AC*u==ZERO)))
return 0;
1295 else if(((BC*BD>ZERO)||(BC*BD==ZERO))&&((BC*u>ZERO)||(BC*u==ZERO)))
return 0;
1317 t2=t2/(a1*v.
get_x()+b1*v.get_y()+c1*v.get_z());
1322 if((t1>ZERO)&&(t1<UN)&&(t2>ZERO)&&(t2<UN))
return 1;
1335 std::vector<SQ_NOEUD*> branche=
LstBranches[num_bran]->get_branche();
1336 OT_VECTEUR_3D V=branche.back()->get_normal_section()&branche.back()->get_dir();
1337 std::vector<MG_NOEUD*> section=
LstBranches[num_bran]->get_section(0);
1338 std::vector<MG_NOEUD*> LstNoInter;
1342 for(
int k=0;k<section.size()-1;k++)
1350 LstNoInter.push_back(no);
1354 double Lmin=std::numeric_limits<double>::max();
1355 for(
int k=0;k<LstNoInter.size();k++)
1357 OT_VECTEUR_3D L(guide->back()->get_coord(),LstNoInter[k]->get_coord());
1364 guide->push_back(no);
1371 std::vector<MG_NOEUD*> guide;
1373 for(
int j=0;j<
LstBranches[i]->get_nb_guides();j++)
1376 for(
int k=0;k<guide.size();k++)
1381 for(
int j=0;j<
LstBranches[i]->get_nb_guides();j++)
1384 for(
int k=0;k<guide.size()-1;k++)
1398 std::vector<SQ_NOEUD*> LstNoJonc;
1399 LISTE_MG_NOEUD::iterator ItLstNo;
1407 for(
int i=0;i<LstNoJonc.size();i++)
1409 no_jonc=LstNoJonc[i];
1414 std::vector<SQ_NOEUD*> branche;
1416 if(branche.front()==no_jonc)
1421 if(branche.back()==no_jonc)
1436 std::vector<SQ_NOEUD*> BranGuide=
LstJonctions[i]->get_branche(j)->get_branche_guide();
1440 else no_central=BranGuide.back();
1447 for(
int j=0;j<
LstJonctions[i]->get_nb_interfaces();j++)
1448 for(
int k=j+1;k<
LstJonctions[i]->get_nb_interfaces();k++)
1459 std::vector<MG_NOEUD*> section;
1467 double dist=
V.get_longueur();
1468 if(dist>DistMax) DistMax=dist;
1478 LISTE_MG_TRIANGLE::iterator it_lst_tri;
1485 for(
int l=0;l<NbPtsInterp;l++)
1488 if(no_prj!=no_sq) section.push_back(no_prj);
1489 if(l!=NbPtsInterp-1)
1506 double Coord1[3]={0};
1517 Coord1[0]=(Coord1[0]+NoJonc->
get_x())/2;
1518 Coord1[1]=(Coord1[1]+NoJonc->
get_y())/2;
1519 Coord1[2]=(Coord1[2]+NoJonc->
get_z())/2;
1557 Coord2[0]=(no_prj1->
get_x()+no_prj2->
get_x())/2.;
1558 Coord2[1]=(no_prj1->
get_y()+no_prj2->
get_y())/2.;
1559 Coord2[2]=(no_prj1->
get_z()+no_prj2->
get_z())/2.;
1566 double dist_min1=std::numeric_limits<double>::max();
1568 std::vector<MG_NOEUD*> SecInit;
1573 if(
V.get_longueur()<dist_min1)
1575 dist_min1=
V.get_longueur();
1582 double dist_min2=std::numeric_limits<double>::max();
1583 std::vector<MG_NOEUD*> SecFin;
1588 if(
V.get_longueur()<dist_min2)
1590 dist_min2=
V.get_longueur();
1610 double phi=(theta*M_PI/180.)/(NbPtsInterp-1);
1611 std::vector<MG_NOEUD*> SecInter;
1612 for(
int k=0;k<NbPtsInterp;k++)
1615 if(no_prj!=no_ctr) SecInter.push_back(no_prj);
1616 if(k!=NbPtsInterp-1)
1631 std::vector<MG_NOEUD*> section;
1634 for(
int j=0;j<
LstJonctions[i]->get_nb_interfaces();j++)
1640 for(
int l=0;l<section.size();l++)
1656 section=
LstJonctions[i]->get_raccord(j)->get_section_intermediaire();
1657 for(
int k=0;k<section.size();k++)
1663 for(
int j=0;j<
LstJonctions[i]->get_nb_interfaces();j++)
1669 for(
int l=0;l<section.size()-1;l++)
1690 section=
LstJonctions[i]->get_raccord(j)->get_section_intermediaire();
1691 for(
int k=0;k<section.size()-1;k++)
1704 std::vector<OT_VECTEUR_3D> LstProj;
1730 LstProj.push_back(Dir2);
1735 double* PP=
new double[3];
1741 if(LstProj.size()==2)
1769 exp.
gmsh(seg_selec,
"voisinage_seg");
1806 exp.
gmsh(tri_selec,
"voisinage_tri");