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