1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : MEDMEM_GibiMeshDriver.cxx
11 #include "MEDMEM_GibiMeshDriver.hxx"
13 #include "MEDMEM_DriversDef.hxx"
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"
22 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
24 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER():
26 _ptrMesh(( MESH *)MED_NULL),
27 // A VOIR _medIdt(MED_INVALID),
32 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName,
34 MED_EN::med_mode_acces accessMode):
35 GENDRIVER(fileName,accessMode),
37 // A VOIR _medIdt(MED_INVALID),
42 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver):
44 _ptrMesh(driver._ptrMesh),
45 // A VOIR _medIdt(MED_INVALID),
46 _meshName(driver._meshName)
50 GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER()
54 void GIBI_MESH_DRIVER::open()
57 const char * LOC = "GIBI_MESH_DRIVER::open()" ;
61 // _status = MED_OPENED;
63 // _medIdt = MED_INVALID;
64 // _status = MED_CLOSED;
65 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
71 void GIBI_MESH_DRIVER::close()
74 const char * LOC = "GIBI_MESH_DRIVER::close() " ;
78 // if ( _status == MED_OPENED) {
79 // err=MED_FR::MEDfermer(_medIdt);
80 // H5close(); // If we call H5close() all the files are closed.
82 // throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
83 // <<" Error when closing file !"
86 // _status = MED_CLOSED;
87 // _medIdt = MED_INVALID;
93 void GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
94 string GIBI_MESH_DRIVER::getMeshName() const { return _meshName; };
97 //---------------------------------- RDONLY PART -------------------------------------------------------------
99 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): GIBI_MESH_DRIVER()
103 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,
105 GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
107 MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
110 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver):
111 GIBI_MESH_DRIVER(driver)
115 GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER()
117 //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
120 GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const
122 return new GIBI_MESH_RDONLY_DRIVER(*this);
125 void GIBI_MESH_RDONLY_DRIVER::read(void)
128 const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ;
131 if (_status!=MED_OPENED)
132 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ;
134 _ptrMesh->_name = _meshName;
140 void GIBI_MESH_RDONLY_DRIVER::write( void ) const
143 throw MEDEXCEPTION("GIBI_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
147 /*--------------------- WRONLY PART -------------------------------*/
149 GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER():GIBI_MESH_DRIVER()
153 GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName,
155 GIBI_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
157 MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
160 GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver):
161 GIBI_MESH_DRIVER(driver)
165 GIBI_MESH_WRONLY_DRIVER::~GIBI_MESH_WRONLY_DRIVER()
167 //MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
170 GENDRIVER * GIBI_MESH_WRONLY_DRIVER::copy(void) const
172 return new GIBI_MESH_WRONLY_DRIVER(*this);
175 void GIBI_MESH_WRONLY_DRIVER::read (void)
178 throw MEDEXCEPTION("GIBI_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
181 void GIBI_MESH_WRONLY_DRIVER::write(void) const
184 const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : ";
187 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
194 /*--------------------- RDWR PART -------------------------------*/
196 GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER():GIBI_MESH_DRIVER()
200 GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName,
202 GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
204 MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
207 GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver):
208 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_DRIVER(driver)
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");
216 GENDRIVER * GIBI_MESH_RDWR_DRIVER::copy(void) const
218 return new GIBI_MESH_RDWR_DRIVER(*this);
221 void GIBI_MESH_RDWR_DRIVER::write(void) const
224 GIBI_MESH_WRONLY_DRIVER::write();
226 void GIBI_MESH_RDWR_DRIVER::read (void)
229 GIBI_MESH_RDONLY_DRIVER::read();