1 |
francois |
979 |
#include "polycristal.h"
|
2 |
|
|
#include "poly_voro.h"
|
3 |
|
|
#include "poly_build_occ.h"
|
4 |
|
|
#include "poly_point.h"
|
5 |
|
|
|
6 |
|
|
#include <stdio.h>
|
7 |
|
|
#include <random>
|
8 |
|
|
#include <vector>
|
9 |
|
|
|
10 |
francois |
1007 |
Polycristal::Polycristal(char* fichier,double dgval):POLY_AFFICHE(),nomfichier("resultat.brep"),dg(dgval)
|
11 |
francois |
979 |
{
|
12 |
|
|
FILE *input = fopen(fichier, "rt");
|
13 |
|
|
char chaine[500];
|
14 |
|
|
fgets(chaine, 500, input);
|
15 |
|
|
int nb_point, nTetra;
|
16 |
|
|
sscanf(chaine,"%d %d", &nb_point, &nTetra);
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
for (int i=0; i<nb_point; i++)
|
20 |
|
|
{
|
21 |
|
|
int num;
|
22 |
|
|
double x, y, z;
|
23 |
|
|
fgets(chaine,500,input);
|
24 |
|
|
sscanf(chaine, "%d %lf %lf %lf", &num, &x, &y, &z);
|
25 |
|
|
Poly_Point* pnt_xyz = new Poly_Point(x, y, z);
|
26 |
|
|
list_points.push_back(pnt_xyz);
|
27 |
|
|
}
|
28 |
|
|
fclose(input);
|
29 |
|
|
|
30 |
francois |
1007 |
|
31 |
|
|
|
32 |
francois |
979 |
}
|
33 |
|
|
|
34 |
|
|
|
35 |
francois |
1007 |
Polycristal::Polycristal(std::vector<double> &listepoint,std::string nom,double dgval):POLY_AFFICHE(),nomfichier(nom),dg(dgval)
|
36 |
francois |
979 |
{
|
37 |
francois |
983 |
int nb_point=listepoint.size()/3.;
|
38 |
|
|
for (int i=0; i<nb_point; i++)
|
39 |
|
|
{
|
40 |
|
|
Poly_Point* pnt_xyz = new Poly_Point(listepoint[3*i],listepoint[3*i+1],listepoint[3*i+2]);
|
41 |
|
|
list_points.push_back(pnt_xyz);
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
}
|
46 |
|
|
|
47 |
francois |
1007 |
Polycristal::Polycristal(int nbParticules,double dgval):POLY_AFFICHE(),nomfichier("resultat.brep"),dg(dgval)
|
48 |
francois |
983 |
{
|
49 |
francois |
1007 |
list_points = random_particules(nbParticules);
|
50 |
|
|
|
51 |
francois |
979 |
}
|
52 |
|
|
|
53 |
francois |
1007 |
|
54 |
|
|
void Polycristal::construit(bool avecstep)
|
55 |
|
|
{
|
56 |
|
|
Poly_Voro voro(list_points,dg);
|
57 |
|
|
if (affichageactif) voro.active_affichage(affiche2);
|
58 |
|
|
voro.construit();
|
59 |
|
|
voro.fusion_noeuds();
|
60 |
|
|
Poly_Build_OCC build_occ(&voro,nomfichier);
|
61 |
|
|
if (affichageactif) build_occ.active_affichage(affiche2);
|
62 |
|
|
build_occ.construit(avecstep);
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
Polycristal::Polycristal(Polycristal& mdd)
|
68 |
|
|
{
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
|
72 |
francois |
979 |
Polycristal::~Polycristal()
|
73 |
|
|
{
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
std::vector<Poly_Point*> Polycristal::random_particules(int nbParticules)
|
77 |
|
|
{
|
78 |
|
|
std::vector<Poly_Point*> list_points;
|
79 |
|
|
|
80 |
|
|
// Géométrie du conteneur rectangulaire
|
81 |
|
|
double x_min= 0.0, x_max= 1.0;
|
82 |
|
|
double y_min= 0.0, y_max= 1.0;
|
83 |
|
|
double z_min= 0.0, z_max= 1.0;
|
84 |
|
|
|
85 |
|
|
Poly_Point* pnt_1 = new Poly_Point(x_min, y_min, z_min);
|
86 |
|
|
Poly_Point* pnt_2 = new Poly_Point(x_min, y_max, z_min);
|
87 |
|
|
Poly_Point* pnt_3 = new Poly_Point(x_max, y_max, z_min);
|
88 |
|
|
Poly_Point* pnt_4 = new Poly_Point(x_max, y_min, z_min);
|
89 |
|
|
Poly_Point* pnt_5 = new Poly_Point(x_min, y_min, z_max);
|
90 |
|
|
Poly_Point* pnt_6 = new Poly_Point(x_min, y_max, z_max);
|
91 |
|
|
Poly_Point* pnt_7 = new Poly_Point(x_max, y_max, z_max);
|
92 |
|
|
Poly_Point* pnt_8 = new Poly_Point(x_max, y_min, z_max);
|
93 |
|
|
|
94 |
|
|
list_points.push_back(pnt_1);
|
95 |
|
|
list_points.push_back(pnt_2);
|
96 |
|
|
list_points.push_back(pnt_3);
|
97 |
|
|
list_points.push_back(pnt_4);
|
98 |
|
|
list_points.push_back(pnt_5);
|
99 |
|
|
list_points.push_back(pnt_6);
|
100 |
|
|
list_points.push_back(pnt_7);
|
101 |
|
|
list_points.push_back(pnt_8);
|
102 |
|
|
|
103 |
|
|
// Ajoute des particules le container avec une distribution aléatoire uniforme
|
104 |
|
|
std::random_device rd; // random number engine
|
105 |
|
|
std::mt19937 gen(rd());
|
106 |
|
|
std::uniform_real_distribution<> dis_x(x_min, x_max);
|
107 |
|
|
std::uniform_real_distribution<> dis_y(y_min, y_max);
|
108 |
|
|
std::uniform_real_distribution<> dis_z(z_min, z_max);
|
109 |
|
|
|
110 |
|
|
for(int i=0; i < nbParticules; i++) {
|
111 |
|
|
double x = dis_x(gen) ;
|
112 |
|
|
double y = dis_y(gen) ;
|
113 |
|
|
double z = dis_z(gen) ;
|
114 |
|
|
Poly_Point* pnt_xyz = new Poly_Point(x, y, z);
|
115 |
|
|
list_points.push_back(pnt_xyz);
|
116 |
|
|
}
|
117 |
|
|
return list_points;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
|