1 // Copyright (C) 2007-2008 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
22 #ifndef ENSIGHT_MESH_DRIVER_HXX
23 #define ENSIGHT_MESH_DRIVER_HXX
25 #include "MEDMEM_define.hxx"
26 #include "MEDMEM_Exception.hxx"
27 #include "MEDMEM_EnsightUtils.hxx"
36 // ==============================================================================
38 Driver Ensight for MESH ( writing and reading ).
40 Generic part : implement open and close methods.
42 // ==============================================================================
44 class MEDMEM_EXPORT ENSIGHT_MESH_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User
49 std::string _meshName;
51 virtual void openConst(bool checkDataFile=false) const;
54 ENSIGHT_MESH_DRIVER() ;
55 ENSIGHT_MESH_DRIVER(const std::string & fileName, MESH * ptrMesh) ;
56 ENSIGHT_MESH_DRIVER(const std::string & fileName, MESH * ptrMesh,
57 MED_EN::med_mode_acces accessMode);
58 ENSIGHT_MESH_DRIVER(const ENSIGHT_MESH_DRIVER & driver) ;
59 virtual ~ENSIGHT_MESH_DRIVER() ;
64 virtual void setMeshName(const string & meshName);
65 virtual std::string getMeshName() const;
67 MESH* getMesh() { return _ptrMesh; }
70 // ==============================================================================
72 * \brief Reading EnSight driver.
74 // ==============================================================================
76 class MEDMEM_EXPORT ENSIGHT_MESH_RDONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER
79 //!< to read mesh of index-th time step
80 ENSIGHT_MESH_RDONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, int index=1);
82 ENSIGHT_MESH_RDONLY_DRIVER();
83 ENSIGHT_MESH_RDONLY_DRIVER(const ENSIGHT_MESH_RDONLY_DRIVER & driver);
84 virtual ~ENSIGHT_MESH_RDONLY_DRIVER();
85 virtual GENDRIVER * copy ( void ) const;
86 virtual void merge ( const GENDRIVER& driver );
87 virtual void write ( void ) const throw (MEDEXCEPTION) ;
88 virtual void read ( void ) throw (MEDEXCEPTION);
90 //!< count number of parts in EnSight geometry file
91 static int countParts(const std::string& geomFileName,
92 const bool isSingleFileMode);
94 static GROUP* makeGroup( MEDMEM::_groupe & interGroup,
95 MEDMEM_ENSIGHT::_InterMed & imed);
99 void readGoldASCII (MEDMEM_ENSIGHT::_InterMed & imed);
100 void readGoldBinary(MEDMEM_ENSIGHT::_InterMed & imed);
101 void read6ASCII (MEDMEM_ENSIGHT::_InterMed & imed);
102 void read6Binary (MEDMEM_ENSIGHT::_InterMed & imed);
104 static int countPartsBinary(MEDMEM_ENSIGHT::_BinaryFileReader& fileReader,
105 const bool isSingleFileMode);
108 int _indexInCaseFile;
111 // ==============================================================================
113 * \brief Writing EnSight mesh driver.
114 * To set writing format use
115 * setEnSightFormatForWriting(EnSightFormat) and
116 * setEnSightBinaryFormatForWriting(bool)
118 // ==============================================================================
120 class MEDMEM_EXPORT ENSIGHT_MESH_WRONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER
124 // to be appended, a mesh mush have same nb of groups and dimension as already present ones
125 ENSIGHT_MESH_WRONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, bool append=false);
127 ENSIGHT_MESH_WRONLY_DRIVER();
128 ENSIGHT_MESH_WRONLY_DRIVER(const ENSIGHT_MESH_WRONLY_DRIVER & driver);
129 virtual ~ENSIGHT_MESH_WRONLY_DRIVER();
130 GENDRIVER * copy ( void ) const;
131 void write ( void ) const throw (MEDEXCEPTION) ;
132 void read ( void ) throw (MEDEXCEPTION) ;
134 int nbPartsToWrite() const;
138 void writePart6Binary (MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const;
139 void writePartGoldBinary(MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const;
140 void writePart6ASCII (std::ofstream& fileStream, const SUPPORT* support) const;
141 void writePartGoldASCII (std::ofstream& fileStream, const SUPPORT* support) const;
148 #endif /* ENSIGHT_MESH_DRIVER_HXX */