ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/microstructure/src/mstruct_analyse.cpp
Revision: 1158
Committed: Thu Jun 13 22:18:49 2024 UTC (11 months, 1 week ago) by francois
File size: 6083 byte(s)
Log Message:
compatibilité Ubuntu 22.04
Suppression des refeences à Windows
Ajout d'une banière

File Contents

# User Rev Content
1 francois 1158 //####//------------------------------------------------------------
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.cpp
15     //####//
16     //####//------------------------------------------------------------
17     //####//------------------------------------------------------------
18     //####// COPYRIGHT 2000-2024
19     //####// jeu 13 jun 2024 11:58:57 EDT
20     //####//------------------------------------------------------------
21     //####//------------------------------------------------------------
22 couturad 919 #include "mstruct_analyse.h"
23 couturad 968 #include "ot_boite_3d.h"
24 couturad 926 MSTRUCT_ANALYSE::MSTRUCT_ANALYSE(void)
25 couturad 919 {
26 couturad 968 m_ves=NULL;
27 couturad 926 m_identifiant="";
28     m_boite_analyse=NULL;
29     m_nom_groupe_forme="";
30 couturad 919 }
31    
32 couturad 968 MSTRUCT_ANALYSE::MSTRUCT_ANALYSE(std::string identifiant, std::string nom_groupe_forme, BOITE_3D* boite_3d)
33 couturad 919 {
34 couturad 968 m_ves=NULL;
35 couturad 926 m_identifiant=identifiant;
36     if(boite_3d!=NULL) m_boite_analyse=new BOITE_3D(*boite_3d);
37     else m_boite_analyse=NULL;
38 couturad 968 m_nom_groupe_forme=nom_groupe_forme;
39 couturad 919 }
40    
41 couturad 968 MSTRUCT_ANALYSE::MSTRUCT_ANALYSE(MSTRUCT_VES* ves,std::string identifiant, std::string nom_groupe_forme, BOITE_3D* boite_3d)
42 couturad 919 {
43 couturad 968 m_ves=ves;
44     m_identifiant=identifiant;
45     if(boite_3d!=NULL) m_boite_analyse=new BOITE_3D(*boite_3d);
46     else m_boite_analyse=NULL;
47     m_nom_groupe_forme=nom_groupe_forme;
48     }
49    
50     MSTRUCT_ANALYSE::MSTRUCT_ANALYSE(MSTRUCT_ANALYSE& mdd,bool cpy_data)
51     {
52     m_ves=mdd.m_ves;
53 couturad 926 m_identifiant=mdd.m_identifiant;
54     if(mdd.m_boite_analyse!=NULL) m_boite_analyse=new BOITE_3D(*mdd.m_boite_analyse);
55     else m_boite_analyse=NULL;
56     m_nom_groupe_forme=mdd.m_nom_groupe_forme;
57 couturad 919 }
58    
59 couturad 926 MSTRUCT_ANALYSE::~MSTRUCT_ANALYSE(void)
60 couturad 919 {
61 couturad 926 if(m_boite_analyse!=NULL) delete m_boite_analyse;
62     }
63    
64 couturad 968 MSTRUCT_VES * MSTRUCT_ANALYSE::get_ves()
65     {
66     return m_ves;
67     }
68    
69 couturad 951 void MSTRUCT_ANALYSE::change_identifiant(std::string identifiant)
70 couturad 926 {
71 couturad 919 m_identifiant=identifiant;
72     }
73    
74 couturad 951 std::string MSTRUCT_ANALYSE::get_identifiant(void)
75 couturad 919 {
76 couturad 926 return m_identifiant;
77 couturad 919 }
78    
79 couturad 926 void MSTRUCT_ANALYSE::change_boite_analyse(BOITE_3D boite_3d)
80 couturad 919 {
81 couturad 926 delete m_boite_analyse;
82     m_boite_analyse=new BOITE_3D(boite_3d);
83 couturad 919 }
84    
85 couturad 926 BOITE_3D* MSTRUCT_ANALYSE::get_boite_analyse(void)
86 couturad 919 {
87     return m_boite_analyse;
88     }
89    
90 couturad 951 void MSTRUCT_ANALYSE::change_nom_groupe_forme(std::string nom_groupe_forme)
91 couturad 919 {
92 couturad 926 m_nom_groupe_forme=nom_groupe_forme;
93 couturad 919 }
94    
95 couturad 951 std::string MSTRUCT_ANALYSE::get_nom_groupe_forme(void)
96 couturad 919 {
97 couturad 926 return m_nom_groupe_forme;
98 couturad 919 }
99    
100 couturad 951 void MSTRUCT_ANALYSE::enregistrer(std::ofstream& ofstrm)
101 couturad 926 {
102     size_t len_identifiant = m_identifiant.size();
103     ofstrm.write((char*)&len_identifiant,sizeof(size_t));
104     ofstrm.write(m_identifiant.c_str(),m_identifiant.size());
105 couturad 919
106 couturad 926 size_t len_nom_groupe_forme = m_nom_groupe_forme.size();
107     ofstrm.write((char*)&len_nom_groupe_forme,sizeof(size_t));
108     ofstrm.write(m_nom_groupe_forme.c_str(),m_nom_groupe_forme.size());
109    
110     bool avec_boite;
111     if(m_boite_analyse==NULL) avec_boite=false;
112     else avec_boite=true;
113     ofstrm.write((char*)&avec_boite,sizeof(bool));
114     if(avec_boite)
115     {
116     double xmin=m_boite_analyse->get_xmin();
117     ofstrm.write((char*)&xmin,sizeof(double));
118     double ymin=m_boite_analyse->get_ymin();
119     ofstrm.write((char*)&ymin,sizeof(double));
120     double zmin=m_boite_analyse->get_zmin();
121     ofstrm.write((char*)&zmin,sizeof(double));
122     double xmax=m_boite_analyse->get_xmax();
123     ofstrm.write((char*)&xmax,sizeof(double));
124     double ymax=m_boite_analyse->get_ymax();
125     ofstrm.write((char*)&ymax,sizeof(double));
126     double zmax=m_boite_analyse->get_zmax();
127     ofstrm.write((char*)&zmax,sizeof(double));
128     }
129 couturad 919 }
130 couturad 926
131 couturad 951 void MSTRUCT_ANALYSE::ouvrir(std::ifstream& ifstrm)
132 couturad 926 {
133     size_t len_identifiant;
134     ifstrm.read((char*)&len_identifiant,sizeof(size_t));
135     char *temp_identifiant = new char[len_identifiant+1];
136     ifstrm.read(temp_identifiant,len_identifiant);
137     temp_identifiant[len_identifiant]='\0';
138     m_identifiant=temp_identifiant;
139     delete [] temp_identifiant;
140    
141     size_t len_nom_groupe_forme;
142     ifstrm.read((char*)&len_nom_groupe_forme,sizeof(size_t));
143     char *temp_nom_groupe_forme = new char[len_nom_groupe_forme+1];
144     ifstrm.read(temp_nom_groupe_forme,len_nom_groupe_forme);
145     temp_nom_groupe_forme[len_nom_groupe_forme]='\0';
146     m_nom_groupe_forme=temp_nom_groupe_forme;
147     delete [] temp_nom_groupe_forme;
148    
149     bool avec_boite;
150     ifstrm.read((char*)&avec_boite,sizeof(bool));
151    
152     if(avec_boite)
153     {
154     double xmin;
155     ifstrm.read((char*)&xmin,sizeof(double));
156     double ymin;
157     ifstrm.read((char*)&ymin,sizeof(double));
158     double zmin;
159     ifstrm.read((char*)&zmin,sizeof(double));
160     double xmax;
161     ifstrm.read((char*)&xmax,sizeof(double));
162     double ymax;
163     ifstrm.read((char*)&ymax,sizeof(double));
164     double zmax;
165     ifstrm.read((char*)&zmax,sizeof(double));
166     m_boite_analyse = new BOITE_3D(xmin,ymin,zmin,xmax,ymax,zmax);
167     }
168     else m_boite_analyse=NULL;
169     }
170    
171 couturad 951 void MSTRUCT_ANALYSE::affiche_contenu(fonction_affiche* fonc)
172 couturad 926 {
173     char ligne[5000];
174     sprintf(ligne,"MSTRUCT_ANALYSE");
175     fonc(ligne);
176     sprintf(ligne,"-> Identifiant : %s", m_identifiant.c_str());
177     fonc(ligne);
178     if(m_boite_analyse!=NULL) sprintf(ligne,"-> Boite_3D : [%lf,%lf,%lf,%lf,%lf,%lf]", m_boite_analyse->get_xmin(),
179     m_boite_analyse->get_ymin(),
180     m_boite_analyse->get_zmin(),
181     m_boite_analyse->get_xmax(),
182     m_boite_analyse->get_ymax(),
183     m_boite_analyse->get_zmax());
184     else sprintf(ligne,"-> Boite_3D : NULL");
185     fonc(ligne);
186     if(m_nom_groupe_forme!="") sprintf(ligne,"-> MG_CG_GROUPE_FORME : %s",m_nom_groupe_forme.c_str());
187     else sprintf(ligne,"-> MG_CG_GROUPE_FORME : NULL");
188     fonc(ligne);
189    
190     }