]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_GibiMeshDriver.cxx
Salome HOME
0da08ffa57efa8f024217e98d3592d30a17ecc7e
[modules/med.git] / src / MEDMEM / MEDMEM_GibiMeshDriver.cxx
1 //  MED MEDMEM : MED files in memory
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : MEDMEM_GibiMeshDriver.cxx
8 //  Module : MED
9
10 using namespace std;
11 #include "MEDMEM_GibiMeshDriver.hxx"
12
13 #include "MEDMEM_DriversDef.hxx"
14
15 #include "MEDMEM_Family.hxx"
16 #include "MEDMEM_Group.hxx"
17 #include "MEDMEM_Coordinate.hxx"
18 #include "MEDMEM_Connectivity.hxx"
19 #include "MEDMEM_Mesh.hxx"
20 #include "MEDMEM_CellModel.hxx"
21
22 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor 
23
24 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER():
25   GENDRIVER(),
26   _ptrMesh(( MESH *)MED_NULL),
27   // A VOIR _medIdt(MED_INVALID),
28   _meshName("")
29 {
30 }
31
32 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName,
33                                    MESH * ptrMesh,
34                                    MED_EN::med_mode_acces accessMode): 
35   GENDRIVER(fileName,accessMode),
36   _ptrMesh(ptrMesh),
37   // A VOIR _medIdt(MED_INVALID), 
38   _meshName("")
39 {
40 }
41   
42 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver): 
43   GENDRIVER(driver),
44   _ptrMesh(driver._ptrMesh),
45   // A VOIR _medIdt(MED_INVALID), 
46   _meshName(driver._meshName)
47 {
48 }
49
50 GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER()
51 {
52 }
53
54 void GIBI_MESH_DRIVER::open()
55   throw (MEDEXCEPTION)
56 {
57   const char * LOC = "GIBI_MESH_DRIVER::open()" ;
58   BEGIN_OF(LOC);
59
60 //   if (_medIdt > 0) 
61 //     _status = MED_OPENED; 
62 //   else {
63 //     _medIdt = MED_INVALID;
64 //     _status = MED_CLOSED;
65 //     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
66 //   }
67   
68   END_OF(LOC);
69 }
70   
71 void GIBI_MESH_DRIVER::close()
72   throw (MEDEXCEPTION)
73 {
74   const char * LOC = "GIBI_MESH_DRIVER::close() " ;
75   BEGIN_OF(LOC);
76
77 //   int err = 0;
78 //   if ( _status == MED_OPENED) {
79 //     err=MED_FR::MEDfermer(_medIdt);
80 //     H5close(); // If we call H5close() all the files are closed.
81 //     if (err != 0)
82 //       throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
83 //                                  <<" Error when closing file !"
84 //                                  )
85 //                        );
86 //     _status = MED_CLOSED;
87 //     _medIdt = MED_INVALID;
88 //   }
89
90   END_OF(LOC);
91 }
92
93 void    GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
94 string  GIBI_MESH_DRIVER::getMeshName() const { return _meshName; };
95
96
97 //---------------------------------- RDONLY PART -------------------------------------------------------------
98
99 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): GIBI_MESH_DRIVER()
100 {
101 }
102   
103 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,
104                                                  MESH * ptrMesh):
105   GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
106
107   MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
108 }
109   
110 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver): 
111   GIBI_MESH_DRIVER(driver)
112 {
113 }
114
115 GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER()
116 {
117   //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
118 }
119   
120 GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const
121 {
122   return new GIBI_MESH_RDONLY_DRIVER(*this);
123 }
124
125 void GIBI_MESH_RDONLY_DRIVER::read(void)
126   throw (MEDEXCEPTION)
127 {
128   const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ;
129   BEGIN_OF(LOC);
130  
131   if (_status!=MED_OPENED)
132     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "  <<  " (the file is not opened)." )) ;
133
134   _ptrMesh->_name =  _meshName;
135   
136  
137   END_OF(LOC);
138 }
139
140 void GIBI_MESH_RDONLY_DRIVER::write( void ) const
141   throw (MEDEXCEPTION)
142 {
143   throw MEDEXCEPTION("GIBI_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
144 }
145
146
147 /*--------------------- WRONLY PART -------------------------------*/
148
149 GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER():GIBI_MESH_DRIVER()
150 {
151 }
152   
153 GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName,
154                                                  MESH * ptrMesh):
155   GIBI_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
156 {
157   MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
158 }
159
160 GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver): 
161   GIBI_MESH_DRIVER(driver)
162 {
163 }
164
165 GIBI_MESH_WRONLY_DRIVER::~GIBI_MESH_WRONLY_DRIVER()
166 {
167   //MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
168 }
169
170 GENDRIVER * GIBI_MESH_WRONLY_DRIVER::copy(void) const
171 {
172   return new GIBI_MESH_WRONLY_DRIVER(*this);
173 }
174
175 void GIBI_MESH_WRONLY_DRIVER::read (void)
176   throw (MEDEXCEPTION)
177 {
178   throw MEDEXCEPTION("GIBI_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
179 }
180
181 void GIBI_MESH_WRONLY_DRIVER::write(void) const
182   throw (MEDEXCEPTION)
183
184   const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : ";
185   BEGIN_OF(LOC);
186
187   throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
188
189   END_OF(LOC);
190
191
192
193
194 /*--------------------- RDWR PART -------------------------------*/
195
196 GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER():GIBI_MESH_DRIVER()
197 {
198 }
199
200 GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName,
201                                            MESH * ptrMesh):
202   GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
203 {
204   MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
205 }
206
207 GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver): 
208   GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_DRIVER(driver)
209 {
210 }
211
212 GIBI_MESH_RDWR_DRIVER::~GIBI_MESH_RDWR_DRIVER() {
213   //MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
214
215   
216 GENDRIVER * GIBI_MESH_RDWR_DRIVER::copy(void) const
217 {
218   return new GIBI_MESH_RDWR_DRIVER(*this);
219 }
220
221 void GIBI_MESH_RDWR_DRIVER::write(void) const
222   throw (MEDEXCEPTION)
223 {
224   GIBI_MESH_WRONLY_DRIVER::write();
225 }
226 void GIBI_MESH_RDWR_DRIVER::read (void)
227   throw (MEDEXCEPTION)
228 {
229   GIBI_MESH_RDONLY_DRIVER::read();
230 }