ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/poly_occ/src/polycristal.cpp
Revision: 983
Committed: Wed Oct 24 17:41:40 2018 UTC (6 years, 6 months ago) by francois
File size: 3352 byte(s)
Log Message:
integration de poly_occ dans magic

File Contents

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

Properties

Name Value
svn:executable