Salome HOME
Merge from V6_main 01/04/2013
[modules/paravis.git] / src / Plugins / MedReader / IO / vtkMedDriver.h
1 // Copyright (C) 2010-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __vtkMedDriver_h_
21 #define __vtkMedDriver_h_
22
23 #include "vtkObject.h"
24 #include "vtkMed.h"
25
26 class vtkMedFile;
27 class vtkMedMesh;
28 class vtkMedField;
29 class vtkMedFamily;
30 class vtkMedPolarGrid;
31 class vtkMedRegularGrid;
32 class vtkMedCurvilinearGrid;
33 class vtkMedUnstructuredGrid;
34 class vtkMedLocalization;
35 class vtkMedProfile;
36 class vtkMedFieldOverEntity;
37 class vtkMedEntityArray;
38 class vtkMedFieldStep;
39 class vtkMedGrid;
40 class vtkMedInterpolation;
41 class vtkMedFieldOnProfile;
42 class vtkMedStructElement;
43 class vtkMedConstantAttribute;
44 class vtkMedVariableAttribute;
45
46 class VTK_EXPORT vtkMedDriver: public vtkObject
47 {
48 public:
49   static vtkMedDriver* New();
50   vtkTypeMacro(vtkMedDriver, vtkObject)
51   void PrintSelf(ostream& os, vtkIndent indent);
52
53   // Description:
54   // Set/Get the med file that use this driver
55   virtual void  SetMedFile(vtkMedFile*);
56   vtkGetObjectMacro(MedFile, vtkMedFile);
57
58   // Description :
59   // This gives the File ID to read in parallel.
60   vtkGetMacro(ParallelFileId, med_idt);
61
62   // Description:
63   // open the file for reading. Returns 0 on success, or error code.
64   virtual int RestrictedOpen();
65   virtual int Open();
66   virtual void Close();
67   virtual bool CanReadFile();
68
69   // Description:
70   // Get the Version numbers from the file
71   virtual void ReadFileVersion(int* major, int* minor, int* release);
72
73   // Description:
74   // load all meta data associated with this file.
75   virtual void ReadFileInformation(vtkMedFile*);
76
77   // Description:
78   // load all meta data associated with this mesh.
79   virtual void ReadMeshInformation(vtkMedMesh*);
80
81   // Description:
82   // load all meta data associated with this field.
83   virtual void ReadFieldInformation(vtkMedField*);
84
85   // Description:
86   // load all meta data associated with this regular (Cartesian or polar) grid.
87   virtual void ReadRegularGridInformation(vtkMedRegularGrid*);
88
89   // Description:
90   // load all meta data associated with this standard grid.
91   virtual void ReadCurvilinearGridInformation(vtkMedCurvilinearGrid*);
92
93   // Description:
94   // load all meta data associated with this unstructured grid.
95   virtual void ReadUnstructuredGridInformation(vtkMedUnstructuredGrid*);
96
97   // Description:
98   // load all meta data associated with this grid.
99   // (call one of the above method depending on the type of grid)
100   virtual void ReadGridInformation(vtkMedGrid*);
101
102   // Description:
103   // load all meta data associated with this family.
104   virtual void ReadFamilyInformation(vtkMedMesh*, vtkMedFamily*);
105
106   // Description:
107   // load all meta data associated with this family.
108   virtual void ReadProfileInformation(vtkMedProfile*);
109
110   // Description:
111   // load information on a field and a given cell type at a given step
112   virtual void ReadFieldOverEntityInformation(vtkMedFieldOverEntity*);
113
114   // Description:
115   // load information related to the given quadrature scheme definition
116   virtual void ReadLocalizationInformation(vtkMedLocalization*);
117
118   // Description:
119   // load all information associated witht this field step
120   virtual void ReadFieldStepInformation(vtkMedFieldStep*, bool readAllEntityInfo);
121
122   // Description:
123   // load all information related to this interpolation function
124   virtual void ReadInterpolationInformation(vtkMedInterpolation*);
125
126   // Description:
127   // load all information related to this field on this profile
128   virtual void ReadFieldOnProfileInformation(vtkMedFieldOnProfile*);
129
130   // Description:
131   // read all information related to the structural elements models
132   // in this file
133   virtual void ReadStructElementInformation(vtkMedStructElement*);
134
135   // Description:
136   // read all information related to the support mesh
137   // in this file
138   virtual void ReadSupportMeshInformation(vtkMedMesh*);
139
140   // Description:
141   // read all information related to the support mesh
142   // in this file
143   virtual void ReadConstantAttributeInformation(vtkMedConstantAttribute*);
144
145   // Description:
146   // read all information related to the support mesh
147   // in this file
148   virtual void ReadVariableAttributeInformation(vtkMedVariableAttribute*);
149
150   // Description:
151   // load the field on this profile
152   virtual void LoadField(vtkMedFieldOnProfile* fop, med_storage_mode mode);
153
154   // Description:
155   // Load the indices of the profile
156   virtual void LoadProfile(vtkMedProfile* profile);
157
158   // Description:
159   // Load the values of the given step
160 //  void Load(vtkMedFieldOnProfile*);
161
162   virtual void LoadFamilyIds(vtkMedEntityArray*);
163
164   virtual void LoadCoordinates(vtkMedGrid*);
165
166   virtual void LoadPointGlobalIds(vtkMedGrid*);
167
168   //virtual void LoadPointFamilyIds(vtkMedGrid*);
169
170   virtual void LoadConnectivity(vtkMedEntityArray*);
171
172   virtual void LoadCellGlobalIds(vtkMedEntityArray*);
173
174   virtual void  LoadVariableAttribute(vtkMedVariableAttribute*,
175                                       vtkMedEntityArray*);
176
177   //BTX
178   class FileOpen
179   {
180   public:
181     FileOpen(vtkMedDriver* driver)
182     {
183       this->Driver = driver;
184       this->Driver->Open();
185     }
186     ~FileOpen()
187     {
188       this->Driver->Close();
189     }
190   protected:
191     vtkMedDriver* Driver;
192     vtkMedFile* File;
193   };
194   //ETX
195
196   //BTX
197   class FileRestrictedOpen
198   {
199   public:
200     FileRestrictedOpen(vtkMedDriver* driver)
201     {
202       this->Driver = driver;
203       this->Driver->RestrictedOpen();
204     }
205     ~FileRestrictedOpen()
206     {
207       this->Driver->Close();
208     }
209   protected:
210     vtkMedDriver* Driver;
211     vtkMedFile* File;
212   };
213   //ETX
214
215 protected:
216   vtkMedDriver();
217   ~vtkMedDriver();
218
219   // name of the file to read from
220   vtkMedFile * MedFile;
221
222   int OpenLevel;
223
224   med_idt FileId;
225   med_idt ParallelFileId;
226
227 private:
228   vtkMedDriver(const vtkMedDriver&); // Not implemented.
229   void operator=(const vtkMedDriver&); // Not implemented.
230 };
231
232 #endif //__vtkMedDriver_h_