MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
mstruct_analyse_orientation.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 //####// mstruct_analyse_orientation.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:57 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
23 #include "mstruct_ves.h"
24 #include "mstruct_outils.h"
25 #include "mstruct_definition.h"
26 #include "mg_cg_forme.h"
27 #include "mg_cg_groupe_forme.h"
28 #include "mg_cg_assemblage.h"
29 #include "mg_cg_modele.h"
30 #include "magic_plot.h"
31 #include <string.h>
32 #include <math.h>
34 {
35 }
36 
38  std::string identifiant,
39  std::string nom_groupe_forme,
40  BOITE_3D* boite_3d,bool avec_fem_maillage): MSTRUCT_ANALYSE(ves,identifiant, nom_groupe_forme, boite_3d)
41 {
42  m_avec_fem_maillage=avec_fem_maillage;
43 }
44 
46 {
47  if(cpy_data)
48  for(int i=0;i<6;i++)
49  {
50  m_moyenne[i]=mdd.m_moyenne[i];
51  m_ecart_type[i]=mdd.m_ecart_type[i];
52  m_min[i]=mdd.m_min[i];
53  m_max[i]=mdd.m_max[i];
54  }
55 }
56 
58 {
59 }
60 
62 {
63  return m_moyenne;
64 }
65 
67 {
68  return m_ecart_type;
69 }
70 
72 {
73  return m_min;
74 }
75 
77 {
78  return m_max;
79 }
80 
82 {
84 }
85 
87 {
88  MG_CG_GROUPE_FORME* groupe_forme=NULL;
89  FEM_MAILLAGE* fem_maill=NULL;
93 }
94 
95 MSTRUCT_ANALYSE_ORIENTATION * MSTRUCT_ANALYSE_ORIENTATION::calculer_ecart(std::string identifiant, double* tenseur_compare, int type_ecart)
96 {
98  ecart->m_identifiant=identifiant;
99  for(int i=0;i<6;i++)
100  {
102  {
103  if(std::fabs(tenseur_compare[i])>1.0e-16) ecart->get_moyenne()[i]=(m_moyenne[i]-tenseur_compare[i])/tenseur_compare[i];
104  else ecart->get_moyenne()[i]=nan("");
105  ecart->get_ecart_type()[i]=nan("");
106  ecart->get_min()[i]=nan("");
107  ecart->get_max()[i]=nan("");
108  }
110  {
111  if(std::fabs(tenseur_compare[i])>1.0e-16) ecart->get_moyenne()[i]=std::fabs((m_moyenne[i]-tenseur_compare[i])/tenseur_compare[i]);
112  else ecart->get_moyenne()[i]=nan("");
113  ecart->get_ecart_type()[i]=nan("");
114  ecart->get_min()[i]=nan("");
115  ecart->get_max()[i]=nan("");
116  }
117  else if(type_ecart==MSTRUCT::TYPE_COMPARAISON::ECART_ABSOLUE)
118  {
119  ecart->get_moyenne()[i]=std::fabs(m_moyenne[i]-tenseur_compare[i]);
120  ecart->get_ecart_type()[i]=nan("");
121  ecart->get_min()[i]=nan("");
122  ecart->get_max()[i]=nan("");
123  }
125  {
126  double val=(m_moyenne[i]-tenseur_compare[i]);
127  ecart->get_moyenne()[i]=val*val;
128  ecart->get_ecart_type()[i]=nan("");
129  ecart->get_min()[i]=nan("");
130  ecart->get_max()[i]=nan("");
131  }
132  }
133  return ecart;
134 }
135 
136 
137 void MSTRUCT_ANALYSE_ORIENTATION::exporter(std::ofstream& ofstrm, long i, bool avec_entete, bool avec_graph, char* prefix_graph)
138 {
139  if(avec_entete) ofstrm << "#(1) [ORIENTATION](2-7) [±](8-13) [min](14-19) [max](20-25)" << std::endl;
140  ofstrm << i << " ";
141  for(int j=0;j<6;j++)
142  {
143  ofstrm << m_moyenne[j] << " ";
144  }
145  for(int j=0;j<6;j++)
146  {
147  ofstrm << m_ecart_type[j] << " ";
148  }
149  for(int j=0;j<6;j++)
150  {
151  ofstrm << m_min[j] << " ";
152  }
153  for(int j=0;j<6;j++)
154  {
155  ofstrm << m_max[j] << " ";
156  }
157  ofstrm << std::endl;
158  if(avec_graph)
159  {
160  OT_TENSEUR tenseur_orientation(3,3);
161  tenseur_orientation(0,0)=m_moyenne[0];
162  tenseur_orientation(1,1)=m_moyenne[1];
163  tenseur_orientation(2,2)=m_moyenne[2];
164  tenseur_orientation(0,1)=m_moyenne[3];
165  tenseur_orientation(0,2)=m_moyenne[4];
166  tenseur_orientation(1,2)=m_moyenne[5];
167  tenseur_orientation(1,0)=m_moyenne[3];
168  tenseur_orientation(2,0)=m_moyenne[4];
169  tenseur_orientation(2,1)=m_moyenne[5];
170  OT_TENSEUR tenseur_orientation_ecart_type(3,3);
171  tenseur_orientation_ecart_type(0,0)=m_ecart_type[0];
172  tenseur_orientation_ecart_type(1,1)=m_ecart_type[1];
173  tenseur_orientation_ecart_type(2,2)=m_ecart_type[2];
174  tenseur_orientation_ecart_type(0,1)=m_ecart_type[3];
175  tenseur_orientation_ecart_type(0,2)=m_ecart_type[4];
176  tenseur_orientation_ecart_type(1,2)=m_ecart_type[5];
177  tenseur_orientation_ecart_type(1,0)=m_ecart_type[3];
178  tenseur_orientation_ecart_type(2,0)=m_ecart_type[4];
179  tenseur_orientation_ecart_type(2,1)=m_ecart_type[5];
180  char nom_plot[500];
181  sprintf(nom_plot,"%s/tenseur_%s.plt",prefix_graph,m_identifiant.c_str());
182  MAGIC_PLOT magic_plot;
183  magic_plot.tenseur_couleur=MAGIC_PLOT::COULEUR::GRIS;
184  magic_plot.tenseur_titre="Tenseur d'orientation";
185  magic_plot.tenseur_titrebarcouleur="";
186  magic_plot.plot_script_tenseur(2,tenseur_orientation,tenseur_orientation_ecart_type,nom_plot,true);
187  }
188 }
189 
190 void MSTRUCT_ANALYSE_ORIENTATION::enregistrer(std::ofstream& ofstrm)
191 {
192  long type_analyse=get_type();
193  ofstrm.write((char*)&type_analyse,sizeof(long));
195  ofstrm.write((char*)&m_avec_fem_maillage,sizeof(bool));
196  for(int i=0;i<6;i++)
197  {
198  ofstrm.write((char*)&m_moyenne[i],sizeof(double));
199  ofstrm.write((char*)&m_ecart_type[i],sizeof(double));
200  ofstrm.write((char*)&m_min[i],sizeof(double));
201  ofstrm.write((char*)&m_max[i],sizeof(double));
202  }
203 }
204 
205 void MSTRUCT_ANALYSE_ORIENTATION::ouvrir(std::ifstream& ifstrm)
206 {
207  MSTRUCT_ANALYSE::ouvrir(ifstrm);
208  ifstrm.read((char*)&m_avec_fem_maillage,sizeof(bool));
209  for(int i=0;i<6;i++)
210  {
211  ifstrm.read((char*)&m_moyenne[i],sizeof(double));
212  ifstrm.read((char*)&m_ecart_type[i],sizeof(double));
213  ifstrm.read((char*)&m_min[i],sizeof(double));
214  ifstrm.read((char*)&m_max[i],sizeof(double));
215  }
216 }
217 
219 {
221  char ligne[5000];
222  sprintf(ligne,"MSTRUCT_ANALYSE_ORIENTATION");
223  fonc(ligne);
224  char valeur[100];
225  sprintf(ligne,"-> Moyenne : [");
226  for(int i=0;i<5;i++)
227  {
228  sprintf(valeur,"%lf,",m_moyenne[i]);
229  strcat(ligne,valeur);
230  }
231  sprintf(valeur,"%lf]",m_moyenne[5]);
232  strcat(ligne,valeur);
233  fonc(ligne);
234  sprintf(ligne,"-> Ecart-type : [");
235  for(int i=0;i<5;i++)
236  {
237  sprintf(valeur,"%lf,",m_ecart_type[i]);
238  strcat(ligne,valeur);
239  }
240  sprintf(valeur,"%lf]",m_ecart_type[5]);
241  strcat(ligne,valeur);
242  fonc(ligne);
243  sprintf(ligne,"-> Min : [");
244  for(int i=0;i<5;i++)
245  {
246  sprintf(valeur,"%lf,",m_min[i]);
247  strcat(ligne,valeur);
248  }
249  sprintf(valeur,"%lf]",m_min[5]);
250  strcat(ligne,valeur);
251  fonc(ligne);
252  sprintf(ligne,"-> Max : [");
253  for(int i=0;i<5;i++)
254  {
255  sprintf(valeur,"%lf,",m_max[i]);
256  strcat(ligne,valeur);
257  }
258  sprintf(valeur,"%lf]",m_max[5]);
259  strcat(ligne,valeur);
260  fonc(ligne);
261 }
MSTRUCT_ANALYSE_ORIENTATION::m_avec_fem_maillage
bool m_avec_fem_maillage
Definition: mstruct_analyse_orientation.h:48
MSTRUCT_ANALYSE_ORIENTATION::get_ecart_type
virtual double * get_ecart_type(void)
Definition: mstruct_analyse_orientation.cpp:66
mg_cg_forme.h
MSTRUCT::ECART_RELATIF
@ ECART_RELATIF
Definition: mstruct_definition.h:85
MSTRUCT_ANALYSE_ORIENTATION::m_min
double m_min[6]
Definition: mstruct_analyse_orientation.h:46
MSTRUCT_ANALYSE_ORIENTATION::calculer_ecart
virtual MSTRUCT_ANALYSE_ORIENTATION * calculer_ecart(std::string identifiant, double *tenseur_compare, int type_ecart)
Definition: mstruct_analyse_orientation.cpp:95
MSTRUCT_ANALYSE_ORIENTATION::get_max
virtual double * get_max(void)
Definition: mstruct_analyse_orientation.cpp:76
mstruct_outils.h
MSTRUCT_ANALYSE_ORIENTATION::get_moyenne
virtual double * get_moyenne(void)
Definition: mstruct_analyse_orientation.cpp:61
MSTRUCT_ANALYSE_ORIENTATION::MSTRUCT_ANALYSE_ORIENTATION
MSTRUCT_ANALYSE_ORIENTATION(void)
Definition: mstruct_analyse_orientation.cpp:33
mstruct_ves.h
MSTRUCT_VES::get_fem_maillage
virtual FEM_MAILLAGE * get_fem_maillage(void)
Definition: mstruct_ves.cpp:186
MSTRUCT_ANALYSE::enregistrer
virtual void enregistrer(std::ofstream &ofstrm)
Definition: mstruct_analyse.cpp:100
mg_cg_groupe_forme.h
MSTRUCT_ANALYSE::m_boite_analyse
BOITE_3D * m_boite_analyse
Definition: mstruct_analyse.h:53
MG_CG_MODELE::get_mgcg_groupe_forme
MG_CG_GROUPE_FORME * get_mgcg_groupe_forme(std::string nom)
Definition: mg_cg_modele.cpp:504
MSTRUCT::ECART_RELATIF_ABSOLUE
@ ECART_RELATIF_ABSOLUE
Definition: mstruct_definition.h:86
MSTRUCT_ANALYSE_ORIENTATION::m_moyenne
double m_moyenne[6]
Definition: mstruct_analyse_orientation.h:44
MSTRUCT_ANALYSE_ORIENTATION::affiche_contenu
virtual void affiche_contenu(fonction_affiche *fonc)
Definition: mstruct_analyse_orientation.cpp:218
MSTRUCT_ANALYSE::m_nom_groupe_forme
std::string m_nom_groupe_forme
Definition: mstruct_analyse.h:54
MSTRUCT_VES::get_mgcg_modele
virtual MG_CG_MODELE * get_mgcg_modele(void)
Definition: mstruct_ves.cpp:170
magic_plot.h
MAGIC_PLOT::tenseur_titrebarcouleur
std::string tenseur_titrebarcouleur
Definition: magic_plot.h:44
MSTRUCT_ANALYSE::m_ves
MSTRUCT_VES * m_ves
Definition: mstruct_analyse.h:55
MSTRUCT::ECART_ABSOLUE
@ ECART_ABSOLUE
Definition: mstruct_definition.h:87
OT_TENSEUR
Definition: ot_tenseur.h:41
FEM_MAILLAGE
Definition: fem_maillage.h:66
MSTRUCT_ANALYSE
Definition: mstruct_analyse.h:30
MAGIC_PLOT::tenseur_titre
std::string tenseur_titre
Definition: magic_plot.h:43
MSTRUCT_ANALYSE_ORIENTATION::get_min
virtual double * get_min(void)
Definition: mstruct_analyse_orientation.cpp:71
MSTRUCT::ECART_QUADRATIQUE
@ ECART_QUADRATIQUE
Definition: mstruct_definition.h:88
mstruct_definition.h
MSTRUCT_VES
Definition: mstruct_ves.h:45
MG_CG_GROUPE_FORME
Definition: mg_cg_groupe_forme.h:30
mg_cg_modele.h
MAGIC_PLOT::plot_script_tenseur
void plot_script_tenseur(int num, OT_TENSEUR tens1, OT_TENSEUR tens2, std::string output, bool aveccouleur=false)
Definition: magic_plot.cpp:60
MSTRUCT_OUTILS::statistiques_tenseur_orientation
static int statistiques_tenseur_orientation(MG_CG_GROUPE_FORME *groupe_forme, BOITE_3D *boite_analyse, double *moyenne, double *ecart_type, double *min, double *max, FEM_MAILLAGE *fem=NULL, bool ponderation_volume=false)
Definition: mstruct_outils.cpp:189
mg_cg_assemblage.h
BOITE_3D
Definition: ot_boite_3d.h:27
MSTRUCT_ANALYSE::affiche_contenu
virtual void affiche_contenu(fonction_affiche *fonc)
Definition: mstruct_analyse.cpp:171
MAGIC_PLOT
Definition: magic_plot.h:27
MAGIC_PLOT::tenseur_couleur
int tenseur_couleur
Definition: magic_plot.h:42
MSTRUCT_ANALYSE_ORIENTATION::exporter
virtual void exporter(std::ofstream &ofstrm, long i, bool avec_entete=false, bool avec_graph=false, char *prefix_graph=(char *)"")
Definition: mstruct_analyse_orientation.cpp:137
MSTRUCT_ANALYSE_ORIENTATION::m_ecart_type
double m_ecart_type[6]
Definition: mstruct_analyse_orientation.h:45
MSTRUCT_ANALYSE::m_identifiant
std::string m_identifiant
Definition: mstruct_analyse.h:52
MSTRUCT_ANALYSE_ORIENTATION::~MSTRUCT_ANALYSE_ORIENTATION
~MSTRUCT_ANALYSE_ORIENTATION(void)
Definition: mstruct_analyse_orientation.cpp:57
MSTRUCT_ANALYSE_ORIENTATION::get_type
virtual long get_type(void)
Definition: mstruct_analyse_orientation.cpp:81
fonction_affiche
void fonction_affiche(char *)
Definition: fct_taille.h:28
MSTRUCT_ANALYSE::ouvrir
virtual void ouvrir(std::ifstream &ifstrm)
Definition: mstruct_analyse.cpp:131
MSTRUCT_ANALYSE_ORIENTATION::executer
virtual void executer(void)
Definition: mstruct_analyse_orientation.cpp:86
MSTRUCT::ORIENTATION
@ ORIENTATION
Definition: mstruct_definition.h:59
MSTRUCT_ANALYSE_ORIENTATION
Definition: mstruct_analyse_orientation.h:25
MSTRUCT_ANALYSE_ORIENTATION::ouvrir
virtual void ouvrir(std::ifstream &ifstrm)
Definition: mstruct_analyse_orientation.cpp:205
mstruct_analyse_orientation.h
MSTRUCT_ANALYSE_ORIENTATION::m_max
double m_max[6]
Definition: mstruct_analyse_orientation.h:47
MSTRUCT_ANALYSE_ORIENTATION::enregistrer
virtual void enregistrer(std::ofstream &ofstrm)
Definition: mstruct_analyse_orientation.cpp:190