]> SALOME platform Git repositories - modules/visu.git/blob - src/CONVERTOR/VISU_MedConvertor.cxx
Salome HOME
Fix of the following issues:
[modules/visu.git] / src / CONVERTOR / VISU_MedConvertor.cxx
1 //  Copyright (C) 2007-2008  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 //  VISU OBJECT : interactive object for VISU entities implementation
23 //  File   : VISU_MedConvertor.cxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //
27 #include "VISU_MedConvertor.hxx"
28 #include "VISU_ConvertorUtils.hxx"
29
30 #include "MED_Factory.hxx"
31 #include "MED_Algorithm.hxx"
32 #include "MED_GaussUtils.hxx"
33 #include "MED_Utilities.hxx"
34
35 #include "SALOMEconfig.h"
36
37 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
38 #define NO_CAS_CATCH
39 #endif
40
41 #include <Standard_Failure.hxx>
42
43 #ifdef NO_CAS_CATCH
44 #include <Standard_ErrorHandler.hxx>
45 #endif
46
47 #include <vtkCellType.h>
48
49 using MED::TInt;
50 using MED::TFloat;
51 using MED::EBooleen;
52
53 #ifdef _DEBUG_
54 static int MYDEBUG = 0;
55 static int MYVALUEDEBUG = 0;
56 static int MY_FAMILY_DEBUG = 0;
57 static int MY_GROUP_DEBUG = 0;
58 //#define _DEXCEPT_
59 #else
60 static int MYDEBUG = 0;
61 static int MYVALUEDEBUG = 0;
62 static int MY_FAMILY_DEBUG = 0;
63 static int MY_GROUP_DEBUG = 0;
64 #endif
65
66 #define _LOAD_FAMILIES_
67 #define _EDF_NODE_IDS_
68
69
70
71 namespace
72 {
73   //---------------------------------------------------------------
74   vtkIdType
75   MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
76   { 
77     return theMEDGeomType % 100;
78   }
79
80
81   //---------------------------------------------------------------
82   VISU::EGeometry
83   MEDGeom2VISU(MED::EGeometrieElement theGeom)
84   { 
85     switch(theGeom){
86     case MED::ePOINT1: return VISU::ePOINT1;
87     case MED::eSEG2: return VISU::eSEG2;
88     case MED::eTRIA3: return VISU::eTRIA3;
89     case MED::eQUAD4: return VISU::eQUAD4;
90     case MED::eTETRA4: return VISU::eTETRA4;
91     case MED::eHEXA8: return VISU::eHEXA8;
92     case MED::ePENTA6: return VISU::ePENTA6;
93     case MED::ePYRA5: return VISU::ePYRA5;
94
95     case MED::eSEG3: return VISU::eSEG3;
96     case MED::eTRIA6: return VISU::eTRIA6;
97     case MED::eQUAD8: return VISU::eQUAD8;
98     case MED::eTETRA10: return VISU::eTETRA10;
99     case MED::eHEXA20: return VISU::eHEXA20;
100     case MED::ePENTA15: return VISU::ePENTA15;
101     case MED::ePYRA13: return VISU::ePYRA13;
102
103     case MED::ePOLYGONE: return VISU::ePOLYGONE;
104     case MED::ePOLYEDRE: return VISU::ePOLYEDRE;
105     }
106     return VISU::eNONE;
107   }
108
109
110   //---------------------------------------------------------------
111   MED::EGeometrieElement 
112   VISUGeom2MED(int theGeom)
113   { 
114     switch(theGeom){
115     case VISU::ePOINT1: return MED::ePOINT1;
116     case VISU::eSEG2: return MED::eSEG2;
117     case VISU::eTRIA3: return MED::eTRIA3;
118     case VISU::eQUAD4: return MED::eQUAD4;
119     case VISU::eTETRA4: return MED::eTETRA4;
120     case VISU::eHEXA8: return MED::eHEXA8;
121     case VISU::ePENTA6: return MED::ePENTA6;
122     case VISU::ePYRA5: return MED::ePYRA5;
123
124     case VISU::eSEG3: return MED::eSEG3;
125     case VISU::eTRIA6: return MED::eTRIA6;
126     case VISU::eQUAD8: return MED::eQUAD8;
127     case VISU::eTETRA10: return MED::eTETRA10;
128     case VISU::eHEXA20: return MED::eHEXA20;
129     case VISU::ePENTA15: return MED::ePENTA15;
130     case VISU::ePYRA13: return MED::ePYRA13;
131
132     case VISU::ePOLYGONE: return MED::ePOLYGONE;
133     case VISU::ePOLYEDRE: return MED::ePOLYEDRE;
134     }
135     return MED::EGeometrieElement(-1);
136   }
137
138
139   //---------------------------------------------------------------
140   VISU::TEntity
141   MEDEntityToVTK( MED::EEntiteMaillage theMEDEntity )
142   {
143     VISU::TEntity anEntity = VISU::TEntity( -1 );
144
145     switch(theMEDEntity){
146     case MED::eNOEUD :
147       anEntity = VISU::NODE_ENTITY;
148       break;
149     case MED::eARETE : 
150       anEntity = VISU::EDGE_ENTITY;
151       break;
152     case MED::eFACE : 
153       anEntity = VISU::FACE_ENTITY;
154       break;
155     case MED::eMAILLE : 
156       anEntity = VISU::CELL_ENTITY;
157       break;
158     case MED::eNOEUD_ELEMENT :
159       anEntity = VISU::CELL_ENTITY;
160       break;
161     }
162
163     return anEntity;
164   }
165
166
167   //---------------------------------------------------------------
168   MED::EEntiteMaillage 
169   VTKEntityToMED(VISU::TEntity theVTKEntity)
170   {
171     switch(theVTKEntity){
172     case VISU::NODE_ENTITY: return MED::eNOEUD;
173     case VISU::EDGE_ENTITY: return MED::eARETE;
174     case VISU::FACE_ENTITY: return MED::eFACE;
175     case VISU::CELL_ENTITY: return MED::eMAILLE;
176     }
177     return MED::EEntiteMaillage(-1);
178   }
179
180
181   //---------------------------------------------------------------
182   VISU::PMEDSubProfile
183   CrSubProfile(const MED::PWrapper& theMEDWrapper,
184                const MED::PMeshInfo& theMeshInfo,
185                MED::EEntiteMaillage theMEntity,
186                MED::EGeometrieElement theMGeom,
187                const MED::TGeom2Size& theGeom2Size,
188                const MED::TGeom2Profile& theGeom2Profile)
189   {
190     VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
191     vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
192
193     VISU::PMEDSubProfile aSubProfile(new VISU::TMEDSubProfile());
194     aSubProfile->myGeom = aEGeom;
195     aSubProfile->myMGeom = theMGeom;
196     aSubProfile->myStatus = VISU::eAddAll;
197
198     MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom);
199     if(aTimeStampIter == theGeom2Size.end())
200       aSubProfile->myStatus = VISU::eRemoveAll;
201     else{
202       MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom);
203       if(aProfileIter != theGeom2Profile.end()){
204         MED::PProfileInfo aProfileInfo = aProfileIter->second;
205
206         aSubProfile->myName = aProfileInfo->GetName();
207         aSubProfile->myStatus = VISU::eAddPart;
208
209         const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
210         TInt aNbElem = anElemNum.size();
211         aSubProfile->myNbCells = aNbElem;
212         switch(theMGeom){
213         case MED::ePOLYGONE: {
214           MED::PPolygoneInfo aPolygoneInfo = 
215             theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
216           for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
217             TInt aNbConn = aPolygoneInfo->GetNbConn( anElemNum[ anElemId ] - 1 );
218             aSubProfile->myCellsSize += aNbConn;
219           }
220           break;
221         }
222         case MED::ePOLYEDRE: {
223           MED::PPolyedreInfo aPolyedreInfo = 
224             theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
225           for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
226             MED::TCConnSliceArr aConnSliceArr = 
227               aPolyedreInfo->GetConnSliceArr( anElemNum[ anElemId ] - 1 );
228             TInt aNbFaces = aConnSliceArr.size();
229             TInt aCellSize = 0;
230             for(TInt iFace = 0; iFace < aNbFaces; iFace++){
231               MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
232               TInt aNbConn = aConnSlice.size();
233               aCellSize += aNbConn;
234             }
235             aSubProfile->myCellsSize += aCellSize;
236           }
237           break;
238         }
239         default: {
240           aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
241         }}
242       }else{
243         TInt aNbElem = aTimeStampIter->second;
244         aSubProfile->myNbCells = aNbElem;
245         switch(theMGeom){
246         case MED::ePOLYGONE: {
247           MED::PPolygoneInfo aPolygoneInfo = 
248             theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
249           for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
250             TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
251             aSubProfile->myCellsSize += aNbConn;
252           }
253           break;
254         }
255         case MED::ePOLYEDRE: {
256           MED::PPolyedreInfo aPolyedreInfo = 
257             theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
258           for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
259             MED::TCConnSliceArr aConnSliceArr = 
260               aPolyedreInfo->GetConnSliceArr(anElemId);
261             TInt aNbFaces = aConnSliceArr.size();
262             TInt aCellSize = 0;
263             for(TInt iFace = 0; iFace < aNbFaces; iFace++){
264               MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
265               TInt aNbConn = aConnSlice.size();
266               aCellSize += aNbConn;
267             }
268             aSubProfile->myCellsSize += aCellSize;
269           }
270           break;
271         }
272         default: {
273           aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
274         }}
275       }
276     }
277     INITMSG(MYDEBUG,
278             "- aMGeom = "<<theMGeom<<
279             "; aEGeom = "<<aEGeom<<
280             "; aName = '"<<aSubProfile->myName<<"'"<<
281             "; aStatus = "<<aSubProfile->myStatus<<
282             "; aNbCells = "<<aSubProfile->myNbCells<<
283             "; aCellsSize = "<<aSubProfile->myCellsSize<<
284             endl);
285     
286     return aSubProfile;
287   }
288
289
290   //---------------------------------------------------------------
291   VISU::TProfileKey
292   GetProfileKey(const MED::PWrapper& theMEDWrapper,
293                 const MED::PMeshInfo& theMeshInfo,
294                 const MED::PTimeStampValueBase& theTimeStampValue,
295                 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
296                 MED::EEntiteMaillage theMEntity,
297                 const MED::TGeom2Size& theGeom2Size)
298   {
299     INITMSG(MYDEBUG,"GetProfileKey"<<endl);
300     
301     VISU::TProfileKey aProfileKey;
302     const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile();
303
304     const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
305     MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
306     for(; anIter != aGeom2Size.end(); anIter++){
307       MED::EGeometrieElement aMGeom = anIter->first;
308       VISU::PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
309                                                    theMeshInfo,
310                                                    theMEntity,
311                                                    aMGeom,
312                                                    theGeom2Size,
313                                                    aGeom2Profile);
314       aProfileKey.insert(aSubProfile);
315     }
316     
317     return aProfileKey;
318   }
319   
320
321   //---------------------------------------------------------------
322   void
323   InitProfile(const MED::PWrapper& theMEDWrapper,
324               const MED::PMeshInfo& theMeshInfo,
325               MED::PTimeStampValueBase& theTimeStampValue,
326               VISU::TMEDMeshOnEntity& theMeshOnEntity,
327               MED::EEntiteMaillage theMEntity,
328               const MED::TGeom2Size& theGeom2Size,
329               VISU::TMEDValForTime& theValForTime)
330   {
331     VISU::TTimerLog aTimerLog(MYDEBUG,"InitProfile");
332     INITMSG(MYDEBUG,"InitProfile"<<endl);
333     
334     VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
335     
336     VISU::TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
337                                             theMeshInfo,
338                                             theTimeStampValue,
339                                             theMeshOnEntity,
340                                             theMEntity,
341                                             theGeom2Size);
342     
343     VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
344     if(anIter != aProfileMap.end()){
345       theValForTime.myProfile = anIter->second;
346       INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<<endl);
347     }else{
348       VISU::PMEDProfile aProfile(new VISU::TMEDProfile());
349       VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
350       
351       VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
352       for(; anIter != aProfileKey.end(); anIter++){
353         VISU::PMEDSubProfile aSubProfile(*anIter);
354
355         if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
356           aProfile->myIsAll = false;
357
358         VISU::EGeometry aEGeom = aSubProfile->myGeom;
359         aGeom2SubProfile[aEGeom] = aSubProfile;
360       }
361
362       aProfileMap[aProfileKey] = aProfile;
363       theValForTime.myProfile = aProfile;
364     }
365   }
366
367
368   //---------------------------------------------------------------
369   VISU::TGaussKey
370   GetGaussKey(const MED::PTimeStampValueBase& theTimeStampValue,
371               const VISU::TMEDMeshOnEntity& theMeshOnEntity,
372               const MED::TGeom2Size& theGeom2Size,
373               VISU::TMEDValForTime& theValForTime)
374   {
375     VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
376     INITMSG(MYDEBUG,"GetGaussKey"<<endl);
377
378     VISU::TGaussKey aGaussKey;
379     VISU::PMEDProfile aProfile = theValForTime.myProfile;
380     VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
381
382     const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo();
383     const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
384
385     const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
386     MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
387     for(; anIter != aGeom2Size.end(); anIter++){
388       MED::EGeometrieElement aMGeom = anIter->first;
389       VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
390
391       VISU::TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
392       if(anIter2 == aGeom2SubProfile.end()){
393         INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
394         continue;
395       }
396       VISU::PMEDSubProfile aSubProfile = anIter2->second;
397
398       MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
399       if(aTimeStampIter != theGeom2Size.end()){
400         TInt aNbCells = aTimeStampIter->second;
401         if(aSubProfile->myStatus == VISU::eAddPart)
402           aNbCells = aSubProfile->myNbCells;
403
404         VISU::PMEDGaussSubMesh aGaussSubMesh(new VISU::TMEDGaussSubMesh());
405         aGaussSubMesh->mySubProfile = aSubProfile;
406         aGaussSubMesh->myStatus = aSubProfile->myStatus;
407           
408         VISU::PMEDGauss aGauss(new VISU::TMEDGauss());
409         aGaussSubMesh->myGauss = aGauss;
410         aGauss->myGeom = aEGeom;
411         aGauss->myNbPoints = 1;
412
413         MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
414         if(aGaussIter != aGeom2Gauss.end()){
415           MED::PGaussInfo aGaussInfo = aGaussIter->second;
416           aGauss->myGaussInfo = aGaussInfo;
417           aGauss->myName = aGaussInfo->GetName();
418           aGauss->myNbPoints = aGaussInfo->GetNbGauss();
419         } else if ( aTimeStampInfo.GetNbGauss(aMGeom) > 1 )
420           EXCEPTION( std::runtime_error, "aGaussIter == aGeom2Gauss.end()"
421                      " && aTimeStampInfo.GetNbGauss(aMGeom) > 1 !!!" );
422         
423         aGaussSubMesh->myNbCells = aNbCells*aGauss->myNbPoints;
424         aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2;
425
426         aGaussKey.insert(aGaussSubMesh);
427
428         INITMSGA(MYDEBUG,0,
429                  "- aEGeom = "<<aGauss->myGeom<<
430                  "; aName = '"<<aGauss->myName<<"'"<<
431                  "; aNbGauss = "<<aGauss->myNbPoints<<
432                  "; aStatus = "<<aGaussSubMesh->myStatus<<
433                  "; aNbCells = "<<aGaussSubMesh->myNbCells<<
434                  "; aCellsSize = "<<aGaussSubMesh->myCellsSize<<
435                  endl);
436
437         //break;
438       }
439     }
440
441     return aGaussKey;
442   }
443
444
445   //---------------------------------------------------------------
446   void
447   InitGaussMesh(MED::PTimeStampValueBase& theTimeStampValue,
448                 VISU::TMEDMeshOnEntity& theMeshOnEntity,
449                 const MED::TGeom2Size& theGeom2Size,
450                 VISU::TMEDValForTime& theValForTime)
451   {
452     VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
453     INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
454
455     if(theMeshOnEntity.myEntity == VISU::NODE_ENTITY)
456       return;
457
458     VISU::TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
459     
460     VISU::TGaussKey aGaussKey = GetGaussKey(theTimeStampValue,
461                                             theMeshOnEntity,
462                                             theGeom2Size,
463                                             theValForTime);
464
465     VISU::TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
466     if(anIter != aGaussMeshMap.end()){
467       theValForTime.myGaussMesh = anIter->second;
468       INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<<endl);
469     }else{
470       VISU::PMEDGaussMesh aGaussMesh(new VISU::TMEDGaussMesh());
471       VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
472       {
473         VISU::TGaussKey::const_iterator anIter = aGaussKey.begin();
474         for(; anIter != aGaussKey.end(); anIter++){
475           VISU::PMEDGaussSubMesh aGaussSubMesh(*anIter);
476           VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss;
477           VISU::EGeometry aEGeom = aGauss->myGeom;
478           aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh;
479         }
480       }
481       {
482         VISU::TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
483         aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size());
484         VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
485         for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){
486           const VISU::PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
487           aGaussSubMeshArr[anID] = aGaussSubMesh;
488         }
489       }
490       INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<std::endl);
491       aGaussMeshMap[aGaussKey] = aGaussMesh;
492       theValForTime.myGaussMesh = aGaussMesh;
493     }
494   }
495
496   //---------------------------------------------------------------
497   void
498   BuildMeshOnEntityMap(VISU::PMEDMesh theMesh,
499                        const MED::TEntityInfo& theEntityInfo,
500                        const MED::PNodeInfo& theNodeInfo,
501                        const MED::PWrapper& theMEDWrapper)
502   {
503     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
504     INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
505
506     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
507     const std::string& aMeshName = theMesh->myName;
508     VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
509     MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
510     for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
511       const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
512       const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
513       
514       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
515       VISU::PMEDMeshOnEntity aMeshOnEntity = 
516         aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity());
517       aMeshOnEntity->myEntity = aVEntity;
518       aMeshOnEntity->myMeshName = aMeshName;
519       aMeshOnEntity->myGeom2Size = aGeom2Size;
520       VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
521       VISU::TGeom2ElemID2FamilyID& aGeom2ElemID2FamilyID = aMeshOnEntity->myGeom2ElemID2FamilyID;
522
523       INITMSG(MYDEBUG,
524               "- aMEntity = "<<aMEntity<<
525               "; aVEntity = "<<aVEntity<<
526               endl);
527       
528       if(aMEntity == MED::eNOEUD){
529         aMeshOnEntity->myNbCells = theMesh->myNbPoints;
530         aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
531         
532         VISU::TElemID2FamilyID& anElemID2FamilyID = aGeom2ElemID2FamilyID[MED::ePOINT1];
533
534         for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
535           TInt aFamId = theNodeInfo->GetFamNum(iElem);
536           if(aFamId != 0)
537             aFamilyID2CellsSize[aFamId] += 2;
538           anElemID2FamilyID[iElem] = aFamId;
539         }
540         
541         INITMSG(MYDEBUG,
542                 "- myNbCells = "<<aMeshOnEntity->myNbCells<<
543                 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
544                 std::endl);
545         
546       }else{
547         MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
548         aMeshOnEntity->myNbCells = 0;
549         aMeshOnEntity->myCellsSize = 0;
550         for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
551           const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
552           
553           VISU::TElemID2FamilyID& anElemID2FamilyID = aGeom2ElemID2FamilyID[aMGeom];
554           switch(aMGeom){
555           case MED::ePOLYGONE: {
556             MED::PPolygoneInfo aPolygoneInfo = theMEDWrapper->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
557             TInt aNbElem = aPolygoneInfo->GetNbElem();
558             
559             INITMSG(MYDEBUG,
560                     "- aMGeom = "<<aMGeom<<
561                     "; aNbElem = "<<aNbElem<<
562                     endl);
563             
564             aMeshOnEntity->myNbCells += aNbElem;      
565             for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
566               TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
567               aMeshOnEntity->myCellsSize += aNbConn;
568               TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
569               if(aFamId != 0)
570                 aFamilyID2CellsSize[aFamId] += aNbConn + 1;
571               anElemID2FamilyID[anElemId] = aFamId;
572             }
573             break;
574           }
575           case MED::ePOLYEDRE: {
576             MED::PPolyedreInfo aPolyedreInfo = theMEDWrapper->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
577             TInt aNbElem = aPolyedreInfo->GetNbElem();
578             
579             INITMSG(MYDEBUG,
580                     "- aMGeom = "<<aMGeom<<
581                     "; aNbElem = "<<aNbElem<<
582                     endl);
583             
584             aMeshOnEntity->myNbCells += aNbElem;
585             for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
586               MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(anElemId);
587               TInt aNbFaces = aConnSliceArr.size();
588               TInt aCellSize = 0;
589               for(TInt iFace = 0; iFace < aNbFaces; iFace++){
590                 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
591                 TInt aNbConn = aConnSlice.size();
592                 aCellSize += aNbConn;
593               }
594               aMeshOnEntity->myCellsSize += aCellSize;
595               TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
596               if(aFamId != 0)
597                 aFamilyID2CellsSize[aFamId] += aCellSize + 1;
598               anElemID2FamilyID[anElemId] = aFamId;
599             }
600             break;
601           }
602           default: {
603             VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
604             vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
605             MED::PCellInfo aCellInfo = theMEDWrapper->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
606             TInt aNbElem = aCellInfo->GetNbElem();
607             aMeshOnEntity->myNbCells += aNbElem;
608             aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
609             
610             INITMSG(MYDEBUG,
611                     "- aMGeom = "<<aMGeom<<
612                     "; aNbElem = "<<aNbElem<<
613                     "; myNbCells = "<<aMeshOnEntity->myNbCells<<
614                     "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
615                     endl);
616             
617             for(TInt iElem = 0; iElem < aNbElem; iElem++){
618               TInt aFamId = aCellInfo->GetFamNum(iElem);
619               if(aFamId != 0)
620                 aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
621               anElemID2FamilyID[iElem] = aFamId;
622             }
623           }} // end switch(...)
624         }
625       }
626     }
627   }
628
629   //---------------------------------------------------------------
630   void
631   BuildMeshGrilleOnEntityMap(VISU::PMEDMesh theMesh,
632                              const MED::TEntityInfo& theEntityInfo,
633                              const MED::PGrilleInfo& theGrilleInfo,
634                              const MED::PWrapper& theMEDWrapper)
635   {
636     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMeshGrilleOnEntityMap");
637     INITMSG(MYDEBUG,"BuildMeshGrilleOnEntityMap"<<endl);
638     
639     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
640     const std::string& aMeshName = theMesh->myName;
641     VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
642     MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
643     
644     VISU::TStructuredId& aGrilleStructure = theMesh->myGrilleStructure;
645     if ( theGrilleInfo->GetGrilleType() != MED::eGRILLE_STANDARD )
646       for ( int aDimId = 0; aDimId < theMesh->myDim; aDimId++ )
647         aGrilleStructure[aDimId] = theGrilleInfo->GetNbIndexes(aDimId);
648     else {
649       MED::TIntVector aVector = theGrilleInfo->GetGrilleStructure();
650       for ( int aDimId = 0; aDimId < aVector.size(); aDimId++ )
651         aGrilleStructure[aDimId] = aVector[aDimId];
652     }
653
654     int kMax = aGrilleStructure[2];
655     int jMax = aGrilleStructure[1];
656     int iMax = aGrilleStructure[0];
657     
658     int iii = 0;
659     VISU::TObj2StructuredId& aObj2StructuredId = theMesh->myObj2StructuredId;
660     switch ( theMesh->myDim ) {
661     case 1:
662       for ( int i = 1; i <= iMax; i++ )
663         aObj2StructuredId[i-1][0] = i;
664       break;
665     case 2:
666       for ( int j = 1; j <= jMax; j++ )
667         for ( int i = 1; i <= iMax; i++ ) {
668           aObj2StructuredId[iii][0] = i;
669           aObj2StructuredId[iii][1] = j;
670           iii++;
671         }
672       break;
673     case 3:
674       for ( int k = 1; k <= kMax; k++ )
675         for ( int j = 1; j <= jMax; j++ )
676           for ( int i = 1; i <= iMax; i++ ) {
677             aObj2StructuredId[iii][0] = i;
678             aObj2StructuredId[iii][1] = j;
679             aObj2StructuredId[iii][2] = k;
680             iii++;
681           }
682     }
683     
684     for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
685       const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
686       const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
687       
688       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
689       VISU::PMEDMeshOnEntity aMeshOnEntity = 
690         aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity());
691       aMeshOnEntity->myEntity = aVEntity;
692       aMeshOnEntity->myMeshName = aMeshName;
693       aMeshOnEntity->myGeom2Size = aGeom2Size;
694       VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
695       VISU::TGeom2ElemID2FamilyID& aGeom2ElemID2FamilyID = aMeshOnEntity->myGeom2ElemID2FamilyID;
696
697       INITMSG(MYDEBUG,
698               "- aMEntity = "<<aMEntity<<
699               "; aVEntity = "<<aVEntity<<
700               endl);
701       
702       if(aMEntity == MED::eNOEUD){
703         aMeshOnEntity->myNbCells = theGrilleInfo->GetNbNodes();
704         aMeshOnEntity->myCellsSize = 2*theGrilleInfo->GetNbNodes();
705
706         VISU::TElemID2FamilyID& anElemID2FamilyID = aGeom2ElemID2FamilyID[MED::ePOINT1];
707
708         if((theGrilleInfo->myFamNumNode).size() > 0)
709         for(TInt iElem = 0; iElem < theGrilleInfo->GetNbNodes(); iElem++){
710           TInt aFamId = theGrilleInfo->GetFamNumNode(iElem);
711           if(aFamId != 0)
712             aFamilyID2CellsSize[aFamId] += 2;
713           anElemID2FamilyID[iElem] = aFamId;
714         }
715         
716         INITMSG(MYDEBUG,
717                 "- myNbCells = "<<aMeshOnEntity->myNbCells<<
718                 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
719                 endl);;
720         
721       } else {
722         MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
723         aMeshOnEntity->myNbCells = 0;
724         aMeshOnEntity->myCellsSize = 0;
725         for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
726           const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
727           VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
728           vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
729           TInt aNbElem = aGeom2SizeIter->second;//theGrilleInfo->GetNbCells();
730           aMeshOnEntity->myNbCells += aNbElem;
731           aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
732
733           VISU::TElemID2FamilyID& anElemID2FamilyID = aGeom2ElemID2FamilyID[aMGeom];
734           
735           INITMSG(MYDEBUG,
736                   "- aMGeom = "<<aMGeom<<
737                   "; aNbElem = "<<aNbElem<<
738                   "; myNbCells = "<<aMeshOnEntity->myNbCells<<
739                   "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
740                   endl);
741           
742           if((theGrilleInfo->myFamNum).size() > 0)
743           for(TInt iElem = 0; iElem < aNbElem; iElem++){
744             TInt aFamId = theGrilleInfo->GetFamNum(iElem);
745             if(aFamId != 0)
746               aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
747             anElemID2FamilyID[iElem] = aFamId;
748           }
749         }
750       }
751     }
752   }
753
754
755   //---------------------------------------------------------------
756   void
757   BuildFieldMap(VISU::PMEDMesh theMesh,
758                 const MED::TEntityInfo& theEntityInfo,
759                 MED::PWrapper theMEDWrapper)
760   {
761     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
762     TInt aNbFields = theMEDWrapper->GetNbFields(); 
763     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
764     const std::string& aMeshName = theMesh->myName;
765     INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
766     for(TInt iField = 1; iField <= aNbFields; iField++){
767       VISU::TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
768       
769       MED::TErr anError = 0;
770       MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo, iField, &anError);
771       if ( anError < 0 )
772         continue;
773
774       TInt aNbComp = aFieldInfo->GetNbComp();
775       std::string aFieldName = aFieldInfo->GetName();
776       
777       MED::TGeom2Size aGeom2Size;
778       MED::EEntiteMaillage aMEntity;
779       TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
780                                                           theEntityInfo,
781                                                           aMEntity,
782                                                           aGeom2Size);
783       if(aNbTimeStamps < 1)
784         continue;
785       
786       VISU::TEntity aVEntity = MEDEntityToVTK( aMEntity );
787       vtkIdType aDataType = VTK_DOUBLE;
788       if ( aFieldInfo->GetType() != MED::eFLOAT64 ) {
789 #if defined(HAVE_F77INT64)
790         aDataType = VTK_LONG;
791 #else   
792         aDataType = VTK_INT;
793 #endif
794       }
795       VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
796       VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
797       VISU::PMEDField aField = aFieldMap[aFieldName](new VISU::TMEDField());
798       aField->myId = iField;
799       aField->Init(aNbComp, aDataType);
800       aField->myEntity = aVEntity;
801       aField->myName = aFieldName;
802       aField->myMeshName = aMeshName;
803       aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
804       aField->myIsELNO = ( aMEntity == MED::eNOEUD_ELEMENT );
805
806       INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
807               "; myId = "<<aField->myId<<
808               "; myEntity = "<<aField->myEntity<<
809               "; myDataSize = "<<aField->myDataSize<<
810               "; myNbComp = "<<aField->myNbComp<<"\n");
811       
812       for(TInt iComp = 0; iComp < aNbComp; iComp++){
813         aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp);
814         aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp);
815       }
816       
817       for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
818         VISU::TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
819
820         MED::TErr anError = 0;
821         MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
822                                                                               aMEntity,
823                                                                               aGeom2Size,
824                                                                               iTimeStamp,
825                                                                               &anError);
826         if ( anError < 0 )
827           continue;
828
829         TFloat aDt = aTimeStampInfo->GetDt();
830         std::string anUnitDt = aTimeStampInfo->GetUnitDt();
831
832         VISU::TValField& aValField = aField->myValField;
833         VISU::PMEDValForTime aValForTime = aValField[iTimeStamp](new VISU::TMEDValForTime());
834         aValForTime->myId = iTimeStamp;
835         aValForTime->myFieldName = aField->myName;
836         aValForTime->myEntity = aField->myEntity;
837         aValForTime->myMeshName = aField->myMeshName;
838         aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
839         INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
840         
841         VISU::TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
842         const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss;
843         MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
844         for(; anIter != aMGeom2NbGauss.end(); anIter++){
845           const MED::EGeometrieElement& aMGeom = anIter->first;
846           VISU::EGeometry aEGeom = MEDGeom2VISU( aMGeom );
847           TInt aNbGauss = anIter->second;
848           aVGeom2NbGauss[ aEGeom ] = aNbGauss;
849
850           // ELNO data should satisfy the following condition ( implicitly )
851           vtkIdType aNbNodes = MEDGeom2NbNodes( aMGeom );
852           aField->myIsELNO &= ( aNbGauss == aNbNodes );
853         }
854       }
855     }
856   }
857
858
859   //---------------------------------------------------------------
860   void
861   BuildFamilyMap(VISU::PMEDMesh theMesh,
862                  const MED::TEntityInfo& theEntityInfo,
863                  const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
864                  const MED::TFamilyInfoSet& theFamilyInfoSet,
865                  MED::PWrapper theMEDWrapper)
866   {
867     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
868     INITMSG(MYDEBUG,"BuildFamilyMap\n");
869
870     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
871     MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
872     MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
873     for(; aEntity2FamilySetIter != aEntity2FamilySet.end(); aEntity2FamilySetIter++){
874       const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
875       const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
876       
877       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
878       VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
879       const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
880       VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
881       VISU::TFamilyIDMap& aFamilyIDMap = aMeshOnEntity->myFamilyIDMap;
882         
883       if(aFamilyTSizeSet.empty())
884         continue;
885         
886       INITMSG(MY_FAMILY_DEBUG,
887               "- aMEntity = "<<aMEntity<<
888               "; aVEntity = "<<aVEntity<<
889               endl);
890
891       MED::TFamilyTSizeSet::const_iterator aFamilyTSizeSetIter = aFamilyTSizeSet.begin();
892       for(; aFamilyTSizeSetIter != aFamilyTSizeSet.end(); aFamilyTSizeSetIter++){
893         const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
894         const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
895         TInt aSize = boost::get<1>(aFamilyTSize);
896         TInt anId = aFamilyInfo->GetId();
897         if(anId == 0) 
898           continue;
899         
900         std::string aFamilyName = aFamilyInfo->GetName();
901
902         VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily());
903         aFamily->myId = anId;
904         aFamily->myEntity = aVEntity;
905         aFamily->myName = aFamilyName;
906         aFamily->myNbCells = aSize;
907
908         aFamily->myCellsSize = 0;
909         VISU::TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
910         if(anIter != aFamilyID2CellsSize.end())
911           aFamily->myCellsSize = anIter->second;
912
913         const TInt aNbGroup = aFamilyInfo->GetNbGroup();
914         VISU::TNames& aGroupNames = aFamily->myGroupNames;
915         aGroupNames.resize(aNbGroup);
916         for(TInt i = 0; i < aNbGroup; i++){
917           std::string aGroupName = aFamilyInfo->GetGroupName(i);
918           aGroupNames[i] = aGroupName;
919         }
920
921         aFamilyIDMap[anId] = aFamily;
922
923         INITMSG(MY_FAMILY_DEBUG,
924                 "- aFamilyName = '"<<aFamilyName<<"'"<<
925                 "; myId = "<<aFamily->myId<<"; "<<
926                 "; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
927                 "; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
928                 "; aVEntity = "<<aVEntity<<
929                 "; myNbCells = "<<aFamily->myNbCells<<
930                 "; myCellsSize = "<<aFamily->myCellsSize<<
931                 endl);
932 #ifdef _DEBUG_  
933         for(TInt i = 0; i < aNbGroup; i++){
934           std::string aGroupName = aFamilyInfo->GetGroupName(i);
935           INITMSG(MY_FAMILY_DEBUG,"- aGroupName = '"<<aGroupName<<"'\n");
936         }
937 #endif
938
939       }
940     }
941   }
942
943   
944   /*!
945    * Build grille family map
946    */
947   void
948   BuildGrilleFamilyMap(VISU::PMEDMesh theMesh,
949                        const MED::TEntityInfo& theEntityInfo,
950                        const MED::TFamilyInfoSet& theFamilyInfoSet,
951                        MED::PWrapper theMEDWrapper)
952   {
953     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap");
954     INITMSG(MYDEBUG,"BuildGrilleFamilyMap\n");
955     
956     VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
957
958     MED::TEntityInfo::const_iterator aEntityIter = theEntityInfo.begin();
959
960     const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
961     MED::PGrilleInfo aGrilleInfo = theMEDWrapper->GetPGrilleInfo(aMeshInfo);
962
963     const MED::TFamilyID2NbCells& aFam2NbCells = MED::GetFamilyID2NbCells(aGrilleInfo);
964
965     MED::TFamilyInfoSet::const_iterator aFamInter = theFamilyInfoSet.begin();
966     for(; aFamInter != theFamilyInfoSet.end(); aFamInter++){
967       const MED::PFamilyInfo& aFamilyInfo = *aFamInter;
968       TInt anId = aFamilyInfo->GetId();
969
970       if(anId == 0)
971         continue;
972
973       std::string aFamilyName = aFamilyInfo->GetName();
974       const MED::EEntiteMaillage& aMEntity = MED::GetEntityByFamilyId(aGrilleInfo,
975                                                                       anId);
976       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
977
978       VISU::PMEDMeshOnEntity aMeshOnEntity;
979       VISU::TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity);
980       if(aMeshOnEntityIter != aMeshOnEntityMap.end())
981         aMeshOnEntity = aMeshOnEntityIter->second;
982
983       VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
984       VISU::TFamilyIDMap& aFamilyIDMap = aMeshOnEntity->myFamilyIDMap;
985
986       VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily());
987       aFamily->myId = anId;
988       aFamily->myEntity = aVEntity;
989       aFamily->myName = aFamilyName;
990       aFamily->myNbCells = 0;
991       aFamily->myCellsSize = 0;
992
993       const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
994       VISU::TFamilyID2CellsSize::const_iterator aFamilyid2CellsSizeIter = aFamilyID2CellsSize.find(anId);
995       if(aFamilyid2CellsSizeIter != (aMeshOnEntity->myFamilyID2CellsSize).end())
996         aFamily->myCellsSize = aFamilyid2CellsSizeIter->second;
997       MED::TFamilyID2NbCells::const_iterator aFam2NbCellsIter = aFam2NbCells.find(anId);
998       if(aFam2NbCellsIter != aFam2NbCells.end())
999         aFamily->myNbCells = aFam2NbCellsIter->second;
1000
1001       const TInt aNbGroup = aFamilyInfo->GetNbGroup();
1002       VISU::TNames& aGroupNames = aFamily->myGroupNames;
1003       aGroupNames.resize(aNbGroup);
1004       for(TInt i = 0; i < aNbGroup; i++){
1005         std::string aGroupName = aFamilyInfo->GetGroupName(i);
1006         aGroupNames[i] = aGroupName;
1007       }
1008
1009       aFamilyIDMap[anId] = aFamily;
1010
1011       INITMSG(MY_FAMILY_DEBUG,
1012               "- aFamilyName =|"<<aFamily->myName<<"|"
1013               << "; myId = "<<aFamily->myId
1014               << "; aNbAttr = "<<aFamilyInfo->GetNbAttr()
1015               << "; aNbGroup = "<<aFamilyInfo->GetNbGroup()
1016               << "; aVEntity = "<<aVEntity
1017               << "; myNbCells = "<<aFamily->myNbCells
1018               << "; myCellsSize = "<<aFamily->myCellsSize
1019               <<endl);
1020
1021
1022     }
1023   }
1024
1025   //---------------------------------------------------------------
1026   void
1027   BuildGroupMap(VISU::PMEDMesh theMesh,
1028                 const MED::TFamilyInfoSet& theFamilyInfoSet)
1029   {
1030     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
1031     INITMSG(MYDEBUG,"BuildGroupMap\n");
1032
1033     VISU::TGroupMap& aGroupMap = theMesh->myGroupMap;
1034     MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
1035     MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
1036     for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
1037       const std::string& aGroupName = aGroupInfoIter->first;
1038       INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
1039
1040       VISU::PMEDGroup aGroup(new VISU::TMEDGroup());
1041       VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
1042
1043       const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
1044       MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
1045       for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
1046         const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
1047         std::string aFamilyName = aFamilyInfo->GetName();
1048         
1049         VISU::TEntity aVEntity = VISU::TEntity(-1);
1050         VISU::PMEDFamily aFamily;
1051         
1052         // Find aVisuEntity
1053         const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
1054         VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
1055         for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
1056           const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
1057           const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1058           VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1059           for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1060             const std::string& aName = aFamilyMapIter->first;
1061             if(aName == aFamilyName){
1062               aFamily = aFamilyMapIter->second;
1063               aVEntity = aFamily->myEntity;
1064               goto exit_lable;
1065             }
1066           }
1067         } 
1068       exit_lable:
1069         if(aFamily && aVEntity >= 0){
1070           aFamilySet.insert(aFamily);
1071           INITMSG(MY_GROUP_DEBUG,
1072                   "- aFamilyName = '"<<aFamilyName<<"'"<<
1073                   "; aVEntity = "<<aVEntity<<
1074                   "\n");
1075         }
1076       }
1077       if(!aFamilySet.empty())
1078         aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
1079     }
1080   }
1081
1082
1083   //---------------------------------------------------------------
1084   struct TSetIsDone
1085   {
1086     bool& myIsDone;
1087     TSetIsDone(bool& theIsDone):
1088       myIsDone(theIsDone)
1089     {}
1090
1091     ~TSetIsDone()
1092     {
1093       myIsDone = true;
1094     }
1095
1096   };
1097
1098
1099   //---------------------------------------------------------------
1100 }
1101
1102 namespace VISU
1103 {
1104   //---------------------------------------------------------------
1105   void
1106   TMEDNamedPointCoords
1107   ::Init(const MED::PNodeInfo& theNodeInfo,
1108          MED::EVersion theVersion)
1109   {
1110     TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
1111     TInt aNbElem = theNodeInfo->GetNbElem();
1112     TInt aDim = theNodeInfo->GetMeshInfo()->GetDim();
1113     aCoordHolder->Init(aNbElem, aDim, theNodeInfo->myCoord);
1114     TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
1115     myVersion = theVersion;
1116
1117     for(TInt iDim = 0; iDim < aDim; iDim++)
1118       myPointsDim[iDim] = theNodeInfo->GetCoordName(iDim);
1119       
1120     myIsElemNum = theNodeInfo->IsElemNum();
1121     if(theNodeInfo->IsElemNum())
1122       myElemNum = theNodeInfo->myElemNum;
1123
1124     myIsElemNames = theNodeInfo->IsElemNames();
1125     if(theNodeInfo->IsElemNames())
1126       myElemNames = theNodeInfo->myElemNames;
1127   }
1128
1129   void
1130   TMEDNamedPointCoords
1131   ::Init(const MED::PGrilleInfo& theGrilleInfo)
1132   {
1133     TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
1134     TInt aNbElem = theGrilleInfo->GetNbNodes();
1135     TInt aDim = theGrilleInfo->GetMeshInfo()->GetDim();
1136     MED::PNodeCoord aCoord(new MED::TNodeCoord(aNbElem * aDim));
1137     aCoordHolder->Init(aNbElem, aDim, aCoord);
1138     TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
1139
1140     for(TInt iDim = 0; iDim < aDim; iDim++)
1141       myPointsDim[iDim] = theGrilleInfo->GetCoordName(iDim);
1142
1143     for(TInt iElem = 0; iElem < aNbElem; iElem++){
1144       VISU::TCoordSlice aVCoordSlice = GetCoordSlice(iElem);
1145       MED::TNodeCoord aMCoord = theGrilleInfo->GetCoord(iElem);
1146       for(TInt iDim = 0; iDim < aDim; iDim++){
1147         aVCoordSlice[iDim] = aMCoord[iDim];
1148       }
1149     }
1150   }
1151
1152   vtkIdType
1153   TMEDNamedPointCoords
1154   ::GetObjID(vtkIdType theID) const
1155   {
1156     if(myIsElemNum)
1157       return (*myElemNum)[theID];
1158     return TNamedPointCoords::GetObjID(theID);
1159   }
1160
1161
1162   vtkIdType
1163   TMEDNamedPointCoords
1164   ::GetVTKID(vtkIdType theID) const
1165   {
1166     if(myIsElemNum){
1167       // To prepare corresponding mapper engine
1168       if(myObj2VTKID.empty()){
1169         vtkIdType anEnd = myElemNum->size();
1170         for(vtkIdType anID = 0; anID < anEnd; anID++)
1171           myObj2VTKID[(*myElemNum)[anID]] = anID;
1172       }
1173       TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
1174       if(anIter != myObj2VTKID.end())
1175         return anIter->second;
1176       return -1;
1177     }
1178     return TNamedPointCoords::GetVTKID(theID);
1179   }
1180
1181   MED::TInt
1182   GetPNOMLength(MED::EVersion theVersion)
1183   {
1184     if(theVersion == MED::eV2_1)
1185       return MED::GetPNOMLength<MED::eV2_1>();
1186     return MED::GetPNOMLength<MED::eV2_2>();
1187   }
1188
1189   std::string 
1190   TMEDNamedPointCoords
1191   ::GetNodeName(vtkIdType theObjID) const
1192   {
1193     if(myIsElemNames)
1194       return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
1195     return TNamedPointCoords::GetNodeName(theObjID);
1196   }
1197
1198   unsigned long int
1199   TMEDNamedPointCoords
1200   ::GetMemorySize()
1201   {
1202     size_t aSize = TNamedPointCoords::GetMemorySize();
1203
1204     if(myElemNum){
1205       aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2;
1206       aSize += myElemNum->size() * sizeof(MED::TInt);
1207     }
1208
1209     if(myIsElemNames)
1210       aSize += myElemNames->size() * sizeof(char);
1211     return aSize;
1212   }
1213
1214
1215   //---------------------------------------------------------------
1216   vtkIdType
1217   TMEDSubProfile
1218   ::GetElemObjID(vtkIdType theID) const
1219   {
1220     if ( !mySubMeshID.empty() )
1221       theID = mySubMeshID[theID];
1222
1223     if ( myIsElemNum )
1224       return (*myElemNum)[theID];
1225     else
1226       return theID;
1227   }
1228   
1229
1230   //---------------------------------------------------------------
1231   vtkIdType
1232   TMEDSubProfile
1233   ::GetElemVTKID(vtkIdType theID) const
1234   {
1235     if ( myIsElemNum )
1236       for ( size_t anId = 0; anId < (*myElemNum).size(); anId++ ) 
1237         if ( (*myElemNum)[ anId ] == theID ) {
1238           theID = anId;
1239           break;
1240         }
1241
1242     return TSubProfileImpl::GetElemVTKID( theID );
1243   }
1244
1245
1246   //----------------------------------------------------------------
1247   unsigned long int
1248   TMEDSubProfile
1249   ::GetMemorySize()
1250   {
1251     size_t aSize = TSubProfileImpl::GetMemorySize();
1252     if(myIsElemNum)
1253       aSize += myElemNum->size() * sizeof(MED::TInt);
1254     return aSize;
1255   }
1256
1257
1258   //---------------------------------------------------------------
1259   void
1260   TMEDGauss
1261   ::LessThan(const PGaussImpl& theGauss,
1262              bool& theResult) const
1263   {
1264     TGaussImpl::LessThan(theGauss,theResult);
1265     if(myGaussInfo){
1266       if(PMEDGauss aGauss = theGauss){
1267         const MED::TGaussInfo& aLeft = myGaussInfo;
1268         const MED::TGaussInfo& aReight = aGauss->myGaussInfo;
1269         theResult = MED::TGaussInfo::TLess()(aLeft,aReight);
1270       }
1271     }
1272   }
1273
1274
1275   //---------------------------------------------------------------
1276   TGaussPointID
1277   TMEDGaussSubMesh
1278   ::GetObjID(vtkIdType theID) const
1279   {
1280     vtkIdType aNbPoints = myGauss->myNbPoints;
1281     TCellID aCellID = theID / aNbPoints;
1282     TLocalPntID aLocalPntID = theID % aNbPoints;
1283
1284     if ( myIsElemNum )
1285       aCellID = GetElemObjID(aCellID);
1286     else
1287       aCellID += myStartID;
1288
1289     return TGaussPointID(aCellID, aLocalPntID);
1290   }
1291   
1292   
1293   //---------------------------------------------------------------
1294   vtkIdType
1295   TMEDGaussSubMesh
1296   ::GetVTKID( const TGaussPointID& theID ) const
1297   {
1298     vtkIdType aResult = -1;
1299
1300     TCellID aCellID = theID.first;
1301     TLocalPntID aLocalPntID = theID.second;
1302     
1303     vtkIdType aNbPoints = myGauss->myNbPoints;
1304     if ( aLocalPntID >= aNbPoints )
1305       return aResult;
1306     
1307     if ( myIsElemNum ) {
1308       aCellID = GetElemVTKID( aCellID );
1309     } else
1310       aCellID -= myStartID;
1311
1312     return aCellID * aNbPoints + aLocalPntID + myStartID;
1313   }
1314
1315
1316   //---------------------------------------------------------------
1317   unsigned long int
1318   TMEDGaussSubMesh
1319   ::GetMemorySize()
1320   {
1321     size_t aSize = TGaussSubMeshImpl::GetMemorySize();
1322     if(myIsElemNum)
1323       aSize += myElemNum->size() * sizeof(MED::TInt);
1324     return aSize;
1325   }
1326
1327
1328   //---------------------------------------------------------------
1329   void
1330   TMEDSubMesh
1331   ::Init(const MED::PElemInfo& theElemInfo,
1332          MED::EVersion theVersion)
1333   {
1334     myVersion = theVersion;
1335     myIsElemNum = theElemInfo->IsElemNum();
1336     if(myIsElemNum)
1337       myElemNum = theElemInfo->myElemNum;
1338
1339     myIsElemNames = theElemInfo->IsElemNames();
1340     if(theElemInfo->IsElemNames())
1341       myElemNames = theElemInfo->myElemNames;
1342   }
1343
1344
1345   void
1346   TMEDSubMesh
1347   ::Init(const MED::PGrilleInfo& theGrilleInfo)
1348   {}
1349
1350   vtkIdType
1351   TMEDSubMesh
1352   ::GetElemObjID(vtkIdType theID) const
1353   {
1354     if(myIsElemNum)
1355       return (*myElemNum)[theID];
1356     else
1357       return TSubMeshImpl::GetElemObjID(theID);
1358   }
1359
1360   std::string 
1361   TMEDSubMesh
1362   ::GetElemName(vtkIdType theObjID) const
1363   {
1364     if(myIsElemNames)
1365       return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
1366     return TSubMeshImpl::GetElemName(theObjID);
1367   }
1368
1369   unsigned long int
1370   TMEDSubMesh
1371   ::GetMemorySize()
1372   {
1373     size_t aSize = TSubMeshImpl::GetMemorySize();
1374
1375     if(myIsElemNum)
1376       aSize += myElemNum->size() * sizeof(MED::TInt);
1377
1378     if(myIsElemNames)
1379       aSize += myElemNames->size() * sizeof(char);
1380
1381     return aSize;
1382   }
1383
1384
1385   //---------------------------------------------------------------
1386 }
1387
1388
1389 //---------------------------------------------------------------
1390 extern "C"
1391 VISU_Convertor* 
1392 CreateConvertor(const std::string& theFileName)
1393 {
1394   if(MED::PWrapper aMed = MED::CrWrapper(theFileName,true))
1395     return new VISU_MedConvertor(theFileName, aMed);
1396   return NULL;
1397 }
1398
1399 VISU_MedConvertor
1400 ::VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed):
1401   myIsEntitiesDone(false),
1402   myIsFieldsDone(false),
1403   myIsGroupsDone(false),
1404   myIsMinMaxDone(false),
1405   myMed(theMed)
1406 {
1407   myName = theFileName;
1408 }
1409
1410
1411 //---------------------------------------------------------------
1412 VISU_Convertor* 
1413 VISU_MedConvertor
1414 ::BuildEntities()
1415 {
1416   if(myIsEntitiesDone)
1417     return this;
1418
1419   TSetIsDone aSetIsDone(myIsEntitiesDone);
1420   VISU::TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
1421
1422   TInt aNbMeshes = myMed->GetNbMeshes();
1423   VISU::TMeshMap& aMeshMap = myMeshMap;
1424
1425   INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
1426
1427   for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1428 #ifndef _DEXCEPT_
1429     try{
1430 #endif
1431       VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1432
1433       MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1434       std::string aMeshName = aMeshInfo->GetName();
1435       TInt aDim = aMeshInfo->GetDim();
1436       MED::EMaillage aType = aMeshInfo->GetType();
1437         
1438       // creating TMesh structure and TMeshOnEntityMap         
1439       VISU::PMEDMesh aMesh = aMeshMap[aMeshName](new VISU::TMEDMesh());
1440       
1441       aMesh->myDim = aDim;
1442       aMesh->myName = aMeshName;
1443       aMesh->myMeshInfo = aMeshInfo;
1444       aMesh->myNamedPointCoords(new VISU::TMEDNamedPointCoords());
1445       
1446       INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
1447               "; aDim = "<<aDim<<"\n");
1448
1449       if(aType == MED::eNON_STRUCTURE){
1450
1451         if(MED::PNodeInfo aNodeInfo = myMed->GetPNodeInfo(aMeshInfo)){
1452           MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1453
1454           aMesh->myNbPoints = aNodeInfo->GetNbElem();
1455           aMesh->myEntityInfo = anEntityInfo;
1456         
1457         
1458 #ifndef _DEXCEPT_
1459           try{
1460 #endif
1461             INITMSG(MYDEBUG,"myNbPoints = "<<aMesh->myNbPoints<<
1462                     "; anEntityInfo.size() = "<<anEntityInfo.size()<<
1463                     "\n");
1464             
1465             BuildMeshOnEntityMap(aMesh,
1466                                  anEntityInfo,
1467                                  aNodeInfo,
1468                                  myMed);
1469             
1470 #ifndef _DEXCEPT_
1471           }catch(std::exception& exc){
1472             MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1473           }catch(...){
1474             MSG(MYDEBUG,"Unknown exception !!!");
1475           }
1476 #endif
1477         }
1478       } // NON STRUCTURED MESH
1479       else {
1480         MED::PGrilleInfo aGrilleInfo = myMed->GetPGrilleInfo(aMeshInfo);
1481
1482         MED::TEntityInfo anEntityInfo;
1483         anEntityInfo[MED::eNOEUD][MED::ePOINT1] = aGrilleInfo->GetNbNodes();
1484         anEntityInfo[aGrilleInfo->GetEntity()][aGrilleInfo->GetGeom()] = aGrilleInfo->GetNbCells();
1485         
1486         aMesh->myNbPoints   = aGrilleInfo->GetNbNodes();
1487         aMesh->myEntityInfo = anEntityInfo;
1488
1489         aMesh->myIsPolarType = (MED::eGRILLE_POLAIRE == aGrilleInfo->GetGrilleType());
1490         aMesh->myIsStructured = true;
1491 #ifndef _DEXCEPT_
1492         try{
1493 #endif
1494           BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
1495           
1496           BuildMeshGrilleOnEntityMap(aMesh,
1497                                      anEntityInfo,
1498                                      aGrilleInfo,
1499                                      myMed);
1500           
1501 #ifndef _DEXCEPT_
1502         }catch(std::exception& exc){
1503           MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1504         }catch(...){
1505           MSG(MYDEBUG,"Unknown exception !!!");
1506         }
1507 #endif
1508
1509       }
1510
1511 #ifndef _DEXCEPT_
1512     }catch(std::exception& exc){
1513       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1514     }catch(...){
1515       MSG(MYDEBUG,"Unknown exception !!!");
1516     }
1517 #endif
1518   } 
1519
1520   return this; 
1521 }
1522
1523
1524 //---------------------------------------------------------------
1525 VISU_Convertor* 
1526 VISU_MedConvertor
1527 ::BuildFields()
1528 {
1529   if(myIsFieldsDone)
1530     return this;
1531
1532   VISU_Convertor_impl::BuildFields();
1533
1534   TSetIsDone aSetIsDone(myIsFieldsDone);
1535   VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFields");
1536
1537   TInt aNbMeshes = myMed->GetNbMeshes();
1538   VISU::TMeshMap& aMeshMap = myMeshMap;
1539
1540   INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
1541
1542   for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1543 #ifndef _DEXCEPT_
1544     try{
1545 #endif
1546       VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1547
1548       MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1549       std::string aMeshName = aMeshInfo->GetName();
1550       
1551       VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1552       if(anIter == aMeshMap.end())
1553         continue;
1554       VISU::PMEDMesh aMesh = anIter->second;
1555
1556       INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1557 #ifndef _DEXCEPT_
1558       try{
1559 #endif
1560         MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1561
1562         BuildFieldMap(aMesh,
1563                       anEntityInfo,
1564                       myMed);
1565 #ifndef _DEXCEPT_
1566       }catch(std::exception& exc){
1567         MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1568       }catch(...){
1569         MSG(MYDEBUG,"Unknown exception !!!");
1570       }
1571 #endif
1572
1573 #ifndef _DEXCEPT_
1574     }catch(std::exception& exc){
1575       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1576     }catch(...){
1577       MSG(MYDEBUG,"Unknown exception !!!");
1578     }
1579 #endif
1580   } 
1581
1582   return this; 
1583 }
1584
1585
1586 //---------------------------------------------------------------
1587 template<class TimeStampValueType>
1588 void
1589 BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
1590                      const VISU::PMEDMeshOnEntity theMeshOnEntity,
1591                      const MED::TGeom2Gauss& theGeom2Gauss,
1592                      VISU::TMinMaxArr& theMinMaxArr,
1593                      VISU::TMinMaxArr& theAverageMinMaxArr,
1594                      VISU::TGroup2MinMaxArr& theGroup2MinMaxArr,
1595                      VISU::TGroup2MinMaxArr& theGroup2AverageMinMaxArr,
1596                      TInt theNbComp,
1597                      TInt theNbComp2)
1598 {
1599   const VISU::TFamilyIDMap& aFamilyIDMap = theMeshOnEntity->myFamilyIDMap;
1600   VISU::TGeom2ElemID2FamilyID aGeom2ElemID2FamilyID = theMeshOnEntity->myGeom2ElemID2FamilyID;
1601
1602   const typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
1603   typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
1604   for(; anIter != aGeom2Value.end(); anIter++){
1605     const typename TimeStampValueType::TTMeshValue& aMMeshValue = anIter->second;
1606     MED::EGeometrieElement aMGeom = anIter->first;
1607                   
1608     TInt aNbElem = aMMeshValue.myNbElem;
1609     TInt aNbGauss = aMMeshValue.myNbGauss;
1610                   
1611     MED::TGeom2Gauss::const_iterator aGaussIter = theGeom2Gauss.find(aMGeom);
1612     if(aGaussIter == theGeom2Gauss.end())
1613       aNbGauss = 1;
1614                   
1615     INITMSG(MYDEBUG,
1616             "- aMGeom = "<<aMGeom<<
1617             "; aNbElem = "<<aNbElem<<
1618             "; aNbGauss = "<<aNbGauss<<
1619             endl);
1620
1621     VISU::TElemID2FamilyID anElemID2FamilyID = aGeom2ElemID2FamilyID[aMGeom];
1622     
1623     bool isAverageByGaussPoints = (aNbGauss > 1);
1624     // To calculate min/max per components
1625     for(TInt iElem = 0; iElem < aNbElem; iElem++){
1626       typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
1627       for(TInt iComp = 0; iComp < theNbComp; iComp++){
1628         const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
1629         VISU::TMinMax& aMinMax = theMinMaxArr[iComp+1];
1630         vtkFloatingPointType& aMin = aMinMax.first;
1631         vtkFloatingPointType& aMax = aMinMax.second;
1632         VISU::TMinMax& anAverageMinMax = theAverageMinMaxArr[iComp+1];
1633         vtkFloatingPointType& anAverageMin = anAverageMinMax.first;
1634         vtkFloatingPointType& anAverageMax = anAverageMinMax.second;
1635         vtkFloatingPointType anAverageValue = 0.0;
1636
1637         VISU::TGroup2MinMax& aGroup2MinMax = theGroup2MinMaxArr[iComp+1];
1638         VISU::TGroup2MinMax& aGroup2AverageMinMax = theGroup2AverageMinMaxArr[iComp+1];
1639         std::map<VISU::TName,vtkFloatingPointType> aGroup2AverageValue;
1640
1641         // get names of groups, to which the element belongs
1642         VISU::TNames aGroupNames;
1643         VISU::TElemID2FamilyID::const_iterator anIter = anElemID2FamilyID.find(iElem);
1644         if(anIter != anElemID2FamilyID.end()){
1645           int aFamilyId = anIter->second;
1646           if(aFamilyId != 0){
1647             VISU::TFamilyIDMap::const_iterator aFamilyIter = aFamilyIDMap.find(aFamilyId);
1648             if(aFamilyIter != aFamilyIDMap.end()){
1649               VISU::PMEDFamily aFamily = aFamilyIter->second;
1650               aGroupNames = aFamily->myGroupNames;
1651               VISU::TNames::const_iterator aGroupIter = aGroupNames.begin();
1652               for(; aGroupIter != aGroupNames.end(); aGroupIter++)
1653                 aGroup2AverageValue[*aGroupIter] = 0.0;
1654             }
1655           }
1656         }
1657
1658         for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1659           const vtkFloatingPointType& aVal = aMValueSlice[iGauss];
1660           aMin = std::min(aMin,aVal);
1661           aMax = std::max(aMax,aVal);          
1662           if(isAverageByGaussPoints){
1663             anAverageValue += aVal;
1664           }
1665           else {
1666             anAverageMin = aMin;
1667             anAverageMax = aMax;
1668           }
1669
1670           // additional calculation for each group, to which the element belongs
1671           VISU::TNames::const_iterator aGroupIter = aGroupNames.begin();
1672           for(; aGroupIter != aGroupNames.end(); aGroupIter++){
1673             VISU::TName aGroupName = *aGroupIter;
1674             bool isGroupFound = aGroup2MinMax.find(aGroupName) != aGroup2MinMax.end();
1675             VISU::TMinMax& aGroupMinMax = aGroup2MinMax[aGroupName];
1676             vtkFloatingPointType& aGroupMin = aGroupMinMax.first;
1677             vtkFloatingPointType& aGroupMax = aGroupMinMax.second;
1678             aGroupMin = isGroupFound ? std::min(aGroupMin,aVal) : aVal;
1679             aGroupMax = isGroupFound ? std::max(aGroupMax,aVal) : aVal;          
1680
1681             if(isAverageByGaussPoints){
1682               aGroup2AverageValue[aGroupName] = aGroup2AverageValue[aGroupName] + aVal;
1683             }
1684             else {
1685               VISU::TMinMax& aGroupAverageMinMax = aGroup2AverageMinMax[aGroupName];
1686               vtkFloatingPointType& aGroupAverageMin = aGroupAverageMinMax.first;
1687               vtkFloatingPointType& aGroupAverageMax = aGroupAverageMinMax.second;
1688               aGroupAverageMin = aGroupMin;
1689               aGroupAverageMax = aGroupMax;
1690             }
1691           }
1692         }
1693         if(isAverageByGaussPoints){
1694           anAverageValue /= aNbGauss;
1695           anAverageMin = std::min(anAverageMin,anAverageValue);
1696           anAverageMax = std::max(anAverageMax,anAverageValue);
1697
1698           VISU::TNames::const_iterator aGroupIter = aGroupNames.begin();
1699           for(; aGroupIter != aGroupNames.end(); aGroupIter++){
1700             VISU::TName aGroupName = *aGroupIter;
1701             vtkFloatingPointType aGroupAverageValue = aGroup2AverageValue[aGroupName] / aNbGauss;
1702             bool isGroupFound = aGroup2AverageMinMax.find(aGroupName) != aGroup2AverageMinMax.end();
1703             VISU::TMinMax& aGroupAverageMinMax = aGroup2AverageMinMax[aGroupName];
1704             vtkFloatingPointType& aGroupAverageMin = aGroupAverageMinMax.first;
1705             vtkFloatingPointType& aGroupAverageMax = aGroupAverageMinMax.second;
1706             aGroupAverageMin = isGroupFound ? std::min(aGroupAverageMin,aGroupAverageValue) : aGroupAverageValue;
1707             aGroupAverageMax = isGroupFound ? std::max(aGroupAverageMax,aGroupAverageValue) : aGroupAverageValue;
1708           }
1709         }
1710       }
1711     }
1712                   
1713     // To calculate min/max per vector modulus
1714     VISU::TMinMax& aMinMax = theMinMaxArr[0];
1715     vtkFloatingPointType& aMin = aMinMax.first;
1716     vtkFloatingPointType& aMax = aMinMax.second;
1717     VISU::TMinMax& anAverageMinMax = theAverageMinMaxArr[0];
1718     vtkFloatingPointType& anAverageMin = anAverageMinMax.first;
1719     vtkFloatingPointType& anAverageMax = anAverageMinMax.second;
1720
1721     VISU::TGroup2MinMax& aGroup2MinMax = theGroup2MinMaxArr[0];
1722     VISU::TGroup2MinMax& aGroup2AverageMinMax = theGroup2AverageMinMaxArr[0];
1723
1724     for(TInt iElem = 0; iElem < aNbElem; iElem++){
1725       typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
1726
1727       // get names of groups, to which the element belongs
1728       VISU::TNames aGroupNames;
1729       VISU::TElemID2FamilyID::const_iterator anIter = anElemID2FamilyID.find(iElem);
1730       if(anIter != anElemID2FamilyID.end()){
1731         int aFamilyId = anIter->second;
1732         if(aFamilyId != 0){
1733           VISU::TFamilyIDMap::const_iterator aFamilyIter = aFamilyIDMap.find(aFamilyId);
1734           if(aFamilyIter != aFamilyIDMap.end()){
1735             VISU::PMEDFamily aFamily = aFamilyIter->second;
1736             aGroupNames = aFamily->myGroupNames;
1737           }
1738         }
1739       }
1740
1741       for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1742         const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
1743         vtkFloatingPointType aValue = 0.0;
1744         for(TInt iComp = 0; iComp < theNbComp2; iComp++){
1745           vtkFloatingPointType aVal = aMValueSlice[iComp];
1746           aValue += aVal*aVal;
1747         }
1748         aValue = sqrt(aValue);
1749         aMin = std::min(aMin,aValue);
1750         aMax = std::max(aMax,aValue);
1751
1752         // additional calculation for each group, to which the element belongs
1753         VISU::TNames::const_iterator aGroupIter = aGroupNames.begin();
1754         for(; aGroupIter != aGroupNames.end(); aGroupIter++){
1755           VISU::TName aGroupName = *aGroupIter;
1756           bool isGroupFound = aGroup2MinMax.find(aGroupName) != aGroup2MinMax.end();
1757           VISU::TMinMax& aGroupMinMax = aGroup2MinMax[aGroupName];
1758           vtkFloatingPointType& aGroupMin = aGroupMinMax.first;
1759           vtkFloatingPointType& aGroupMax = aGroupMinMax.second;
1760           aGroupMin = isGroupFound ? std::min(aGroupMin,aValue) : aValue;
1761           aGroupMax = isGroupFound ? std::max(aGroupMax,aValue) : aValue;
1762         }
1763       }
1764       if(isAverageByGaussPoints){
1765         typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMCompValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
1766         vtkFloatingPointType aValue = 0.0;
1767         for(TInt iComp = 0; iComp < theNbComp2; iComp++){
1768           const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMCompValueSlice = aMCompValueSliceArr[iComp];
1769           vtkFloatingPointType anAverageValue = 0.0;
1770           for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1771             const vtkFloatingPointType& aVal = aMCompValueSlice[iGauss];
1772             anAverageValue += aVal;
1773           }
1774           anAverageValue /= aNbGauss;
1775           aValue += anAverageValue*anAverageValue;
1776         }
1777         aValue = sqrt(aValue);
1778         anAverageMin = std::min(anAverageMin,aValue);
1779         anAverageMax = std::max(anAverageMax,aValue);
1780
1781         // additional calculation for each group, to which the element belongs
1782         VISU::TNames::const_iterator aGroupIter = aGroupNames.begin();
1783         for(; aGroupIter != aGroupNames.end(); aGroupIter++){
1784           VISU::TName aGroupName = *aGroupIter;
1785           bool isGroupFound = aGroup2AverageMinMax.find(aGroupName) != aGroup2AverageMinMax.end();
1786           VISU::TMinMax& aGroupAverageMinMax = aGroup2AverageMinMax[aGroupName];
1787           vtkFloatingPointType& aGroupAverageMin = aGroupAverageMinMax.first;
1788           vtkFloatingPointType& aGroupAverageMax = aGroupAverageMinMax.second;
1789           aGroupAverageMin = isGroupFound ? std::min(aGroupAverageMin,aValue) : aValue;
1790           aGroupAverageMax = isGroupFound ? std::max(aGroupAverageMax,aValue) : aValue;
1791         }
1792       }
1793       else {
1794         anAverageMin = aMin;
1795         anAverageMax = aMax;
1796
1797         // additional calculation for each group, to which the element belongs
1798         VISU::TNames::const_iterator aGroupIter = aGroupNames.begin();
1799         for(; aGroupIter != aGroupNames.end(); aGroupIter++){
1800           VISU::TName aGroupName = *aGroupIter;
1801           VISU::TMinMax& aGroupAverageMinMax = aGroup2AverageMinMax[aGroupName];
1802           vtkFloatingPointType& aGroupAverageMin = aGroupAverageMinMax.first;
1803           vtkFloatingPointType& aGroupAverageMax = aGroupAverageMinMax.second;
1804           aGroupAverageMin = aGroup2MinMax[aGroupName].first;
1805           aGroupAverageMax = aGroup2MinMax[aGroupName].second;
1806         }
1807       }
1808     }
1809   }
1810 }
1811
1812   
1813 //---------------------------------------------------------------
1814 VISU_Convertor* 
1815 VISU_MedConvertor
1816 ::BuildMinMax()
1817 {
1818   if(myIsMinMaxDone)
1819     return this;
1820
1821   VISU_Convertor_impl::BuildMinMax();
1822
1823   TSetIsDone aSetIsDone(myIsMinMaxDone);
1824   VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
1825
1826   MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(myMed);
1827   MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(myMed);
1828
1829   TInt aNbMeshes = myMed->GetNbMeshes();
1830   VISU::TMeshMap& aMeshMap = myMeshMap;
1831
1832   INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
1833
1834   for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1835 #ifndef _DEXCEPT_
1836     try{
1837 #endif
1838       VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
1839
1840       MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1841       std::string aMeshName = aMeshInfo->GetName();
1842       
1843       VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1844       if(anIter == aMeshMap.end())
1845         continue;
1846       VISU::PMEDMesh aMesh = anIter->second;
1847
1848 #ifndef _DEXCEPT_
1849       try{
1850 #endif
1851         TInt aNbFields = myMed->GetNbFields(); 
1852
1853         INITMSG(MYDEBUG,
1854                 "- aMeshName = '"<<aMeshName<<"'"<<
1855                 "; aNbFields = "<<aNbFields<<"\n");
1856
1857         MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1858
1859         for(TInt iField = 1; iField <= aNbFields; iField++){
1860           VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
1861
1862           MED::TErr anError = 0;
1863           MED::PFieldInfo aFieldInfo = myMed->GetPFieldInfo(aMeshInfo, iField, &anError);
1864           if ( anError < 0 )
1865             continue;
1866
1867           std::string aFieldName = aFieldInfo->GetName();
1868           INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
1869           
1870           MED::TGeom2Size aGeom2Size;
1871           MED::EEntiteMaillage aMEntity;
1872           TInt aNbTimeStamps = myMed->GetNbTimeStamps(aFieldInfo,
1873                                                      anEntityInfo,
1874                                                      aMEntity,
1875                                                      aGeom2Size);
1876           if(aNbTimeStamps < 1)
1877             continue;
1878         
1879           VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
1880           VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
1881           VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1882           VISU::PMEDField aField = aFieldMap[aFieldName];
1883         
1884           TInt aNbComp = aField->myNbComp;
1885           int aNbComp2 = aNbComp;
1886           if(aNbComp == 2 || aNbComp == 4)
1887             aNbComp2 = 2;
1888           else if(aNbComp > 4)
1889             aNbComp2 = 3;
1890
1891           VISU::TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
1892           VISU::TMinMaxArr& anAverageMinMaxArr = aField->myAverageMinMaxArr;
1893           VISU::TGroup2MinMaxArr& aGroup2MinMaxArr = aField->myGroup2MinMaxArr;
1894           VISU::TGroup2MinMaxArr& aGroup2AverageMinMaxArr = aField->myGroup2AverageMinMaxArr;
1895           TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
1896           for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
1897             VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
1898             INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
1899             
1900 #ifndef _DEXCEPT_
1901             try {
1902 #ifdef NO_CAS_CATCH
1903               OCC_CATCH_SIGNALS;
1904 #endif
1905 #endif
1906               MED::PTimeStampInfo aTimeStampInfo = 
1907                 myMed->GetPTimeStampInfo(aFieldInfo,
1908                                          aMEntity,
1909                                          aGeom2Size,
1910                                          iTimeStamp);
1911
1912               MED::PTimeStampValueBase aTimeStampValue = 
1913                 myMed->GetPTimeStampValue(aTimeStampInfo,
1914                                           aMKey2Profile,
1915                                           aKey2Gauss);
1916
1917               const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
1918
1919               if(aFieldInfo->GetType() == MED::eFLOAT64)
1920                 BuildTimeStampMinMax<MED::TFloatTimeStampValue>(CastToFloatTimeStampValue(aTimeStampValue),
1921                                                                 aMeshOnEntity,
1922                                                                 aGeom2Gauss,
1923                                                                 aMinMaxArr,
1924                                                                 anAverageMinMaxArr,
1925                                                                 aGroup2MinMaxArr,
1926                                                                 aGroup2AverageMinMaxArr,
1927                                                                 aNbComp,
1928                                                                 aNbComp2);
1929               else
1930                 BuildTimeStampMinMax<MED::TIntTimeStampValue>(CastToIntTimeStampValue(aTimeStampValue),
1931                                                               aMeshOnEntity,
1932                                                               aGeom2Gauss,
1933                                                               aMinMaxArr,
1934                                                               anAverageMinMaxArr,
1935                                                               aGroup2MinMaxArr,
1936                                                               aGroup2AverageMinMaxArr,
1937                                                               aNbComp,
1938                                                               aNbComp2);
1939
1940 #ifndef _DEXCEPT_
1941             }catch(Standard_Failure){
1942               Handle(Standard_Failure) aFail = Standard_Failure::Caught();          
1943               MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
1944             }catch(std::exception& exc){
1945               MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1946             }catch(...){
1947               MSG(MYDEBUG,"Unknown exception !!!");
1948             }
1949 #endif
1950           }
1951           for(TInt iComp = 0; iComp <= aNbComp; iComp++){
1952             VISU::TMinMax aMinMax = aField->GetMinMax(iComp, VISU::TNames());
1953             INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
1954           }
1955         }
1956 #ifndef _DEXCEPT_
1957       }catch(std::exception& exc){
1958         MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1959       }catch(...){
1960         MSG(MYDEBUG,"Unknown exception !!!");
1961       }
1962 #endif
1963
1964 #ifndef _DEXCEPT_
1965     }catch(std::exception& exc){
1966       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1967     }catch(...){
1968       MSG(MYDEBUG,"Unknown exception !!!");
1969     }
1970 #endif
1971   }
1972
1973   return this; 
1974 }
1975
1976
1977 //---------------------------------------------------------------
1978 VISU_Convertor* 
1979 VISU_MedConvertor
1980 ::BuildGroups()
1981 {
1982   if(myIsGroupsDone)
1983     return this;
1984
1985   TSetIsDone aSetIsDone(myIsGroupsDone);
1986   VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
1987
1988   TInt aNbMeshes = myMed->GetNbMeshes();
1989   VISU::TMeshMap& aMeshMap = myMeshMap;
1990
1991   INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
1992
1993   for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1994 #ifndef _DEXCEPT_
1995     try{
1996 #endif
1997       VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1998
1999       MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
2000       std::string aMeshName = aMeshInfo->GetName();      
2001
2002       VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
2003       if(anIter == aMeshMap.end())
2004         continue;
2005       VISU::PMEDMesh aMesh = anIter->second;
2006
2007       INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
2008
2009       MED::EMaillage aType = aMeshInfo->GetType();
2010       
2011       MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
2012       
2013       MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = 
2014         MED::GetEntity2TGeom2ElemInfo(myMed, aMeshInfo, anEntityInfo);
2015       
2016 #ifndef _DEXCEPT_
2017       try{
2018 #endif
2019         MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(myMed, aMeshInfo);
2020         
2021         if(aType == MED::eNON_STRUCTURE)
2022           BuildFamilyMap(aMesh,
2023                          anEntityInfo,
2024                          anEntity2TGeom2ElemInfo,
2025                          aFamilyInfoSet,
2026                          myMed);
2027         else
2028           BuildGrilleFamilyMap(aMesh,
2029                                anEntityInfo,
2030                                aFamilyInfoSet,
2031                                myMed);
2032         
2033         BuildGroupMap(aMesh,
2034                       aFamilyInfoSet);
2035 #ifndef _DEXCEPT_
2036       }catch(std::exception& exc){
2037         MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
2038       }catch(...){
2039           MSG(MYDEBUG,"Unknown exception !!!");
2040       }
2041 #endif
2042
2043 #ifndef _DEXCEPT_
2044     }catch(std::exception& exc){
2045       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
2046     }catch(...){
2047       MSG(MYDEBUG,"Unknown exception !!!");
2048     }
2049 #endif
2050   } 
2051
2052   return this; 
2053 }
2054
2055
2056 //---------------------------------------------------------------
2057 int
2058 VISU_MedConvertor
2059 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
2060                    VISU::PMeshOnEntityImpl theMeshOnEntity)
2061 {
2062   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
2063   INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
2064
2065   const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
2066
2067   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
2068   if(anEntity == VISU::NODE_ENTITY){
2069     isPointsUpdated += LoadPoints(myMed, theMesh);
2070   }else{
2071     isPointsUpdated += LoadPoints(myMed, theMesh);
2072     isCellsOnEntityUpdated += LoadCellsOnEntity(myMed, theMesh, theMeshOnEntity);
2073   }
2074
2075   return (isPointsUpdated || isCellsOnEntityUpdated);
2076 }
2077
2078
2079 //---------------------------------------------------------------
2080 int
2081 VISU_MedConvertor
2082 ::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
2083                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
2084                      VISU::PFamilyImpl theFamily)
2085 {
2086   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
2087   INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
2088
2089   const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
2090
2091   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
2092   if(anEntity == VISU::NODE_ENTITY){
2093     isPointsUpdated += LoadPointsOnFamily(myMed, theMesh, theFamily);
2094   }else{
2095     isPointsUpdated += LoadPoints(myMed, theMesh);
2096     isCellsOnEntityUpdated += LoadCellsOnFamily(myMed, theMesh, theMeshOnEntity, theFamily);
2097   }
2098
2099   return (isPointsUpdated || isCellsOnEntityUpdated);
2100 }
2101
2102
2103 //---------------------------------------------------------------
2104 int
2105 VISU_MedConvertor
2106 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
2107                   const VISU::TFamilySet& theFamilySet)
2108 {
2109   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
2110   INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
2111
2112   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
2113   VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
2114   for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
2115     VISU::PMEDFamily aFamily = *aFamilyIter;
2116     const VISU::TEntity& anEntity = aFamily->myEntity;
2117     const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
2118     isPointsUpdated += LoadPoints(myMed, theMesh);
2119     if(anEntity == VISU::NODE_ENTITY){
2120       isPointsUpdated += LoadPointsOnFamily(myMed, theMesh, aFamily);
2121     }else{
2122       isCellsOnEntityUpdated += LoadCellsOnFamily(myMed,theMesh,aMeshOnEntity,aFamily);
2123     }
2124   }
2125
2126   return (isPointsUpdated || isCellsOnEntityUpdated);
2127 }
2128
2129
2130 //---------------------------------------------------------------
2131 int
2132 VISU_MedConvertor
2133 ::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
2134                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
2135                        VISU::PFieldImpl theField, 
2136                        VISU::PValForTimeImpl theValForTime)
2137 {
2138   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
2139   INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
2140
2141   const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
2142   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
2143   isPointsUpdated += LoadPoints(myMed,theMesh);
2144   if(anEntity != VISU::NODE_ENTITY)
2145     isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity);
2146   int isFieldUpdated = LoadValForTimeOnMesh(myMed,theMesh,theMeshOnEntity,theField,theValForTime);
2147   
2148   return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
2149 }
2150
2151
2152 //---------------------------------------------------------------
2153 int
2154 VISU_MedConvertor
2155 ::LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
2156                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
2157                            VISU::PFieldImpl theField, 
2158                            VISU::PValForTimeImpl theValForTime)
2159 {
2160   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
2161   INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
2162
2163   const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
2164   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
2165   if(anEntity != VISU::NODE_ENTITY)
2166     isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity);
2167   int isFieldUpdated = LoadValForTimeOnGaussPts(myMed,theMesh,theMeshOnEntity,theField,theValForTime);
2168   
2169   return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
2170 }
2171
2172
2173 //---------------------------------------------------------------
2174 int 
2175 VISU_MedConvertor
2176 ::LoadPoints(const MED::PWrapper& theMed,
2177              VISU::PMEDMesh theMesh) 
2178 {
2179   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
2180   try{
2181     //Check on existing family
2182     VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
2183     aMeshOnEntity->myMeshName = theMesh->myName;
2184     aMeshOnEntity->myEntity = VISU::NODE_ENTITY;
2185
2186     INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<<theMesh->myIsDone<<"'\n");
2187
2188     //Check on loading already done
2189     if(theMesh->myIsDone)
2190       return 0;
2191
2192     MED::EMaillage aType = theMesh->myMeshInfo->GetType();
2193     
2194     if(aType == MED::eNON_STRUCTURE){
2195       //Main part of code
2196       MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
2197       TInt aNbElem = aNodeInfo->GetNbElem();
2198       
2199       VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
2200       aNamedPointCoords->Init(aNodeInfo, theMed->GetVersion());
2201       
2202       VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
2203       VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh());
2204       
2205       aSubMesh->Init(MED::PElemInfo(aNodeInfo), theMed->GetVersion()); 
2206       aSubMesh->myNbCells = theMesh->myNbPoints;
2207       aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
2208       
2209       VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2210       aCell2Connect.resize(aNbElem);
2211       for (int iElem = 0; iElem < aNbElem; iElem++)
2212         aCell2Connect[iElem] = VISU::TConnect(1,iElem);
2213     } // END NON_STRUCTURED
2214     else { // STRUCTURED
2215       //Main part of code
2216       MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(theMesh->myMeshInfo);
2217       TInt aNbElem = aGrilleInfo->GetNbNodes();
2218       
2219       VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
2220       aNamedPointCoords->Init(aGrilleInfo);
2221       
2222       VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
2223       VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh());
2224       
2225       aSubMesh->Init(aGrilleInfo); 
2226       aSubMesh->myNbCells = theMesh->myNbPoints;
2227       aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
2228       
2229       VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2230       aCell2Connect.resize(aNbElem);
2231       for(int iElem = 0; iElem < aNbElem; iElem++)
2232         aCell2Connect[iElem] = VISU::TConnect(1,iElem);
2233       
2234     }
2235     
2236     theMesh->myIsDone = true;
2237     
2238     return 1;
2239
2240   }catch(std::exception& exc){
2241     throw;
2242   }catch(...){
2243     EXCEPTION(std::runtime_error,"Unknown exception !!!");
2244   }
2245
2246   return 0;
2247 }
2248
2249
2250 //---------------------------------------------------------------
2251 int 
2252 VISU_MedConvertor
2253 ::LoadPointsOnFamily(const MED::PWrapper& theMed,
2254                      const VISU::PMEDMesh theMesh, 
2255                      const VISU::PMEDFamily theFamily) 
2256 {
2257   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
2258   try{
2259     if(theFamily->myIsDone) 
2260       return 0;
2261
2262     const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2263     MED::EMaillage aType = aMeshInfo->GetType();
2264
2265     //Main part of code
2266     if(aType == MED::eNON_STRUCTURE){
2267       MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
2268       TInt aNbElem = aNodeInfo->GetNbElem();
2269       
2270       if(aNbElem > 0){
2271         TInt anId = theFamily->myId;
2272         VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
2273         for(TInt iElem = 0; iElem < aNbElem; iElem++) 
2274           if(aNodeInfo->GetFamNum(iElem) == anId)
2275             aSubMeshID.push_back(iElem);
2276       }
2277     }
2278     else {
2279       MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(aMeshInfo);
2280       TInt aNbElem = aGrilleInfo->GetNbNodes();
2281       
2282       if(aNbElem > 0){
2283         TInt anId = theFamily->myId;
2284         VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
2285         for(TInt iElem = 0; iElem < aNbElem; iElem++) 
2286           if(aGrilleInfo->GetFamNumNode(iElem) == anId)
2287             aSubMeshID.push_back(iElem);
2288       }
2289     }
2290
2291     theFamily->myIsDone = true;
2292
2293     return 1;
2294
2295   }catch(std::exception& exc){
2296     throw;
2297   }catch(...){
2298     EXCEPTION(std::runtime_error,"Unknown exception !!!");
2299   }
2300
2301   return 0;
2302 }
2303
2304
2305 //---------------------------------------------------------------
2306 int 
2307 VISU_MedConvertor
2308 ::LoadCellsOnEntity(const MED::PWrapper& theMed,
2309                     const VISU::PMEDMesh theMesh,
2310                     const VISU::PMEDMeshOnEntity theMeshOnEntity)
2311 {
2312   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
2313 #ifndef _DEXCEPT_
2314   try{
2315 #endif
2316     const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
2317     const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
2318
2319     INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<<aVEntity<<"\n");
2320
2321     if(theMeshOnEntity->myIsDone)
2322       return 0;
2323
2324     const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2325
2326     MED::EMaillage aType = aMeshInfo->GetType();
2327
2328     if(aType == MED::eSTRUCTURE){
2329       
2330       MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(aMeshInfo);
2331       TInt aNbPoints = aGrilleInfo->GetNbNodes();
2332       
2333       std::map<TInt,TInt> aNodeIdMap;
2334       EBooleen anIsNodeNum = MED::eFAUX;
2335       
2336       const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
2337       MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
2338       VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
2339       
2340       for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
2341         const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
2342         VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2343         INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
2344         {
2345           vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
2346           INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
2347         
2348           TInt aNbElem = aGeom2SizeIter->second;//aGrilleInfo->GetNbCells();
2349           
2350           if(aNbElem > 0){
2351             VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2352             
2353             aSubMesh->Init(aGrilleInfo); 
2354             aSubMesh->myNbCells = aNbElem;      
2355             aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
2356             
2357             VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2358             aCell2Connect.resize(aNbElem);
2359             
2360             TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
2361             VISU::TVector<TInt> aConnect(aMNbNodes);
2362             
2363             for(TInt iElem = 0; iElem < aNbElem; iElem++) {
2364               MED::TIntVector aConn = aGrilleInfo->GetConn(iElem);
2365               VISU::TConnect& anArray = aCell2Connect[iElem];
2366               anArray.resize(aVNbNodes);
2367               
2368               if(anIsNodeNum){
2369                 for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
2370                   aConnect[iConn] = aNodeIdMap[aConn[iConn] - 1];
2371                 }
2372               }else{
2373                 for(int iConn = 0; iConn < aMNbNodes; ++iConn){
2374                   aConnect[iConn] = aConn[iConn];
2375                 }
2376               }
2377               
2378               switch(aMGeom){
2379               case MED::eQUAD4:
2380                 anArray[0] = aConnect[0];
2381                 anArray[1] = aConnect[2];
2382                 anArray[2] = aConnect[3];
2383                 anArray[3] = aConnect[1];
2384                 break;
2385               case MED::eHEXA8:
2386                 anArray[0] = aConnect[0];
2387                 anArray[1] = aConnect[2];
2388                 anArray[2] = aConnect[3];
2389                 anArray[3] = aConnect[1];
2390                 anArray[4] = aConnect[4];
2391                 anArray[5] = aConnect[6];
2392                 anArray[6] = aConnect[7];
2393                 anArray[7] = aConnect[5];
2394                 break;
2395               default:
2396                 for(int iNode = 0; iNode < aVNbNodes; iNode++) 
2397                   anArray[iNode] = aConnect[iNode];
2398               }
2399               
2400               for(int iNode = 0; iNode < aVNbNodes; iNode++) 
2401                 if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
2402                   EXCEPTION(std::runtime_error,"LoadCellsOnEntity - "<<
2403                             " aNbPoints("<<aNbPoints<<") "<<
2404                             "<= anArray["<<iElem<<"]"<<
2405                             "["<<iNode<<"]"<<
2406                             "("<<anArray[iNode]<<") < 0");
2407             }
2408           }
2409         }
2410       }
2411
2412       theMeshOnEntity->myIsDone = true;
2413       
2414       return 1;
2415       
2416     }
2417     
2418     MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
2419     TInt aNbPoints = aNodeInfo->GetNbElem();
2420
2421     std::map<TInt,TInt> aNodeIdMap;
2422 #ifdef _EDF_NODE_IDS_
2423     EBooleen anIsNodeNum = MED::eFAUX;
2424 #else
2425     EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
2426     if(anIsNodeNum){
2427       for(TInt i = 0; i < aNbPoints; i++){
2428         aNodeIdMap[aNodeInfo->GetElemNum(i)-1] = i;
2429       }
2430     }
2431 #endif
2432
2433     const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
2434     MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
2435     VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
2436
2437     for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
2438       const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
2439       VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2440       INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
2441       switch(aMGeom){
2442       case MED::ePOLYGONE: {
2443         MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
2444         TInt aNbElem = aPolygoneInfo->GetNbElem();
2445         if(aNbElem > 0){
2446           VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2447           
2448           aSubMesh->Init(MED::PElemInfo(aPolygoneInfo),theMed->GetVersion()); 
2449           aSubMesh->myNbCells = aNbElem;      
2450
2451           VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2452           aCell2Connect.resize(aNbElem);
2453           
2454           for(TInt iElem = 0; iElem < aNbElem; iElem++) {
2455             MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
2456             TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
2457             aSubMesh->myCellsSize += aNbConn;
2458             VISU::TConnect& anArray = aCell2Connect[iElem];
2459             anArray.resize(aNbConn);
2460             for(TInt iConn = 0; iConn < aNbConn; iConn++)
2461               anArray[iConn] = aConnSlice[iConn] - 1;
2462           }
2463         }
2464         break;
2465       }
2466       case MED::ePOLYEDRE: {
2467         MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
2468         TInt aNbElem = aPolyedreInfo->GetNbElem();
2469         
2470         if(aNbElem > 0){
2471           VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2472           
2473           aSubMesh->Init(MED::PElemInfo(aPolyedreInfo),theMed->GetVersion()); 
2474           aSubMesh->myNbCells = aNbElem;      
2475
2476           VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2477           aCell2Connect.resize(aNbElem);
2478           
2479           for(TInt iElem = 0; iElem < aNbElem; iElem++){
2480             MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
2481             VISU::TConnect& anArray = aCell2Connect[iElem];
2482             typedef std::set<TInt> TConnectSet;
2483             TConnectSet aConnectSet;
2484             TInt aNbFaces = aConnSliceArr.size();
2485             for(TInt iFace = 0; iFace < aNbFaces; iFace++){
2486               MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
2487               TInt aNbConn = aConnSlice.size();
2488               aSubMesh->myCellsSize += aNbConn;
2489               for(TInt iConn = 0; iConn < aNbConn; iConn++){
2490                 aConnectSet.insert(aConnSlice[iConn]);
2491               }
2492             }
2493           
2494             int aNbConn = aConnectSet.size();
2495             anArray.resize(aNbConn);
2496             TConnectSet::iterator anIter = aConnectSet.begin();
2497             for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){
2498               TInt anId = *anIter;
2499               anArray[i] = anId - 1;
2500             }
2501           }
2502         }
2503
2504         break;
2505       }
2506       default: {
2507         vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
2508         INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
2509         
2510         MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
2511         TInt aNbElem = aCellInfo->GetNbElem();
2512         
2513         if(aNbElem > 0){
2514           VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2515           
2516           aSubMesh->Init(MED::PElemInfo(aCellInfo), theMed->GetVersion()); 
2517           aSubMesh->myNbCells = aNbElem;      
2518           aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
2519
2520           VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2521           aCell2Connect.resize(aNbElem);
2522         
2523           TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
2524           VISU::TVector<TInt> aConnect(aMNbNodes);
2525         
2526           for(TInt iElem = 0; iElem < aNbElem; iElem++) {
2527             MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
2528             VISU::TConnect& anArray = aCell2Connect[iElem];
2529             anArray.resize(aVNbNodes);
2530             
2531             if(anIsNodeNum){
2532               for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
2533                 aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1];
2534               }
2535             }else{
2536               for(int iConn = 0; iConn < aMNbNodes; iConn++){
2537                 aConnect[iConn] = aConnSlice[iConn] - 1;
2538               }
2539             }
2540             
2541             switch(aMGeom){
2542 #if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2543             case MED::eSEG3:
2544               anArray[0] = aConnect[0];
2545               anArray[2] = aConnect[1];  
2546
2547               anArray[1] = aConnect[2];
2548               break;
2549 #endif
2550 #if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2551             case MED::eTRIA6:
2552               anArray[0] = aConnect[0];
2553               anArray[2] = aConnect[1];  
2554               anArray[4] = aConnect[2];  
2555
2556               anArray[1] = aConnect[3];
2557               anArray[3] = aConnect[4];  
2558               anArray[5] = aConnect[5];  
2559               break;
2560 #endif
2561 #if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2562             case MED::eQUAD8:
2563               anArray[0] = aConnect[0];
2564               anArray[2] = aConnect[1];  
2565               anArray[4] = aConnect[2];  
2566               anArray[6] = aConnect[3];  
2567
2568               anArray[1] = aConnect[4];
2569               anArray[3] = aConnect[5];  
2570               anArray[5] = aConnect[6];  
2571               anArray[7] = aConnect[7];  
2572               break;
2573 #endif
2574 #if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2575             case MED::eTETRA10:
2576               anArray[0] = aConnect[0];
2577               anArray[1] = aConnect[2];
2578               anArray[2] = aConnect[1];  
2579               anArray[3] = aConnect[3];  
2580
2581               anArray[4] = aConnect[6];
2582               anArray[5] = aConnect[5];
2583               anArray[6] = aConnect[4];  
2584
2585               anArray[7] = aConnect[7];  
2586               anArray[8] = aConnect[9];  
2587               anArray[9] = aConnect[8];  
2588               break;
2589 #endif
2590             case MED::eTETRA4:
2591               anArray[0] = aConnect[0];
2592               anArray[1] = aConnect[2];
2593               anArray[2] = aConnect[1];  
2594               anArray[3] = aConnect[3];  
2595               break;
2596 #if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2597             case MED::ePYRA13:
2598               anArray[0] = aConnect[0];
2599               anArray[1] = aConnect[3];
2600               anArray[2] = aConnect[2];  
2601               anArray[3] = aConnect[1];  
2602               anArray[4] = aConnect[4];
2603
2604               anArray[5] = aConnect[8];
2605               anArray[6] = aConnect[7];  
2606               anArray[7] = aConnect[6];  
2607               anArray[8] = aConnect[5];  
2608
2609               anArray[9] = aConnect[9];  
2610               anArray[10] = aConnect[12];  
2611               anArray[11] = aConnect[11];  
2612               anArray[12] = aConnect[10];  
2613               break;
2614 #endif
2615             case MED::ePYRA5:
2616               anArray[0] = aConnect[0];
2617               anArray[1] = aConnect[3];  
2618               anArray[2] = aConnect[2];
2619               anArray[3] = aConnect[1];  
2620               anArray[4] = aConnect[4];
2621               break;
2622             default:
2623               for(int iNode = 0; iNode < aVNbNodes; iNode++) 
2624                 anArray[iNode] = aConnect[iNode];
2625             }
2626             for(int iNode = 0; iNode < aVNbNodes; iNode++) 
2627               if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
2628                 EXCEPTION(std::runtime_error,"LoadCellsOnEntity - "<<
2629                           " aNbPoints("<<aNbPoints<<") "<<
2630                           "<= anArray["<<iElem<<"]"<<
2631                           "["<<iNode<<"]"<<
2632                           "("<<anArray[iNode]<<") < 0");
2633           }
2634         }
2635       }}
2636     }
2637
2638     // END NON_STRUCTURED
2639
2640     theMeshOnEntity->myIsDone = true;
2641
2642     return 1;
2643
2644 #ifndef _DEXCEPT_
2645   }catch(std::exception& exc){
2646     throw;
2647   }catch(...){
2648     EXCEPTION(std::runtime_error,"Unknown exception !!!");
2649   }
2650 #endif
2651
2652   return 0;
2653 }
2654
2655
2656 //---------------------------------------------------------------
2657 int 
2658 VISU_MedConvertor
2659 ::LoadCellsOnFamily(const MED::PWrapper& theMed,
2660                     const VISU::PMEDMesh theMesh,
2661                     const VISU::PMEDMeshOnEntity theMeshOnEntity,
2662                     const VISU::PMEDFamily theFamily)
2663 {
2664   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
2665 #ifndef _DEXCEPT_
2666   try{
2667 #endif
2668     const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
2669     const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
2670
2671     INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<<aVEntity<<"\n");
2672
2673     if(theFamily->myIsDone)
2674       return 0;
2675
2676     TInt anId = theFamily->myId;
2677
2678     const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2679     VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
2680     MED::EMaillage aType = aMeshInfo->GetType();
2681
2682     const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
2683     MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
2684     for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
2685       const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
2686       if(aType == MED::eNON_STRUCTURE){
2687         MED::PElemInfo anElemInfo;
2688         switch(aMGeom){
2689         case MED::ePOLYGONE: {
2690           anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
2691           break;
2692         }
2693         case MED::ePOLYEDRE: {
2694           anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
2695           break;
2696         }
2697         default: {
2698           anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
2699           break;
2700         }}
2701         if(anElemInfo){
2702           if(TInt aNbElem = anElemInfo->GetNbElem()){
2703             VISU::TSubMeshID aSubMeshID;
2704             for(TInt iElem = 0; iElem < aNbElem; iElem++) 
2705               if(anElemInfo->GetFamNum(iElem) == anId)
2706                 aSubMeshID.push_back(iElem);
2707             if(!aSubMeshID.empty()){
2708               VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2709               INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
2710               aGeom2SubMeshID.insert(VISU::TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
2711             }
2712           }
2713         }
2714       } else {
2715         MED::PGrilleInfo anElemInfo = theMed->GetPGrilleInfo(aMeshInfo);
2716         if(anElemInfo){
2717           TInt aNbElem = anElemInfo->GetNbCells();
2718           if(aNbElem>0 && (aMGeom == anElemInfo->GetGeom()) ){
2719             VISU::TSubMeshID aSubMeshID;
2720             for(TInt iElem = 0; iElem < aNbElem; iElem++) 
2721               if(anElemInfo->GetFamNum(iElem) == anId)
2722                 aSubMeshID.push_back(iElem);
2723             if(!aSubMeshID.empty()){
2724               VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2725               INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
2726               aGeom2SubMeshID.insert(VISU::TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
2727             }
2728           }
2729         }
2730       }
2731     }
2732
2733     theFamily->myIsDone = true;
2734
2735     return 1;
2736
2737 #ifndef _DEXCEPT_
2738   }catch(std::exception& exc){
2739     throw;
2740   }catch(...){
2741     EXCEPTION(std::runtime_error,"Unknown exception !!!");
2742   }
2743 #endif
2744
2745   return 0;
2746 }
2747
2748
2749 //---------------------------------------------------------------
2750 void
2751 LoadProfile(const MED::PWrapper& theMed,
2752             VISU::PMEDMesh theMesh,
2753             MED::PTimeStampValueBase theTimeStampValue,
2754             VISU::TMEDValForTime& theValForTime,
2755             VISU::TMEDMeshOnEntity& theMeshOnEntity)
2756 {
2757   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
2758   INITMSG(MYDEBUG,"LoadProfile"<<endl);
2759
2760   VISU::PMEDProfile aProfile = theValForTime.myProfile;
2761   if(aProfile->myIsDone)
2762     return;
2763
2764   const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2765   const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile();
2766   MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin();
2767   for(; anIter != aGeom2Profile.end(); anIter++){
2768     MED::PProfileInfo aProfileInfo = anIter->second;
2769     MED::EGeometrieElement aMGeom = anIter->first;
2770     VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2771
2772     VISU::TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
2773     if(anIter2 != aGeom2SubProfile.end()){
2774       VISU::PMEDSubProfile aSubProfile = anIter2->second;
2775
2776       MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2777       if(!anElemNum.empty()){
2778         VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
2779         TInt aSize = anElemNum.size();
2780         aSubMeshID.resize(aSize);
2781         for(TInt anId = 0; anId < aSize; anId++)
2782           aSubMeshID[anId] = anElemNum[anId] - 1;
2783       }
2784
2785       INITMSG(MYDEBUG,
2786               "- aEGeom = "<<aEGeom<<
2787               "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
2788               endl);
2789     }
2790   }
2791   {
2792     const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2793     
2794     VISU::TEntity aVEntity = theMeshOnEntity.myEntity;
2795     MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
2796     
2797     const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2798     VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
2799     for(; anIter != aGeom2SubProfile.end(); anIter++){
2800       const VISU::PMEDSubProfile& aSubProfile = anIter->second;
2801       MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2802       MED::PElemInfo anElemInfo;
2803       anElemInfo = theMed->GetPElemInfo(aMeshInfo,aMEntity,aMGeom);
2804       aSubProfile->myIsElemNum = anElemInfo->IsElemNum();
2805       aSubProfile->myElemNum = anElemInfo->myElemNum;
2806     }
2807   }
2808
2809   aProfile->myIsDone = true;
2810 }
2811
2812
2813 //---------------------------------------------------------------
2814 void
2815 LoadGaussMesh(const MED::PWrapper& theMed,
2816               VISU::PMEDMesh theMesh,
2817               MED::PTimeStampValueBase theTimeStampValue,
2818               VISU::TMEDValForTime& theValForTime,
2819               VISU::TMEDMeshOnEntity& theMeshOnEntity)
2820 {
2821   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
2822   INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
2823
2824   // this part of code must be reimplemented in connection with GRILLE structures
2825   if(theMesh->myMeshInfo->GetType() == MED::eSTRUCTURE)
2826     EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
2827   
2828   VISU::PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
2829   if(!aGaussMesh || aGaussMesh->myIsDone)
2830     return;
2831
2832   const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2833   MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
2834
2835   VISU::TEntity aVEntity = theMeshOnEntity.myEntity;
2836   MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
2837
2838   const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
2839   const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo();
2840   const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
2841
2842   VISU::TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
2843   for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){
2844     VISU::PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
2845     VISU::EGeometry aEGeom = aSubMeshIter->first;
2846     
2847     if(aGaussSubMesh->myIsDone)
2848       continue;
2849
2850     VISU::PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
2851     const VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
2852     MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2853
2854     MED::PPolygoneInfo aPolygoneInfo;
2855     MED::PPolyedreInfo aPolyedreInfo;
2856     MED::PCellInfo aCellInfo;
2857     MED::PElemInfo anElemInfo;
2858
2859     switch(aMGeom){
2860     case MED::ePOLYGONE: 
2861       aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,
2862                                                aMEntity,
2863                                                aMGeom);
2864       anElemInfo = aPolygoneInfo;
2865       break;
2866     case MED::ePOLYEDRE: 
2867       aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,
2868                                                aMEntity,
2869                                                aMGeom);
2870       anElemInfo = aPolyedreInfo;
2871       break;
2872     default:
2873       aCellInfo = theMed->GetPCellInfo(aMeshInfo,
2874                                        aMEntity, 
2875                                        aMGeom);
2876       anElemInfo = aCellInfo;
2877     }
2878     aGaussSubMesh->myIsElemNum = anElemInfo->IsElemNum();
2879     aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
2880
2881     std::string aName;
2882     bool anIsGaussCoord3D = false;
2883     MED::PGaussCoord aGaussCoordPtr(new MED::TGaussCoord());
2884     MED::TGaussCoord& aGaussCoord = *aGaussCoordPtr;
2885
2886     MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
2887     if(aGaussIter != aGeom2Gauss.end()){
2888       VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss;
2889       MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo;
2890       if(aGaussInfo){
2891         aName = aGaussInfo->GetName();
2892         if(!aSubMeshID.empty()){
2893           const std::string& aProfileName = aSubProfile->myName;
2894           MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2895                                                                aProfileName);
2896           if(aProfileInfo){
2897             const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2898             anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2899                                                     aCellInfo,
2900                                                     aNodeInfo,
2901                                                     aGaussCoord,
2902                                                     anElemNum);
2903           }
2904         }else
2905           anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2906                                                   aCellInfo,
2907                                                   aNodeInfo,
2908                                                   aGaussCoord);
2909       }
2910     }else{
2911       if(!aSubMeshID.empty()){
2912         const std::string& aProfileName = aSubProfile->myName;
2913         MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2914                                                              aProfileName);
2915         if(aProfileInfo){
2916           const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2917           switch(aMGeom){
2918           case MED::ePOLYGONE: 
2919             anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2920                                                   aNodeInfo,
2921                                                   aGaussCoord,
2922                                                   anElemNum);
2923             break;
2924           case MED::ePOLYEDRE: 
2925             anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2926                                                   aNodeInfo,
2927                                                   aGaussCoord,
2928                                                   anElemNum);
2929             break;
2930           default:
2931             anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2932                                                   aNodeInfo,
2933                                                   aGaussCoord,
2934                                                   anElemNum);
2935           }
2936         }
2937       }else
2938         switch(aMGeom){
2939         case MED::ePOLYGONE: 
2940           anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2941                                                 aNodeInfo,
2942                                                 aGaussCoord);
2943           break;
2944         case MED::ePOLYEDRE: 
2945           anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2946                                                 aNodeInfo,
2947                                                 aGaussCoord);
2948           break;
2949         default:
2950           anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2951                                                 aNodeInfo,
2952                                                 aGaussCoord);
2953         }
2954     }
2955     
2956     if(anIsGaussCoord3D){
2957       VISU::TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
2958       VISU::TMEDGaussCoordHolder* aCoordHolder = new VISU::TMEDGaussCoordHolder();
2959       aCoordHolder->Init(aGaussCoordPtr);
2960       aCoords.Init(VISU::PCoordHolder(aCoordHolder));
2961       
2962       aGaussSubMesh->myIsDone = true;
2963       
2964       TInt aNbGauss = aGaussCoord.GetNbGauss();
2965       TInt aNbElem = aGaussCoord.GetNbElem();
2966       TInt aNbCells = aNbElem*aNbGauss;
2967
2968       INITMSG(MYDEBUG,
2969               "- aEGeom = "<<aEGeom<<
2970               "; aName = '"<<aName<<"'"<<
2971               "; aStatus = "<<aGaussSubMesh->myStatus<<
2972               "; aNbElem = "<<aNbElem<<
2973               "; aNbGauss = "<<aNbGauss<<
2974               "; aNbCells = "<<aNbCells<<
2975               endl);
2976     }else
2977       EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
2978   }
2979   
2980   aGaussMesh->myIsDone = true;
2981 }
2982
2983
2984 //---------------------------------------------------------------
2985 template<class TimeStampValueType>
2986 void
2987 FillValForTime(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
2988                const VISU::TGeom2SubProfile& theGeom2SubProfile,
2989                VISU::PMEDValForTime theValForTime,
2990                VISU::PMEDField theField)
2991 {
2992   theField->myDataSize = 0;
2993   TInt aNbComp = theField->myNbComp;
2994
2995   VISU::TGeom2SubProfile::const_iterator anIter = theGeom2SubProfile.begin();
2996   for(; anIter != theGeom2SubProfile.end(); anIter++){
2997     VISU::EGeometry aEGeom = anIter->first;
2998     VISU::PMEDSubProfile aSubProfile(anIter->second);
2999
3000     TInt aNbElem = aSubProfile->myNbCells;
3001     theField->myDataSize += aNbElem * aNbComp;
3002
3003     if(aSubProfile->myStatus != VISU::eRemoveAll){
3004       TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
3005
3006       INITMSG(MYDEBUG,
3007               "- aEGeom = "<<aEGeom<<
3008               "; aNbElem = "<<aNbElem<<
3009               "; aNbGauss = "<<aNbGauss<<
3010               endl);
3011       
3012       VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
3013       typedef typename TimeStampValueType::TElement TElement;
3014       typedef VISU::TTMEDMeshValue<TElement> TVMeshValue;
3015       TVMeshValue* aMeshValue = new TVMeshValue();
3016
3017       MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
3018       typedef typename TimeStampValueType::PTMeshValue PTMeshValue;
3019       PTMeshValue aMeshValuePtr = theTimeStampValue->GetMeshValuePtr(aMGeom);
3020       aMeshValue->Init(aNbElem, aNbGauss, aNbComp, aMeshValuePtr);
3021       aVMeshValue.reset(aMeshValue);
3022     }
3023   }
3024 }
3025
3026 //---------------------------------------------------------------
3027 int 
3028 LoadValForTime(const MED::PWrapper& theMed,
3029                VISU::PMEDMesh theMesh,
3030                VISU::PMEDMeshOnEntity theMeshOnEntity,
3031                VISU::PMEDField theField, 
3032                VISU::PMEDValForTime theValForTime,
3033                bool theIsGauss,
3034                bool& theIsDone)
3035 {
3036   VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
3037   INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
3038
3039   //Check on loading already done
3040   if(theIsDone) 
3041     return 0;
3042
3043   //Main part of code
3044   const std::string& aMeshName = theMeshOnEntity->myMeshName;
3045   const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
3046   MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,
3047                                                      theField->myId);
3048
3049   MED::TGeom2Size aGeom2Size;
3050   MED::EEntiteMaillage aMEntity;
3051   theMed->GetNbTimeStamps(aFieldInfo,
3052                           theMesh->myEntityInfo,
3053                           aMEntity,
3054                           aGeom2Size);
3055
3056   MED::PTimeStampInfo aTimeStampInfo = 
3057     theMed->GetPTimeStampInfo(aFieldInfo,
3058                               aMEntity,
3059                               aGeom2Size,
3060                               theValForTime->myId);
3061
3062   MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
3063   MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
3064
3065   MED::PTimeStampValueBase aTimeStampValue = 
3066     theMed->GetPTimeStampValue(aTimeStampInfo,
3067                                aMKey2Profile,
3068                                aKey2Gauss);
3069   
3070   InitProfile(theMed,
3071               aMeshInfo,
3072               aTimeStampValue,
3073               theMeshOnEntity,
3074               aMEntity,
3075               aGeom2Size,
3076               theValForTime);
3077
3078   LoadProfile(theMed,
3079               theMesh,
3080               aTimeStampValue,
3081               theValForTime,
3082               theMeshOnEntity);
3083   
3084   if(theIsGauss) {
3085     InitGaussMesh(aTimeStampValue,
3086                   theMeshOnEntity,
3087                   aGeom2Size,
3088                   theValForTime);
3089
3090     LoadGaussMesh(theMed,
3091                   theMesh,
3092                   aTimeStampValue,
3093                   theValForTime,
3094                   theMeshOnEntity);
3095   }
3096   
3097   VISU::PMEDProfile aProfile = theValForTime->myProfile;
3098   VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
3099
3100   INITMSGA(MYDEBUG,0,
3101            "- aMeshName = '"<<aMeshName<<"'"<<
3102            "; aFieldName = '"<<aFieldInfo->GetName()<<"'"<<
3103            "; aMEntity = "<<aMEntity<<
3104            "; aNbComp = "<<theField->myNbComp<<
3105            endl);
3106
3107   if(aFieldInfo->GetType() == MED::eFLOAT64)
3108     FillValForTime<MED::TFloatTimeStampValue>(CastToFloatTimeStampValue(aTimeStampValue),
3109                                               aGeom2SubProfile,
3110                                               theValForTime,
3111                                               theField);
3112   else
3113     FillValForTime<MED::TIntTimeStampValue>(CastToIntTimeStampValue(aTimeStampValue),
3114                                             aGeom2SubProfile,
3115                                             theValForTime,
3116                                             theField);
3117   theIsDone = true;
3118
3119   return 1; 
3120 }
3121
3122
3123 //---------------------------------------------------------------
3124 int 
3125 VISU_MedConvertor
3126 ::LoadValForTimeOnMesh(const MED::PWrapper& theMed,
3127                        VISU::PMEDMesh theMesh,
3128                        VISU::PMEDMeshOnEntity theMeshOnEntity,
3129                        VISU::PMEDField theField, 
3130                        VISU::PMEDValForTime theValForTime)
3131 {
3132   VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
3133   return LoadValForTime(theMed,
3134                         theMesh,
3135                         theMeshOnEntity,
3136                         theField,
3137                         theValForTime,
3138                         false,
3139                         anUnstructuredGridIDMapper->myIsVTKDone);
3140 }
3141
3142
3143 //---------------------------------------------------------------
3144 int 
3145 VISU_MedConvertor
3146 ::LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
3147                            VISU::PMEDMesh theMesh,
3148                            VISU::PMEDMeshOnEntity theMeshOnEntity,
3149                            VISU::PMEDField theField, 
3150                            VISU::PMEDValForTime theValForTime)
3151 {
3152   VISU::PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
3153   return LoadValForTime(theMed,
3154                         theMesh,
3155                         theMeshOnEntity,
3156                         theField,
3157                         theValForTime,
3158                         true,
3159                         aGaussPtsIDFilter->myIsVTKDone);
3160 }