Back to index

salome-med  6.5.0
MEDMEM_MedMeshDriver.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_MESH_DRIVER_HXX
00024 #define MED_MESH_DRIVER_HXX
00025 
00026 #include <MEDMEM.hxx>
00027 
00028 #include <string>
00029 #include <vector>
00030 #include "MEDMEM_define.hxx"
00031 #include "MEDMEM_GenDriver.hxx"
00032 
00033 #include "MEDMEM_STRING.hxx"
00034 #include "MEDMEM_Exception.hxx"
00035 #include "MEDMEM_Utilities.hxx"
00036 
00045 namespace MEDMEM {
00046 class GMESH;
00047 class FAMILY;
00048 class GROUP;
00049 class CONNECTIVITY;
00050 class MEDMEM_EXPORT MED_MESH_DRIVER : public GENDRIVER
00051 {
00052 protected:
00053 
00054   GMESH *             _ptrMesh;
00055   mutable std::string _meshName;
00056   med_2_3::med_idt    _medIdt ;
00057   
00058 
00059 
00060 public :
00061 
00062   // all MED cell type
00063   static const med_2_3::med_geometry_type all_cell_type[MED_N_CELL_GEO_FIXED_CON];
00064   
00065   static const char * const all_cell_type_tab [MED_N_CELL_GEO_FIXED_CON];
00066 
00070   MED_MESH_DRIVER() ;
00074   MED_MESH_DRIVER(const std::string &    fileName,
00075                   GMESH *                ptrMesh,
00076                   MED_EN::med_mode_acces accessMode) ;
00080   MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ;
00081 
00085   virtual ~MED_MESH_DRIVER() ;
00086 
00087   virtual void open();
00088   virtual void close();
00089 
00090   virtual void write( void ) const = 0 ;
00091   virtual void read ( void ) = 0 ;
00092 
00098   virtual void   setMeshName(const std::string & meshName) ;
00102   virtual std::string getMeshName() const ;
00103 
00104 public:
00105   virtual GENDRIVER * copy ( void ) const = 0 ;
00106 
00107 };
00108 
00117 class MEDMEM_EXPORT MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
00118 {
00119  
00120 public :
00121   
00125   MED_MESH_RDONLY_DRIVER() ;
00129   MED_MESH_RDONLY_DRIVER(const std::string & fileName, GMESH * ptrMesh) ;
00133   MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver) ;
00137   virtual ~MED_MESH_RDONLY_DRIVER() ;
00138 
00142   void write( void ) const;
00146   void read ( void );
00151   void activateFacesComputation() { _computeFaces=true; }
00157   void desactivateFacesComputation() { _computeFaces=false; }
00158 
00159 protected:
00160   int getDescendingConnectivity(CONNECTIVITY * Connectivity);
00161   void updateFamily() ;
00162   void buildAllGroups(std::vector<GROUP*> & Groups, std::vector<FAMILY*> & Families) ;
00163 
00164 private:
00165   int getCOORDINATE();
00166   int getCONNECTIVITY();
00167   int getFAMILY();
00168   int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
00169   int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
00170   int getCellsFamiliesNumber(int** Arrays, /*CONNECTIVITY* Connectivity, */MED_EN::medEntityMesh entity) ;
00171   void getGRID ();
00172 
00173   GENDRIVER * copy ( void ) const ;
00174   virtual void merge ( const GENDRIVER& driver );
00175 
00176 private:
00177   bool _computeFaces;
00178 };
00179 
00188 class MEDMEM_EXPORT MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER
00189 {
00190 public :
00191   
00195   MED_MESH_WRONLY_DRIVER() ;
00199   MED_MESH_WRONLY_DRIVER(const std::string &    fileName,
00200                          GMESH *                ptrMesh,
00201                          MED_EN::med_mode_acces access=MED_EN::WRONLY) ;
00205   MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ;
00206 
00210   virtual ~MED_MESH_WRONLY_DRIVER() ;
00211 
00215   void read ( void );
00216 
00220   void write( void ) const;
00221 
00222 private:
00223   int writeCoordinates    ()                           const;
00224   int writeConnectivities (MED_EN::medEntityMesh entity)       const;
00225   void groupFamilyConverter(const std::vector<GROUP*>& groups,
00226                             std::vector<FAMILY*>&      families) const;
00227   int writeFamilyNumbers  ()                           const;
00228   int writeFamilies       (std::vector<FAMILY*> & families) const;
00229   int writeGRID() const;
00230 
00231   GENDRIVER * copy ( void ) const ;
00232 };
00233 
00234 
00243 class MEDMEM_EXPORT MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, public virtual MED_MESH_WRONLY_DRIVER {
00244 
00245 public :
00246 
00250   MED_MESH_RDWR_DRIVER() ;
00254   MED_MESH_RDWR_DRIVER(const std::string & fileName, GMESH * ptrMesh) ;
00258   MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ;
00259 
00263   ~MED_MESH_RDWR_DRIVER() ;
00264 
00268   void write(void) const;
00272   void read (void);
00273 
00274 private:
00275   GENDRIVER * copy(void) const ;
00276 
00277 };
00278 
00279 }
00280 
00281 #endif /* MED_MESH_DRIVER_HXX */