Back to index

salome-med  6.5.0
MEDMEM_TypeMeshDriver.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "MEDMEM_TypeMeshDriver.hxx"
00024 #include "MEDMEM_DriversDef.hxx"
00025 
00026 #include "MEDMEM_Family.hxx"
00027 #include "MEDMEM_Group.hxx"
00028 #include "MEDMEM_Coordinate.hxx"
00029 #include "MEDMEM_Connectivity.hxx"
00030 #include "MEDMEM_Mesh.hxx"
00031 #include "MEDMEM_CellModel.hxx"
00032 
00033 using namespace std;
00034 using namespace MEDMEM;
00035 
00036 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor 
00037 
00038 TYPE_MESH_DRIVER::TYPE_MESH_DRIVER():
00039   GENDRIVER(),
00040   _ptrMesh(( MESH *)MED_NULL),
00041   // A VOIR _medIdt(MED_INVALID),
00042   _meshName("")
00043 {
00044 }
00045 
00046 TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const std::string & fileName,
00047                                    MESH * ptrMesh,
00048                                    MED_EN::med_mode_acces accessMode): 
00049   GENDRIVER(fileName,accessMode),
00050   _ptrMesh(ptrMesh),
00051   // A VOIR _medIdt(MED_INVALID), 
00052   _meshName("")
00053 {
00054 }
00055   
00056 TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver): 
00057   GENDRIVER(driver),
00058   _ptrMesh(driver._ptrMesh),
00059   // A VOIR _medIdt(MED_INVALID), 
00060   _meshName(driver._meshName)
00061 {
00062 }
00063 
00064 TYPE_MESH_DRIVER::~TYPE_MESH_DRIVER()
00065 {
00066 }
00067 
00068 void TYPE_MESH_DRIVER::open()
00069   throw (MEDEXCEPTION)
00070 {
00071   const char * LOC = "TYPE_MESH_DRIVER::open()" ;
00072   BEGIN_OF_MED(LOC);
00073 
00074 //   if (_medIdt > 0) 
00075 //     _status = MED_OPENED; 
00076 //   else {
00077 //     _medIdt = MED_INVALID;
00078 //     _status = MED_CLOSED;
00079 //     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
00080 //   }
00081   
00082   END_OF_MED(LOC);
00083 }
00084   
00085 void TYPE_MESH_DRIVER::close()
00086   throw (MEDEXCEPTION)
00087 {
00088   const char * LOC = "TYPE_MESH_DRIVER::close() " ;
00089   BEGIN_OF_MED(LOC);
00090 
00091 //   int err = 0;
00092 //   if ( _status == MED_OPENED) {
00093 //     err=MED_FR::MEDfermer(_medIdt);
00094 //     H5close(); // If we call H5close() all the files are closed.
00095 //     if (err != 0)
00096 //       throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
00097 //                                  <<" Error when closing file !"
00098 //                                  )
00099 //                        );
00100 //     _status = MED_CLOSED;
00101 //     _medIdt = MED_INVALID;
00102 //   }
00103 
00104   END_OF_MED(LOC);
00105 }
00106 
00107 void    TYPE_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
00108 string  TYPE_MESH_DRIVER::getMeshName() const { return _meshName; };
00109 
00110 
00111 //---------------------------------- RDONLY PART -------------------------------------------------------------
00112 
00113 TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(): TYPE_MESH_DRIVER()
00114 {
00115 }
00116   
00117 TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName,
00118                                                  MESH * ptrMesh):
00119   TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
00120 { 
00121   MESSAGE_MED("TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
00122 }
00123   
00124 TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver): 
00125   TYPE_MESH_DRIVER(driver)
00126 {
00127 }
00128 
00129 TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER()
00130 {
00131   //MESSAGE_MED("TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER() has been destroyed");
00132 }
00133   
00134 GENDRIVER * TYPE_MESH_RDONLY_DRIVER::copy(void) const
00135 {
00136   return new TYPE_MESH_RDONLY_DRIVER(*this);
00137 }
00138 
00139 void TYPE_MESH_RDONLY_DRIVER::read(void)
00140   throw (MEDEXCEPTION)
00141 {
00142   const char * LOC = "TYPE_MESH_RDONLY_DRIVER::read() : " ;
00143   BEGIN_OF_MED(LOC);
00144  
00145   if (_status!=MED_OPENED)
00146     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "  <<  " (the file is not opened)." )) ;
00147 
00148   _ptrMesh->_name =  _meshName;
00149   
00150  
00151   END_OF_MED(LOC);
00152 }
00153 
00154 void TYPE_MESH_RDONLY_DRIVER::write( void ) const
00155   throw (MEDEXCEPTION)
00156 {
00157   throw MEDEXCEPTION("TYPE_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
00158 }
00159 
00160 
00161 /*--------------------- WRONLY PART -------------------------------*/
00162 
00163 TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER():TYPE_MESH_DRIVER()
00164 {
00165 }
00166   
00167 TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName,
00168                                                  MESH * ptrMesh):
00169   TYPE_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
00170 {
00171   MESSAGE_MED("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
00172 }
00173 
00174 TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver): 
00175   TYPE_MESH_DRIVER(driver)
00176 {
00177 }
00178 
00179 TYPE_MESH_WRONLY_DRIVER::~TYPE_MESH_WRONLY_DRIVER()
00180 {
00181   //MESSAGE_MED("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
00182 }
00183 
00184 GENDRIVER * TYPE_MESH_WRONLY_DRIVER::copy(void) const
00185 {
00186   return new TYPE_MESH_WRONLY_DRIVER(*this);
00187 }
00188 
00189 void TYPE_MESH_WRONLY_DRIVER::read (void)
00190   throw (MEDEXCEPTION)
00191 {
00192   throw MEDEXCEPTION("TYPE_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
00193 }
00194 
00195 void TYPE_MESH_WRONLY_DRIVER::write(void) const
00196   throw (MEDEXCEPTION)
00197 { 
00198   const char * LOC = "void TYPE_MESH_WRONLY_DRIVER::write(void) const : ";
00199   BEGIN_OF_MED(LOC);
00200 
00201   throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
00202 
00203   END_OF_MED(LOC);
00204 } 
00205 
00206 
00207 
00208 /*--------------------- RDWR PART -------------------------------*/
00209 
00210 TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER():TYPE_MESH_DRIVER()
00211 {
00212 }
00213 
00214 TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName,
00215                                            MESH * ptrMesh):
00216   TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
00217 {
00218   MESSAGE_MED("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
00219 }
00220 
00221 TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver): 
00222   TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_DRIVER(driver)
00223 {
00224 }
00225 
00226 TYPE_MESH_RDWR_DRIVER::~TYPE_MESH_RDWR_DRIVER() {
00227   //MESSAGE_MED("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
00228 } 
00229   
00230 GENDRIVER * TYPE_MESH_RDWR_DRIVER::copy(void) const
00231 {
00232   return new TYPE_MESH_RDWR_DRIVER(*this);
00233 }
00234 
00235 void TYPE_MESH_RDWR_DRIVER::write(void) const
00236   throw (MEDEXCEPTION)
00237 {
00238   TYPE_MESH_WRONLY_DRIVER::write();
00239 }
00240 void TYPE_MESH_RDWR_DRIVER::read (void)
00241   throw (MEDEXCEPTION)
00242 {
00243   TYPE_MESH_RDONLY_DRIVER::read();
00244 }