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