1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef ENSIGHT_MESH_DRIVER_HXX
24 #define ENSIGHT_MESH_DRIVER_HXX
26 #include "MEDMEM_define.hxx"
27 #include "MEDMEM_Exception.hxx"
28 #include "MEDMEM_EnsightUtils.hxx"
37 // ==============================================================================
39 Driver Ensight for MESH ( writing and reading ).
41 Generic part : implement open and close methods.
43 // ==============================================================================
45 class MEDMEM_EXPORT ENSIGHT_MESH_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User
50 std::string _meshName;
52 virtual void openConst(bool checkDataFile=false) const;
55 ENSIGHT_MESH_DRIVER() ;
56 ENSIGHT_MESH_DRIVER(const std::string & fileName, GMESH * ptrMesh) ;
57 ENSIGHT_MESH_DRIVER(const std::string & fileName, GMESH * ptrMesh,
58 MED_EN::med_mode_acces accessMode);
59 ENSIGHT_MESH_DRIVER(const ENSIGHT_MESH_DRIVER & driver) ;
60 virtual ~ENSIGHT_MESH_DRIVER() ;
65 virtual void setMeshName(const string & meshName);
66 virtual std::string getMeshName() const;
68 GMESH* getMesh() { return _ptrMesh; }
71 // ==============================================================================
73 * \brief Reading EnSight driver.
75 // ==============================================================================
77 class MEDMEM_EXPORT ENSIGHT_MESH_RDONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER
80 //!< to read mesh of index-th time step
81 ENSIGHT_MESH_RDONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, int index=1);
83 ENSIGHT_MESH_RDONLY_DRIVER();
84 ENSIGHT_MESH_RDONLY_DRIVER(const ENSIGHT_MESH_RDONLY_DRIVER & driver);
85 virtual ~ENSIGHT_MESH_RDONLY_DRIVER();
86 virtual GENDRIVER * copy ( void ) const;
87 virtual void merge ( const GENDRIVER& driver );
88 virtual void write ( void ) const throw (MEDEXCEPTION) ;
89 virtual void read ( void ) throw (MEDEXCEPTION);
91 //!< count number of parts in EnSight geometry file
92 static int countParts(const std::string& geomFileName,
93 const bool isSingleFileMode);
95 static GROUP* makeGroup( MEDMEM::_groupe & interGroup,
96 MEDMEM_ENSIGHT::_InterMed & imed);
100 void readGoldASCII (MEDMEM_ENSIGHT::_InterMed & imed);
101 void readGoldBinary(MEDMEM_ENSIGHT::_InterMed & imed);
102 void read6ASCII (MEDMEM_ENSIGHT::_InterMed & imed);
103 void read6Binary (MEDMEM_ENSIGHT::_InterMed & imed);
105 static int countPartsBinary(MEDMEM_ENSIGHT::_BinaryFileReader& fileReader,
106 const bool isSingleFileMode);
109 int _indexInCaseFile;
112 // ==============================================================================
114 * \brief Writing EnSight mesh driver.
115 * To set writing format use
116 * setEnSightFormatForWriting(EnSightFormat) and
117 * setEnSightBinaryFormatForWriting(bool)
119 // ==============================================================================
121 class MEDMEM_EXPORT ENSIGHT_MESH_WRONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER
125 // to be appended, a mesh mush have same nb of groups and dimension as already present ones
126 ENSIGHT_MESH_WRONLY_DRIVER(const std::string & fileName,
127 const GMESH * ptrMesh,
130 ENSIGHT_MESH_WRONLY_DRIVER();
131 ENSIGHT_MESH_WRONLY_DRIVER(const ENSIGHT_MESH_WRONLY_DRIVER & driver);
132 virtual ~ENSIGHT_MESH_WRONLY_DRIVER();
133 GENDRIVER * copy ( void ) const;
134 void write ( void ) const throw (MEDEXCEPTION) ;
135 void read ( void ) throw (MEDEXCEPTION) ;
137 int nbPartsToWrite() const;
141 void writePart6Binary (MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const;
142 void writePartGoldBinary(MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const;
143 void writePart6ASCII (std::ofstream& fileStream, const SUPPORT* support) const;
144 void writePartGoldASCII (std::ofstream& fileStream, const SUPPORT* support) const;
151 #endif /* ENSIGHT_MESH_DRIVER_HXX */