Back to index

salome-med  6.5.0
MEDMEM_EnsightMeshDriver.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 ENSIGHT_MESH_DRIVER_HXX
00024 #define ENSIGHT_MESH_DRIVER_HXX
00025 
00026 #include "MEDMEM_define.hxx"
00027 #include "MEDMEM_Exception.hxx"
00028 #include "MEDMEM_EnsightUtils.hxx"
00029 
00030 #include <fstream>
00031 
00032 namespace MEDMEM {
00033 
00034   class GMESH;
00035   class SUPPORT;
00036 
00037 // ==============================================================================
00043 // ==============================================================================
00044 
00045 class MEDMEM_EXPORT ENSIGHT_MESH_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User
00046 {
00047 protected:
00048 
00049   GMESH *      _ptrMesh;
00050   std::string  _meshName;
00051 
00052   virtual void openConst(bool checkDataFile=false) const;
00053 
00054 public :
00055   ENSIGHT_MESH_DRIVER() ;
00056   ENSIGHT_MESH_DRIVER(const std::string & fileName,  GMESH * ptrMesh) ;
00057   ENSIGHT_MESH_DRIVER(const std::string & fileName,  GMESH * ptrMesh,
00058                       MED_EN::med_mode_acces accessMode);
00059   ENSIGHT_MESH_DRIVER(const ENSIGHT_MESH_DRIVER & driver) ;
00060   virtual ~ENSIGHT_MESH_DRIVER() ;
00061 
00062   void open();
00063   void close();
00064 
00065   virtual void        setMeshName(const string & meshName);
00066   virtual std::string getMeshName() const;
00067 
00068   GMESH* getMesh() { return _ptrMesh; }
00069 };
00070 
00071 // ==============================================================================
00075 // ==============================================================================
00076   
00077 class MEDMEM_EXPORT ENSIGHT_MESH_RDONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER
00078 {
00079 public :
00081   ENSIGHT_MESH_RDONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, int index=1);
00082 
00083   ENSIGHT_MESH_RDONLY_DRIVER();
00084   ENSIGHT_MESH_RDONLY_DRIVER(const ENSIGHT_MESH_RDONLY_DRIVER & driver);
00085   virtual ~ENSIGHT_MESH_RDONLY_DRIVER();
00086   virtual GENDRIVER * copy ( void ) const;
00087   virtual void merge ( const GENDRIVER& driver );
00088   virtual void write       ( void ) const throw (MEDEXCEPTION) ;
00089   virtual void read        ( void ) throw (MEDEXCEPTION);
00090 
00092   static int countParts(const std::string& geomFileName,
00093                         const bool         isSingleFileMode);
00094 
00095   static GROUP* makeGroup( MEDMEM::_groupe &           interGroup,
00096                            MEDMEM_ENSIGHT::_InterMed & imed);
00097                         
00098 private:
00099 
00100   void readGoldASCII (MEDMEM_ENSIGHT::_InterMed & imed);
00101   void readGoldBinary(MEDMEM_ENSIGHT::_InterMed & imed);
00102   void read6ASCII    (MEDMEM_ENSIGHT::_InterMed & imed);
00103   void read6Binary   (MEDMEM_ENSIGHT::_InterMed & imed);
00104 
00105   static int countPartsBinary(MEDMEM_ENSIGHT::_BinaryFileReader& fileReader,
00106                               const bool                         isSingleFileMode);
00107 
00108   bool _isMadeByMed;
00109   int  _indexInCaseFile;
00110 };
00111 
00112 // ==============================================================================
00119 // ==============================================================================
00120 
00121 class MEDMEM_EXPORT ENSIGHT_MESH_WRONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER
00122 {
00123 public :
00125   // to be appended, a mesh mush have same nb of groups and dimension as already present ones
00126   ENSIGHT_MESH_WRONLY_DRIVER(const std::string & fileName,
00127                              const GMESH * ptrMesh,
00128                              bool append=false);
00129 
00130   ENSIGHT_MESH_WRONLY_DRIVER();
00131   ENSIGHT_MESH_WRONLY_DRIVER(const ENSIGHT_MESH_WRONLY_DRIVER & driver);
00132   virtual ~ENSIGHT_MESH_WRONLY_DRIVER();
00133   GENDRIVER * copy ( void ) const;
00134   void write       ( void ) const throw (MEDEXCEPTION) ;
00135   void read        ( void ) throw (MEDEXCEPTION) ;
00136 
00137   int nbPartsToWrite() const;
00138 
00139 private:
00140 
00141   void writePart6Binary   (MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const;
00142   void writePartGoldBinary(MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const;
00143   void writePart6ASCII    (std::ofstream&               fileStream, const SUPPORT* support) const;
00144   void writePartGoldASCII (std::ofstream&               fileStream, const SUPPORT* support) const;
00145 
00146   bool _append;
00147 };
00148 
00149 }
00150 
00151 #endif /* ENSIGHT_MESH_DRIVER_HXX */
00152