Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / CONVERTOR / VISU_MedConvertor.hxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : VISU_MedConvertor.hxx
6 //  Author : Alexey PETROV
7 //  Module : VISU
8
9 #ifndef VISU_MedConvertor_HeaderFile
10 #define VISU_MedConvertor_HeaderFile
11
12 #include "VISU_Convertor_impl.hxx"
13
14 #include "MED_Common.hxx"
15 #include "MED_Structures.hxx"
16
17 #include <boost/thread/mutex.hpp>
18 #include <qfileinfo.h>
19
20 namespace VISU
21 {
22   typedef TVector<TName> TNames;
23
24   //---------------------------------------------------------------
25   class TMEDNamedPointCoords: public virtual TNamedPointCoords
26   {
27     MED::PNodeInfo myNodeInfo;
28     TNames myPointNames;
29   public:
30     void
31     Init(vtkIdType theNbPoints,
32          vtkIdType theDim,
33          const MED::PNodeInfo& theNodeInfo);
34
35     virtual
36     std::string 
37     GetNodeName(vtkIdType theObjID) const;
38   };
39   typedef SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
40
41
42   //---------------------------------------------------------------
43   struct TMEDMesh: virtual TMeshImpl
44   {
45     MED::PMeshInfo myMeshInfo;
46     MED::TEntityInfo myEntityInfo;
47   };
48   typedef SharedPtr<TMEDMesh> PMEDMesh;
49
50
51   //---------------------------------------------------------------
52   struct TMEDSubProfile: virtual TSubProfileImpl
53   {
54     MED::EGeometrieElement myMGeom;
55
56     TMEDSubProfile():
57       myIsElemNum(MED::eFAUX)
58     {}
59
60     MED::EBooleen myIsElemNum;
61     MED::TElemNum myElemNum;
62
63     virtual 
64     vtkIdType 
65     GetElemObjID(vtkIdType theID) const;
66   };
67   typedef SharedPtr<TMEDSubProfile> PMEDSubProfile;
68
69
70   //---------------------------------------------------------------
71   struct TMEDProfile: virtual TProfileImpl
72   {};
73   typedef SharedPtr<TMEDProfile> PMEDProfile;
74
75
76   //---------------------------------------------------------------
77   struct TMEDGauss: virtual TGaussImpl
78   {
79     MED::PGaussInfo myGaussInfo;
80
81     //! To define a way to implement more detail comparision of the TGaussSubMesh instances
82     virtual
83     void
84     LessThan(const PGaussImpl& theGauss,
85              bool& theResult) const;
86   };
87   typedef SharedPtr<TMEDGauss> PMEDGauss;
88
89
90   //---------------------------------------------------------------
91   struct TMEDGaussSubMesh: virtual TGaussSubMeshImpl
92   {
93     TMEDGaussSubMesh():
94       myIsElemNum(MED::eFAUX)
95     {}
96
97     MED::EBooleen myIsElemNum;
98     MED::TElemNum myElemNum;
99
100     virtual
101     TGaussPointID
102     GetObjID(vtkIdType theID,
103              vtkIdType theStartID) const;
104   };
105   typedef SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
106
107
108   //---------------------------------------------------------------
109   struct TMEDGaussMesh: virtual TGaussMeshImpl
110   {};
111   typedef SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
112
113
114   //---------------------------------------------------------------
115   struct TMEDSubMesh: virtual TSubMeshImpl
116   {
117     TMEDSubMesh():
118       myIsElemNum(MED::eFAUX)
119     {}
120
121     MED::EBooleen myIsElemNum;
122     MED::TElemNum myElemNum;
123     MED::PElemInfo myElemInfo;
124
125     void
126     Init(const MED::PElemInfo& theElemInfo);
127
128     virtual 
129     vtkIdType 
130     GetElemObjID(vtkIdType theID) const;
131
132     virtual
133     std::string 
134     GetElemName(vtkIdType theObjID) const;
135   };
136   typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
137
138
139   //---------------------------------------------------------------
140   typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
141
142   struct TMEDMeshOnEntity: virtual TMeshOnEntityImpl
143   {
144     TFamilyID2CellsSize myFamilyID2CellsSize;
145     MED::TGeom2Size myGeom2Size;
146   };
147   typedef SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
148
149
150   //---------------------------------------------------------------
151   struct TMEDFamily: virtual TFamilyImpl
152   {};
153   typedef SharedPtr<TMEDFamily> PMEDFamily;
154   
155
156   //---------------------------------------------------------------
157   struct TMEDGroup: virtual TGroupImpl
158   {};
159   typedef SharedPtr<TMEDGroup> PMEDGroup;
160
161
162   //---------------------------------------------------------------
163   struct TMEDField: virtual TFieldImpl
164   {};
165   typedef SharedPtr<TMEDField> PMEDField;
166
167
168   //---------------------------------------------------------------
169   struct TMEDValForTime: virtual TValForTimeImpl
170   {};
171   typedef SharedPtr<TMEDValForTime> PMEDValForTime;
172
173 }
174
175 class VISU_MedConvertor: public VISU_Convertor_impl
176 {  
177   VISU_MedConvertor();
178   VISU_MedConvertor(const VISU_MedConvertor&);
179   
180   bool myIsEntitiesDone;
181   bool myIsFieldsDone;
182   bool myIsGroupsDone;
183   bool myIsMinMaxDone;
184
185 public:
186   VISU_MedConvertor(const std::string& theFileName);
187
188   virtual
189   VISU_Convertor* 
190   BuildEntities();
191
192   virtual
193   VISU_Convertor* 
194   BuildFields();
195
196   virtual
197   VISU_Convertor* 
198   BuildMinMax();
199
200   virtual
201   VISU_Convertor* 
202   BuildGroups();
203
204 protected:
205   QFileInfo myFileInfo;
206
207   virtual
208   int
209   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
210                    VISU::PMeshOnEntityImpl theMeshOnEntity);
211   
212   virtual
213   int
214   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
215                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
216                      VISU::PFamilyImpl theFamily);
217
218   virtual
219   int
220   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
221                   const VISU::TFamilySet& theFamilySet);
222   
223   virtual
224   int
225   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
226                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
227                        VISU::PFieldImpl theField, 
228                        VISU::PValForTimeImpl theValForTime);
229   
230   virtual 
231   int
232   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
233                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
234                            VISU::PFieldImpl theField, 
235                            VISU::PValForTimeImpl theValForTime);
236
237   int
238   LoadPoints(const MED::PWrapper& theMed,
239              const VISU::PMEDMesh theMesh);
240   
241   int
242   LoadPointsOnFamily(const MED::PWrapper& theMed,
243                      const VISU::PMEDMesh theMesh, 
244                      const VISU::PMEDFamily theFamily);
245   
246   int
247   LoadCellsOnEntity(const MED::PWrapper& theMed,
248                     const VISU::PMEDMesh theMesh,
249                     const VISU::PMEDMeshOnEntity theMeshOnEntity);
250   
251   int
252   LoadCellsOnFamily(const MED::PWrapper& theMed,
253                     const VISU::PMEDMesh theMesh,
254                     const VISU::PMEDMeshOnEntity theMeshOnEntity,
255                     const VISU::PMEDFamily theFamily);
256   
257   int
258   LoadValForTimeOnMesh(const MED::PWrapper& theMed,
259                        VISU::PMEDMesh theMesh,
260                        VISU::PMEDMeshOnEntity theMeshOnEntity,
261                        VISU::PMEDField theField, 
262                        VISU::PMEDValForTime theValForTime);
263   
264   int
265   LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
266                            VISU::PMEDMesh theMesh,
267                            VISU::PMEDMeshOnEntity theMeshOnEntity,
268                            VISU::PMEDField theField, 
269                            VISU::PMEDValForTime theValForTime);
270 };
271
272 #endif