Back to index

salome-med  6.5.0
MEDMEM_MedFieldDriver.hxx
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 #ifndef MED_FIELD_DRIVER_HXX
00024 #define MED_FIELD_DRIVER_HXX
00025 
00026 #include "MEDMEM_GenDriver.hxx"
00027 
00028 namespace MEDMEM {
00029 template <class T> class MED_FIELD_RDWR_DRIVER;
00030 template <class T> class MED_FIELD_RDONLY_DRIVER;
00031 template <class T> class MED_FIELD_WRONLY_DRIVER;
00032 
00041 template <class T> class MED_FIELD_DRIVER : public GENDRIVER
00042 {
00043 protected:
00044   // Developement plus propre :
00045   // - Il faudrait soit utiliser le type FIELD_ et ajouter à cette classe
00046   //   les accesseurs de FIELD<> utilisées dans les drivers
00047   // - Ou bien avoir des drivers à deux paramètres template (le top)
00048   // - Remarquez l'affreux cast dans le second constructeur :
00049   //      _ptrField( (FIELD<T> *) ptrField )
00050   //   Cela cast toujours le ptrField en FullInterlace
00051   //   Cela ne pose cependant pas de pb de fonctionement aux drivers
00052   FIELD<T> *       _ptrField;
00053   std::string      _fieldName;
00054   int              _fieldNum;
00055   med_2_3::med_idt _medIdt;
00056 
00057 public :
00058 
00059   MED_FIELD_DRIVER();
00060 
00061   template <class INTERLACING_TAG>
00062   MED_FIELD_DRIVER(const std::string &         fileName,
00063                    FIELD<T, INTERLACING_TAG> * ptrField,
00064                    MED_EN::med_mode_acces      accessMode);
00065 
00066   MED_FIELD_DRIVER(const MED_FIELD_DRIVER & fieldDriver);
00067 
00068   virtual ~MED_FIELD_DRIVER();
00069 
00070   virtual void open() throw (MEDEXCEPTION);
00071   virtual void close();
00072   virtual void write( void ) const = 0 ;
00073   virtual void read ( void ) = 0 ;
00079   virtual void   setFieldName(const std::string & fieldName) { _fieldName = fieldName; }
00083   virtual std::string getFieldName() const { return _fieldName; }
00084 
00085 protected:
00086   virtual GENDRIVER * copy ( void ) const = 0 ;
00087 
00088   bool createFieldSupportPart1(med_2_3::med_idt        id,
00089                                const std::string &     fieldName,
00090                                med_2_3::med_int        ndt,
00091                                med_2_3::med_int        od,
00092                                SUPPORT &               support,
00093                                std::string &           meshName,
00094                                std::vector<int> &      numberOfElementsOfTypeC,
00095                                std::vector<int> &      numberOfGaussPoint,
00096                                std::vector<std::string>& gaussModelName,
00097                                std::vector<std::string>& profilName,
00098                                int &                   totalNumberOfElWg,
00099                                MED_EN::medEntityMesh & fieldMedFileEntity,
00100                                MED_EN::medEntityMesh   preferEntity=MED_EN::MED_ALL_ENTITIES
00101                                ) const throw (MEDEXCEPTION);
00102 
00103   void getMeshGeometricTypeFromFile(med_2_3::med_idt      id,
00104                                     std::string &              meshName,
00105                                     MED_EN::medEntityMesh entite,
00106                                     std::vector<MED_EN::medGeometryElement> & geoType,
00107                                     std::vector<int> &         nbOfElOfType,
00108                                     std::vector<int> &         nbOfElOfTypeC
00109                                     ) const throw(MEDEXCEPTION);
00110 
00111   void getMeshGeometricTypeFromMESH( const GMESH * meshPtr,
00112                                      MED_EN::medEntityMesh  entity,
00113                                      std::vector<MED_EN::medGeometryElement> & geoType,
00114                                      std::vector<int> &nbOfElOfType,
00115                                      std::vector<int> &nbOfElOfTypeC
00116                                      ) const throw(MEDEXCEPTION);
00117 
00118   int getMeshDimensionFromFile(med_2_3::med_idt id, const string & meshName) const;
00119         
00120   MED_EN::medEntityMesh getMEDMEMEntityFromMEDType(MED_EN::medGeometryElement type,
00121                                                    int                        mesh_dim) const;
00122 
00123 };
00124 
00133 template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
00134 {
00135 public :
00136 
00137   MED_FIELD_RDONLY_DRIVER();
00138 
00139   template <class INTERLACING_TAG>
00140   MED_FIELD_RDONLY_DRIVER(const string &              fileName,
00141                           FIELD<T, INTERLACING_TAG> * ptrField);
00142 
00143   MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver);
00144 
00145   virtual ~MED_FIELD_RDONLY_DRIVER() {};
00146 
00147   void write( void ) const throw (MEDEXCEPTION) ;
00148   void read ( void ) throw (MEDEXCEPTION) ;
00149 
00150 private:
00151   GENDRIVER * copy( void ) const ;
00152 
00153 };
00154 
00163 template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
00164 {
00165 public :
00166 
00167   MED_FIELD_WRONLY_DRIVER();
00168 
00169   template <class INTERLACING_TAG>
00170   MED_FIELD_WRONLY_DRIVER(const string &              fileName,
00171                           FIELD<T, INTERLACING_TAG> * ptrField);
00172 
00173   MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver);
00174 
00175   virtual ~MED_FIELD_WRONLY_DRIVER();
00176 
00180   void write( void ) const throw (MEDEXCEPTION) ;
00184   void read ( void ) throw (MEDEXCEPTION) ;
00185 
00186 private:
00187   GENDRIVER * copy( void ) const ;
00188 
00189 };
00190 
00191 
00200 template <class T> class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER<T>, public MED_FIELD_WRONLY_DRIVER<T>
00201 {
00202 public :
00203 
00204   MED_FIELD_RDWR_DRIVER();
00205 
00206   template <class INTERLACING_TAG>
00207   MED_FIELD_RDWR_DRIVER(const string &              fileName,
00208                         FIELD<T, INTERLACING_TAG> * ptrField);
00209 
00210   MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver);
00211 
00215   ~MED_FIELD_RDWR_DRIVER();
00216 
00220   void write(void) const throw (MEDEXCEPTION) ;
00224   void read (void) throw (MEDEXCEPTION) ;
00225 
00226 private:
00227   GENDRIVER * copy( void ) const ;
00228 
00229 };
00230 
00231 } //End namespace MEDMEM
00232 
00233 // implementation
00234 #include "MEDMEM_MedFieldDriver.txx"
00235 
00236 #endif /* MED_FIELD_DRIVER_HXX */