Salome HOME
Merge from OCC_development_generic_2006
[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) const;
103   };
104   typedef SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
105
106
107   //---------------------------------------------------------------
108   struct TMEDGaussMesh: virtual TGaussMeshImpl
109   {};
110   typedef SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
111
112
113   //---------------------------------------------------------------
114   struct TMEDSubMesh: virtual TSubMeshImpl
115   {
116     TMEDSubMesh():
117       myIsElemNum(MED::eFAUX)
118     {}
119
120     MED::EBooleen myIsElemNum;
121     MED::TElemNum myElemNum;
122     MED::PElemInfo myElemInfo;
123
124     void
125     Init(const MED::PElemInfo& theElemInfo);
126
127     virtual 
128     vtkIdType 
129     GetElemObjID(vtkIdType theID) const;
130
131     virtual
132     std::string 
133     GetElemName(vtkIdType theObjID) const;
134   };
135   typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
136
137
138   //---------------------------------------------------------------
139   typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
140
141   struct TMEDMeshOnEntity: virtual TMeshOnEntityImpl
142   {
143     TFamilyID2CellsSize myFamilyID2CellsSize;
144     MED::TGeom2Size myGeom2Size;
145   };
146   typedef SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
147
148
149   //---------------------------------------------------------------
150   struct TMEDFamily: virtual TFamilyImpl
151   {};
152   typedef SharedPtr<TMEDFamily> PMEDFamily;
153   
154
155   //---------------------------------------------------------------
156   struct TMEDGroup: virtual TGroupImpl
157   {};
158   typedef SharedPtr<TMEDGroup> PMEDGroup;
159
160
161   //---------------------------------------------------------------
162   struct TMEDField: virtual TFieldImpl
163   {};
164   typedef SharedPtr<TMEDField> PMEDField;
165
166
167   //---------------------------------------------------------------
168   struct TMEDValForTime: virtual TValForTimeImpl
169   {};
170   typedef SharedPtr<TMEDValForTime> PMEDValForTime;
171
172 }
173
174 class VISU_MedConvertor: public VISU_Convertor_impl
175 {  
176   VISU_MedConvertor();
177   VISU_MedConvertor(const VISU_MedConvertor&);
178   
179   bool myIsEntitiesDone;
180   bool myIsFieldsDone;
181   bool myIsGroupsDone;
182   bool myIsMinMaxDone;
183
184 public:
185   VISU_MedConvertor(const std::string& theFileName);
186
187   virtual
188   VISU_Convertor* 
189   BuildEntities();
190
191   virtual
192   VISU_Convertor* 
193   BuildFields();
194
195   virtual
196   VISU_Convertor* 
197   BuildMinMax();
198
199   virtual
200   VISU_Convertor* 
201   BuildGroups();
202
203 protected:
204   QFileInfo myFileInfo;
205
206   virtual
207   int
208   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
209                    VISU::PMeshOnEntityImpl theMeshOnEntity);
210   
211   virtual
212   int
213   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
214                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
215                      VISU::PFamilyImpl theFamily);
216
217   virtual
218   int
219   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
220                   const VISU::TFamilySet& theFamilySet);
221   
222   virtual
223   int
224   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
225                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
226                        VISU::PFieldImpl theField, 
227                        VISU::PValForTimeImpl theValForTime);
228   
229   virtual 
230   int
231   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
232                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
233                            VISU::PFieldImpl theField, 
234                            VISU::PValForTimeImpl theValForTime);
235
236   int
237   LoadPoints(const MED::PWrapper& theMed,
238              const VISU::PMEDMesh theMesh);
239   
240   int
241   LoadPointsOnFamily(const MED::PWrapper& theMed,
242                      const VISU::PMEDMesh theMesh, 
243                      const VISU::PMEDFamily theFamily);
244   
245   int
246   LoadCellsOnEntity(const MED::PWrapper& theMed,
247                     const VISU::PMEDMesh theMesh,
248                     const VISU::PMEDMeshOnEntity theMeshOnEntity);
249   
250   int
251   LoadCellsOnFamily(const MED::PWrapper& theMed,
252                     const VISU::PMEDMesh theMesh,
253                     const VISU::PMEDMeshOnEntity theMeshOnEntity,
254                     const VISU::PMEDFamily theFamily);
255   
256   int
257   LoadValForTimeOnMesh(const MED::PWrapper& theMed,
258                        VISU::PMEDMesh theMesh,
259                        VISU::PMEDMeshOnEntity theMeshOnEntity,
260                        VISU::PMEDField theField, 
261                        VISU::PMEDValForTime theValForTime);
262   
263   int
264   LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
265                            VISU::PMEDMesh theMesh,
266                            VISU::PMEDMeshOnEntity theMeshOnEntity,
267                            VISU::PMEDField theField, 
268                            VISU::PMEDValForTime theValForTime);
269 };
270
271 #endif