MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
polycristal.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// polycristal.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:54:00 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 #include "polycristal.h"
23 #include "poly_voro.h"
24 #include "poly_build_occ.h"
25 #include "poly_point.h"
26 
27 #include <stdio.h>
28 #include <random>
29 #include <vector>
30 
31 Polycristal::Polycristal(char* fichier,double dgval):POLY_AFFICHE(),nomfichier("resultat.brep"),dg(dgval)
32 {
33  FILE *input = fopen(fichier, "rt");
34  char chaine[500];
35  fgets(chaine, 500, input);
36  int nb_point, nTetra;
37  sscanf(chaine,"%d %d", &nb_point, &nTetra);
38 
39 
40  for (int i=0; i<nb_point; i++)
41  {
42  int num;
43  double x, y, z;
44  fgets(chaine,500,input);
45  sscanf(chaine, "%d %lf %lf %lf", &num, &x, &y, &z);
46  Poly_Point* pnt_xyz = new Poly_Point(x, y, z);
47  list_points.push_back(pnt_xyz);
48  }
49  fclose(input);
50 
51 
52 
53 }
54 
55 
56 Polycristal::Polycristal(std::vector<double> &listepoint,std::string nom,double dgval):POLY_AFFICHE(),nomfichier(nom),dg(dgval)
57 {
58  int nb_point=listepoint.size()/3.;
59  for (int i=0; i<nb_point; i++)
60  {
61  Poly_Point* pnt_xyz = new Poly_Point(listepoint[3*i],listepoint[3*i+1],listepoint[3*i+2]);
62  list_points.push_back(pnt_xyz);
63  }
64 
65 
66 }
67 
68 Polycristal::Polycristal(int nbParticules,double dgval):POLY_AFFICHE(),nomfichier("resultat.brep"),dg(dgval)
69 {
70  list_points = random_particules(nbParticules);
71 
72 }
73 
74 
75 void Polycristal::construit(bool avecstep)
76 {
77  Poly_Voro voro(list_points,dg);
79  voro.construit();
80  voro.fusion_noeuds();
81  Poly_Build_OCC build_occ(&voro,nomfichier);
83  build_occ.construit(avecstep);
84 }
85 
86 
87 
89 {
90 }
91 
92 
94 {
95 }
96 
97 std::vector<Poly_Point*> Polycristal::random_particules(int nbParticules)
98 {
99  std::vector<Poly_Point*> list_points;
100 
101  double x_min= 0.0, x_max= 1.0;
102  double y_min= 0.0, y_max= 1.0;
103  double z_min= 0.0, z_max= 1.0;
104 
105  Poly_Point* pnt_1 = new Poly_Point(x_min, y_min, z_min);
106  Poly_Point* pnt_2 = new Poly_Point(x_min, y_max, z_min);
107  Poly_Point* pnt_3 = new Poly_Point(x_max, y_max, z_min);
108  Poly_Point* pnt_4 = new Poly_Point(x_max, y_min, z_min);
109  Poly_Point* pnt_5 = new Poly_Point(x_min, y_min, z_max);
110  Poly_Point* pnt_6 = new Poly_Point(x_min, y_max, z_max);
111  Poly_Point* pnt_7 = new Poly_Point(x_max, y_max, z_max);
112  Poly_Point* pnt_8 = new Poly_Point(x_max, y_min, z_max);
113 
114  list_points.push_back(pnt_1);
115  list_points.push_back(pnt_2);
116  list_points.push_back(pnt_3);
117  list_points.push_back(pnt_4);
118  list_points.push_back(pnt_5);
119  list_points.push_back(pnt_6);
120  list_points.push_back(pnt_7);
121  list_points.push_back(pnt_8);
122 
123  std::random_device rd; // random number engine
124  std::mt19937 gen(rd());
125  std::uniform_real_distribution<> dis_x(x_min, x_max);
126  std::uniform_real_distribution<> dis_y(y_min, y_max);
127  std::uniform_real_distribution<> dis_z(z_min, z_max);
128 
129  for(int i=0; i < nbParticules; i++) {
130  double x = dis_x(gen) ;
131  double y = dis_y(gen) ;
132  double z = dis_z(gen) ;
133  Poly_Point* pnt_xyz = new Poly_Point(x, y, z);
134  list_points.push_back(pnt_xyz);
135  }
136  return list_points;
137 }
138 
139 
Polycristal::~Polycristal
~Polycristal()
Definition: polycristal.cpp:93
Poly_Build_OCC::construit
virtual void construit(bool avecstep=false)
Definition: poly_build_occ.cpp:54
POLY_AFFICHE::affichageactif
int affichageactif
Definition: poly_affiche.h:43
Polycristal::Polycristal
Polycristal(char *fichier, double dgval)
Definition: polycristal.cpp:31
Poly_Voro::fusion_noeuds
virtual void fusion_noeuds(void)
Definition: poly_voro.cpp:128
Poly_Voro::construit
virtual void construit(void)
Definition: poly_voro.cpp:41
Poly_Point
Definition: poly_point.h:25
Poly_Build_OCC
Definition: poly_build_occ.h:31
Poly_Voro
Definition: poly_voro.h:31
POLY_AFFICHE
Definition: poly_affiche.h:29
Polycristal::nomfichier
std::string nomfichier
Definition: polycristal.h:48
Polycristal::random_particules
std::vector< Poly_Point * > random_particules(int nbParticules)
Definition: polycristal.cpp:97
Polycristal::list_points
std::vector< Poly_Point * > list_points
Definition: polycristal.h:51
POLY_AFFICHE::active_affichage
virtual void active_affichage(fonction_affiche *fonc)
Definition: poly_affiche.cpp:36
polycristal.h
Polycristal::construit
virtual void construit(bool avecstep=false)
Definition: polycristal.cpp:75
poly_voro.h
poly_build_occ.h
POLY_AFFICHE::affiche2
fonction_affiche * affiche2
Definition: poly_affiche.h:42
Polycristal
Definition: polycristal.h:31
poly_point.h
Polycristal::dg
double dg
Definition: polycristal.h:49