]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_EnsightFieldDriver.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef ENSIGHT_FIELD_DRIVER_HXX
23 #define ENSIGHT_FIELD_DRIVER_HXX
24
25 #include <string>
26
27 #include "MEDMEM_EnsightUtils.hxx"
28
29 // ==========================================================================================
30 /*!
31   Driver Ensight for FIELD.
32 */
33 // ==========================================================================================
34
35 namespace MEDMEM {
36
37 class MEDMEM_EXPORT ENSIGHT_FIELD_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User
38 {
39 protected:
40   FIELD_ *    _ptrField;
41   std::string _fieldName;
42   std::string _constantValue;
43
44   void openConst(bool checkDataFile=false) const throw (MEDEXCEPTION);
45
46 public :
47
48   /*!
49     Constructor.
50   */
51   ENSIGHT_FIELD_DRIVER();
52   ENSIGHT_FIELD_DRIVER(const std::string &    fileName,
53                        FIELD_ *               ptrField,
54                        MED_EN::med_mode_acces accessMode);
55   /*!
56     Copy constructor.
57   */
58   ENSIGHT_FIELD_DRIVER(const ENSIGHT_FIELD_DRIVER & fieldDriver);
59   virtual void merge ( const GENDRIVER& driver );
60   /*!
61     Destructor.
62   */
63   virtual ~ENSIGHT_FIELD_DRIVER();
64
65   /*!
66     Set the name of the FIELD in EnSight file.
67
68     It could be different than the name of the FIELD object.
69   */
70   virtual void setFieldName(const std::string & fieldName) throw (MEDEXCEPTION);
71
72   /*!
73     Get the name of the FIELD in EnSight file.
74   */
75   virtual std::string getFieldName() const { return _fieldName; }
76
77   virtual void open() throw (MEDEXCEPTION) { openConst(); }
78
79   virtual void close() {}
80
81   FIELD_* getField() { return _ptrField; }
82
83   void setConstantValue(const std::string& value) { _constantValue = value; }
84
85   const std::string& getConstantValue() const { return _constantValue; }
86
87 };
88
89 // ==========================================================================================
90
91 class MEDMEM_EXPORT ENSIGHT_FIELD_RDONLY_DRIVER : public ENSIGHT_FIELD_DRIVER
92 {
93 public :
94   
95   /*!
96     Constructor to read the field of a specified name and index-th time step.
97     Append "_Im" to field name to select an imaginary part of a complex field
98   */
99   ENSIGHT_FIELD_RDONLY_DRIVER(const string & fileName, FIELD_ * ptrField, int step=1);
100
101   ENSIGHT_FIELD_RDONLY_DRIVER();
102   ENSIGHT_FIELD_RDONLY_DRIVER(const ENSIGHT_FIELD_RDONLY_DRIVER & fieldDriver);
103   ~ENSIGHT_FIELD_RDONLY_DRIVER();
104   virtual GENDRIVER * copy ( void ) const ;
105   virtual void merge ( const GENDRIVER& driver );
106
107   /*!
108     Read a field
109   */
110   void read ( void ) throw (MEDEXCEPTION);
111
112   /*!
113     Return a MEDEXCEPTION : it is a read-only driver.
114   */
115   void write( void ) const throw (MEDEXCEPTION) ;
116
117 private:
118
119   void readGoldASCII ();
120   void readGoldBinary();
121   void read6ASCII    ();
122   void read6Binary   ();
123
124   void skipTimeStamp(MEDMEM_ENSIGHT::_BinaryFileReader& fileReader);
125
126   int _fieldStep;
127 };
128
129 // ==========================================================================================
130
131 class MEDMEM_EXPORT ENSIGHT_FIELD_WRONLY_DRIVER : public ENSIGHT_FIELD_DRIVER
132 {
133 public :
134   
135   /*!
136     Constructor to append a field to the file
137   */
138   ENSIGHT_FIELD_WRONLY_DRIVER(const string & fileName, FIELD_ * ptrField);
139
140   ENSIGHT_FIELD_WRONLY_DRIVER();
141   ENSIGHT_FIELD_WRONLY_DRIVER(const ENSIGHT_FIELD_WRONLY_DRIVER & fieldDriver);
142   ~ENSIGHT_FIELD_WRONLY_DRIVER();
143   GENDRIVER * copy ( void ) const ;
144
145   /*!
146     Return a MEDEXCEPTION : it is the write-only driver.
147   */
148   void read ( void ) throw (MEDEXCEPTION) ;
149
150   /*!
151     Write FIELD in the specified file, the mesh is supposed to be
152     written in this file
153   */
154   void write( void ) const throw (MEDEXCEPTION) ;
155
156 };
157
158 }//End namespace MEDMEM
159
160 #endif /* ENSIGHT_FIELD_DRIVER_HXX */