1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_MedConvertor.cxx
24 // Author : Alexey PETROV
28 #include "VISU_MedConvertor.hxx"
29 #include "VISU_Convertor.hxx"
30 #include "VISU_ConvertorUtils.hxx"
32 #include "MED_Factory.hxx"
33 #include "MED_Algorithm.hxx"
34 #include "MED_GaussUtils.hxx"
35 #include "MED_Utilities.hxx"
37 #include <boost/thread/thread.hpp>
38 #include <boost/bind.hpp>
40 #include <vtkCellType.h>
50 static int MYDEBUG = 0;
51 static int MYVALUEDEBUG = 0;
52 static int MY_FAMILY_DEBUG = 0;
53 static int MY_GROUP_DEBUG = 0;
56 static int MYDEBUG = 0;
57 static int MYVALUEDEBUG = 0;
58 static int MY_FAMILY_DEBUG = 0;
59 static int MY_GROUP_DEBUG = 0;
62 #define _LOAD_FAMILIES_
63 #define _EDF_NODE_IDS_
67 //---------------------------------------------------------------
69 MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
71 return theMEDGeomType % 100;
75 //---------------------------------------------------------------
77 MEDGeom2VISU(MED::EGeometrieElement theGeom)
80 case MED::ePOINT1: return VISU::ePOINT1;
81 case MED::eSEG2: return VISU::eSEG2;
82 case MED::eTRIA3: return VISU::eTRIA3;
83 case MED::eQUAD4: return VISU::eQUAD4;
84 case MED::eTETRA4: return VISU::eTETRA4;
85 case MED::eHEXA8: return VISU::eHEXA8;
86 case MED::ePENTA6: return VISU::ePENTA6;
87 case MED::ePYRA5: return VISU::ePYRA5;
89 case MED::eSEG3: return VISU::eSEG3;
90 case MED::eTRIA6: return VISU::eTRIA6;
91 case MED::eQUAD8: return VISU::eQUAD8;
92 case MED::eTETRA10: return VISU::eTETRA10;
93 case MED::eHEXA20: return VISU::eHEXA20;
94 case MED::ePENTA15: return VISU::ePENTA15;
95 case MED::ePYRA13: return VISU::ePYRA13;
97 case MED::ePOLYGONE: return VISU::ePOLYGONE;
98 case MED::ePOLYEDRE: return VISU::ePOLYEDRE;
104 //---------------------------------------------------------------
105 MED::EGeometrieElement
106 VISUGeom2MED(int theGeom)
109 case VISU::ePOINT1: return MED::ePOINT1;
110 case VISU::eSEG2: return MED::eSEG2;
111 case VISU::eTRIA3: return MED::eTRIA3;
112 case VISU::eQUAD4: return MED::eQUAD4;
113 case VISU::eTETRA4: return MED::eTETRA4;
114 case VISU::eHEXA8: return MED::eHEXA8;
115 case VISU::ePENTA6: return MED::ePENTA6;
116 case VISU::ePYRA5: return MED::ePYRA5;
118 case VISU::eSEG3: return MED::eSEG3;
119 case VISU::eTRIA6: return MED::eTRIA6;
120 case VISU::eQUAD8: return MED::eQUAD8;
121 case VISU::eTETRA10: return MED::eTETRA10;
122 case VISU::eHEXA20: return MED::eHEXA20;
123 case VISU::ePENTA15: return MED::ePENTA15;
124 case VISU::ePYRA13: return MED::ePYRA13;
126 case VISU::ePOLYGONE: return MED::ePOLYGONE;
127 case VISU::ePOLYEDRE: return MED::ePOLYEDRE;
129 return MED::EGeometrieElement(-1);
133 //---------------------------------------------------------------
135 MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
137 switch(theMEDEntity){
138 case MED::eNOEUD: return NODE_ENTITY;
139 case MED::eARETE: return EDGE_ENTITY;
140 case MED::eFACE: return FACE_ENTITY;
141 case MED::eMAILLE: return CELL_ENTITY;
143 return VISU::TEntity(-1);
147 //---------------------------------------------------------------
149 VTKEntityToMED(TEntity theVTKEntity)
151 switch(theVTKEntity){
152 case NODE_ENTITY: return MED::eNOEUD;
153 case EDGE_ENTITY: return MED::eARETE;
154 case FACE_ENTITY: return MED::eFACE;
155 case CELL_ENTITY: return MED::eMAILLE;
157 return MED::EEntiteMaillage(-1);
161 //---------------------------------------------------------------
163 CrSubProfile(const MED::PWrapper& theMEDWrapper,
164 const MED::PMeshInfo& theMeshInfo,
165 MED::EEntiteMaillage theMEntity,
166 MED::EGeometrieElement theMGeom,
167 const MED::TGeom2Size& theGeom2Size,
168 const MED::TGeom2Profile& theGeom2Profile)
170 VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
171 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
173 PMEDSubProfile aSubProfile(new TMEDSubProfile());
174 aSubProfile->myGeom = aEGeom;
175 aSubProfile->myMGeom = theMGeom;
176 aSubProfile->myStatus = eAddAll;
178 MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom);
179 if(aTimeStampIter == theGeom2Size.end())
180 aSubProfile->myStatus = eRemoveAll;
182 MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom);
183 if(aProfileIter != theGeom2Profile.end()){
184 MED::PProfileInfo aProfileInfo = aProfileIter->second;
186 aSubProfile->myName = aProfileInfo->GetName();
187 aSubProfile->myStatus = eAddPart;
189 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
190 TInt aNbElem = anElemNum.size();
191 aSubProfile->myNbCells = aNbElem;
193 case MED::ePOLYGONE: {
194 MED::PPolygoneInfo aPolygoneInfo =
195 theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
196 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
197 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemNum[anElemId]);
198 aSubProfile->myCellsSize += aNbConn;
202 case MED::ePOLYEDRE: {
203 MED::PPolyedreInfo aPolyedreInfo =
204 theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
205 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
206 MED::TCConnSliceArr aConnSliceArr =
207 aPolyedreInfo->GetConnSliceArr(anElemNum[anElemId]);
208 TInt aNbFaces = aConnSliceArr.size();
210 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
211 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
212 TInt aNbConn = aConnSlice.size();
213 aCellSize += aNbConn;
215 aSubProfile->myCellsSize += aCellSize;
220 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
223 TInt aNbElem = aTimeStampIter->second;
224 aSubProfile->myNbCells = aNbElem;
226 case MED::ePOLYGONE: {
227 MED::PPolygoneInfo aPolygoneInfo =
228 theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
229 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
230 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
231 aSubProfile->myCellsSize += aNbConn;
235 case MED::ePOLYEDRE: {
236 MED::PPolyedreInfo aPolyedreInfo =
237 theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
238 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
239 MED::TCConnSliceArr aConnSliceArr =
240 aPolyedreInfo->GetConnSliceArr(anElemId);
241 TInt aNbFaces = aConnSliceArr.size();
243 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
244 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
245 TInt aNbConn = aConnSlice.size();
246 aCellSize += aNbConn;
248 aSubProfile->myCellsSize += aCellSize;
253 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
258 "- aMGeom = "<<theMGeom<<
259 "; aEGeom = "<<aEGeom<<
260 "; aName = '"<<aSubProfile->myName<<"'"<<
261 "; aStatus = "<<aSubProfile->myStatus<<
262 "; aNbCells = "<<aSubProfile->myNbCells<<
263 "; aCellsSize = "<<aSubProfile->myCellsSize<<
270 //---------------------------------------------------------------
272 GetProfileKey(const MED::PWrapper& theMEDWrapper,
273 const MED::PMeshInfo& theMeshInfo,
274 const MED::TTimeStampVal& theTimeStampVal,
275 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
276 MED::EEntiteMaillage theMEntity,
277 const MED::TGeom2Size& theGeom2Size)
279 INITMSG(MYDEBUG,"GetProfileKey"<<endl);
281 TProfileKey aProfileKey;
282 const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
284 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
285 MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
286 for(; anIter != aGeom2Size.end(); anIter++){
287 MED::EGeometrieElement aMGeom = anIter->first;
288 PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
294 aProfileKey.insert(aSubProfile);
301 //---------------------------------------------------------------
303 InitProfile(const MED::PWrapper& theMEDWrapper,
304 const MED::PMeshInfo& theMeshInfo,
305 MED::TTimeStampVal& theTimeStampVal,
306 VISU::TMEDMeshOnEntity& theMeshOnEntity,
307 MED::EEntiteMaillage theMEntity,
308 const MED::TGeom2Size& theGeom2Size,
309 VISU::TMEDValForTime& theValForTime)
311 TTimerLog aTimerLog(MYDEBUG,"InitProfile");
312 INITMSG(MYDEBUG,"InitProfile"<<endl);
314 TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
316 TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
323 TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
324 if(anIter != aProfileMap.end()){
325 theValForTime.myProfile = anIter->second;
326 INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<<endl);
328 PMEDProfile aProfile(new TMEDProfile());
329 TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
331 TProfileKey::const_iterator anIter = aProfileKey.begin();
332 for(; anIter != aProfileKey.end(); anIter++){
333 PMEDSubProfile aSubProfile(*anIter);
335 if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
336 aProfile->myIsAll = false;
338 VISU::EGeometry aEGeom = aSubProfile->myGeom;
339 aGeom2SubProfile[aEGeom] = aSubProfile;
342 aProfileMap[aProfileKey] = aProfile;
343 theValForTime.myProfile = aProfile;
348 //---------------------------------------------------------------
350 GetGaussKey(const MED::TTimeStampVal& theTimeStampVal,
351 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
352 const MED::TGeom2Size& theGeom2Size,
353 VISU::TMEDValForTime& theValForTime)
355 TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
356 INITMSG(MYDEBUG,"GetGaussKey"<<endl);
359 PMEDProfile aProfile = theValForTime.myProfile;
360 TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
362 const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
363 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
365 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
366 MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
367 for(; anIter != aGeom2Size.end(); anIter++){
368 MED::EGeometrieElement aMGeom = anIter->first;
369 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
371 TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
372 if(anIter2 == aGeom2SubProfile.end()){
373 INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
376 PMEDSubProfile aSubProfile = anIter2->second;
378 MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
379 if(aTimeStampIter != theGeom2Size.end()){
380 TInt aNbCells = aTimeStampIter->second;
381 if(aSubProfile->myStatus == eAddPart)
382 aNbCells = aSubProfile->myNbCells;
384 PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
385 aGaussSubMesh->mySubProfile = aSubProfile;
386 aGaussSubMesh->myStatus = aSubProfile->myStatus;
388 PMEDGauss aGauss(new TMEDGauss());
389 aGaussSubMesh->myGauss = aGauss;
390 aGauss->myGeom = aEGeom;
391 aGauss->myNbPoints = 1;
393 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
394 if(aGaussIter != aGeom2Gauss.end()){
395 MED::PGaussInfo aGaussInfo = aGaussIter->second;
396 aGauss->myGaussInfo = aGaussInfo;
397 aGauss->myName = aGaussInfo->GetName();
398 aGauss->myNbPoints = aGaussInfo->GetNbGauss();
401 aGaussSubMesh->myNbCells = aNbCells*aGauss->myNbPoints;
402 aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2;
404 aGaussKey.insert(aGaussSubMesh);
407 "- aEGeom = "<<aGauss->myGeom<<
408 "; aName = '"<<aGauss->myName<<"'"<<
409 "; aNbGauss = "<<aGauss->myNbPoints<<
410 "; aStatus = "<<aGaussSubMesh->myStatus<<
411 "; aNbCells = "<<aGaussSubMesh->myNbCells<<
412 "; aCellsSize = "<<aGaussSubMesh->myCellsSize<<
421 //---------------------------------------------------------------
423 InitGaussMesh(MED::TTimeStampVal& theTimeStampVal,
424 VISU::TMEDMeshOnEntity& theMeshOnEntity,
425 const MED::TGeom2Size& theGeom2Size,
426 VISU::TMEDValForTime& theValForTime)
428 TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
429 INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
431 if(theMeshOnEntity.myEntity == NODE_ENTITY)
434 TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
436 TGaussKey aGaussKey = GetGaussKey(theTimeStampVal,
441 TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
442 if(anIter != aGaussMeshMap.end()){
443 theValForTime.myGaussMesh = anIter->second;
444 INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<<endl);
446 PMEDGaussMesh aGaussMesh(new TMEDGaussMesh());
447 TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
449 TGaussKey::const_iterator anIter = aGaussKey.begin();
450 for(; anIter != aGaussKey.end(); anIter++){
451 PMEDGaussSubMesh aGaussSubMesh(*anIter);
452 PMEDGauss aGauss = aGaussSubMesh->myGauss;
453 VISU::EGeometry aEGeom = aGauss->myGeom;
454 aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh;
458 TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
459 aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size());
460 TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
461 for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){
462 const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
463 aGaussSubMeshArr[anID] = aGaussSubMesh;
466 INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<endl);
467 aGaussMeshMap[aGaussKey] = aGaussMesh;
468 theValForTime.myGaussMesh = aGaussMesh;
473 //---------------------------------------------------------------
475 InitGaussProfile(const MED::PWrapper& theMEDWrapper,
476 const MED::PMeshInfo& theMeshInfo,
477 MED::TTimeStampVal& theTimeStampVal,
478 VISU::TMEDMeshOnEntity& theMeshOnEntity,
479 MED::EEntiteMaillage theMEntity,
480 const MED::TGeom2Size& theGeom2Size,
481 VISU::TMEDValForTime& theValForTime)
483 TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile");
484 INITMSG(MYDEBUG,"InitGaussProfile"<<endl);
486 // The order of the function calls is important
487 InitProfile(theMEDWrapper,
495 InitGaussMesh(theTimeStampVal,
502 //---------------------------------------------------------------
504 BuildMeshOnEntityMap(PMEDMesh theMesh,
505 const MED::TEntityInfo& theEntityInfo,
506 const MED::PNodeInfo& theNodeInfo,
507 const MED::PWrapper& theMEDWrapper)
509 TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
510 INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
512 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
513 const std::string& aMeshName = theMesh->myName;
514 TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
515 MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
516 for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
517 const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
518 const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
520 TEntity aVEntity = MEDEntityToVTK(aMEntity);
521 PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity());
522 aMeshOnEntity->myEntity = aVEntity;
523 aMeshOnEntity->myMeshName = aMeshName;
524 aMeshOnEntity->myGeom2Size = aGeom2Size;
525 TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
528 "- aMEntity = "<<aMEntity<<
529 "; aVEntity = "<<aVEntity<<
532 if(aMEntity == MED::eNOEUD){
533 aMeshOnEntity->myNbCells = theMesh->myNbPoints;
534 aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
536 for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
537 TInt aFamId = theNodeInfo->GetFamNum(iElem);
539 aFamilyID2CellsSize[aFamId] += 2;
543 "- myNbCells = "<<aMeshOnEntity->myNbCells<<
544 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
548 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
549 aMeshOnEntity->myNbCells = 0;
550 aMeshOnEntity->myCellsSize = 0;
551 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
552 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
555 case MED::ePOLYGONE: {
556 MED::PPolygoneInfo aPolygoneInfo = theMEDWrapper->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
557 TInt aNbElem = aPolygoneInfo->GetNbElem();
560 "- aMGeom = "<<aMGeom<<
561 "; aNbElem = "<<aNbElem<<
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);
570 aFamilyID2CellsSize[aFamId] += aNbConn + 1;
574 case MED::ePOLYEDRE: {
575 MED::PPolyedreInfo aPolyedreInfo = theMEDWrapper->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
576 TInt aNbElem = aPolyedreInfo->GetNbElem();
579 "- aMGeom = "<<aMGeom<<
580 "; aNbElem = "<<aNbElem<<
583 aMeshOnEntity->myNbCells += aNbElem;
584 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
585 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(anElemId);
586 TInt aNbFaces = aConnSliceArr.size();
588 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
589 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
590 TInt aNbConn = aConnSlice.size();
591 aCellSize += aNbConn;
593 aMeshOnEntity->myCellsSize += aCellSize;
594 TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
596 aFamilyID2CellsSize[aFamId] += aCellSize + 1;
601 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
602 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
603 MED::PCellInfo aCellInfo = theMEDWrapper->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
604 TInt aNbElem = aCellInfo->GetNbElem();
605 aMeshOnEntity->myNbCells += aNbElem;
606 aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
609 "- aMGeom = "<<aMGeom<<
610 "; aNbElem = "<<aNbElem<<
611 "; myNbCells = "<<aMeshOnEntity->myNbCells<<
612 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
615 for(TInt iElem = 0; iElem < aNbElem; iElem++){
616 TInt aFamId = aCellInfo->GetFamNum(iElem);
618 aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
620 }} // end switch(...)
627 //---------------------------------------------------------------
629 BuildFieldMap(PMEDMesh theMesh,
630 const MED::TEntityInfo& theEntityInfo,
631 MED::PWrapper theMEDWrapper)
633 TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
634 TInt aNbFields = theMEDWrapper->GetNbFields();
635 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
636 const std::string& aMeshName = theMesh->myName;
637 INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
638 for(TInt iField = 1; iField <= aNbFields; iField++){
639 TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
640 MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
641 TInt aNbComp = aFieldInfo->GetNbComp();
642 std::string aFieldName = aFieldInfo->GetName();
644 MED::TGeom2Size aGeom2Size;
645 MED::EEntiteMaillage aMEntity;
646 TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
650 if(aNbTimeStamps < 1)
653 TEntity aVEntity = MEDEntityToVTK(aMEntity);
654 PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
655 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
656 PMEDField aField = aFieldMap[aFieldName](new TMEDField());
657 aField->myId = iField;
658 aField->InitArrays(aNbComp);
659 aField->myEntity = aVEntity;
660 aField->myName = aFieldName;
661 aField->myMeshName = aMeshName;
662 aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
664 INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
665 "; myId = "<<aField->myId<<
666 "; myEntity = "<<aField->myEntity<<
667 "; myDataSize = "<<aField->myDataSize<<
668 "; myNbComp = "<<aField->myNbComp<<"\n");
670 for(TInt iComp = 0; iComp < aNbComp; iComp++){
671 aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp);
672 aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp);
675 for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
676 TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
677 MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
681 TFloat aDt = aTimeStampInfo->GetDt();
682 std::string anUnitDt = aTimeStampInfo->GetUnitDt();
684 TValField& aValField = aField->myValField;
685 PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
686 aValForTime->myId = iTimeStamp;
687 aValForTime->myFieldName = aField->myName;
688 aValForTime->myEntity = aField->myEntity;
689 aValForTime->myMeshName = aField->myMeshName;
690 aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
691 INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
693 TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
694 const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss;
695 MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
696 for(; anIter != aMGeom2NbGauss.end(); anIter++){
697 const MED::EGeometrieElement& aMGeom = anIter->first;
698 EGeometry aEGeom = MEDGeom2VISU(aMGeom);
699 TInt aNbGauss = anIter->second;
700 aVGeom2NbGauss[aEGeom] = aNbGauss;
707 //---------------------------------------------------------------
709 BuildFamilyMap(PMEDMesh theMesh,
710 const MED::TEntityInfo& theEntityInfo,
711 const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
712 const MED::TFamilyInfoSet& theFamilyInfoSet,
713 MED::PWrapper theMEDWrapper)
715 TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
716 INITMSG(MYDEBUG,"BuildFamilyMap\n");
718 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
719 MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
720 MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
721 for(; aEntity2FamilySetIter != aEntity2FamilySet.end(); aEntity2FamilySetIter++){
722 const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
723 const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
725 TEntity aVEntity = MEDEntityToVTK(aMEntity);
726 PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
727 const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
728 TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
730 if(aFamilyTSizeSet.empty())
733 INITMSG(MY_FAMILY_DEBUG,
734 "- aMEntity = "<<aMEntity<<
735 "; aVEntity = "<<aVEntity<<
738 MED::TFamilyTSizeSet::const_iterator aFamilyTSizeSetIter = aFamilyTSizeSet.begin();
739 for(; aFamilyTSizeSetIter != aFamilyTSizeSet.end(); aFamilyTSizeSetIter++){
740 const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
741 const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
742 TInt aSize = boost::get<1>(aFamilyTSize);
743 TInt anId = aFamilyInfo->GetId();
747 std::string aFamilyName = aFamilyInfo->GetName();
749 PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
750 aFamily->myId = anId;
751 aFamily->myEntity = aVEntity;
752 aFamily->myName = aFamilyName;
753 aFamily->myNbCells = aSize;
755 aFamily->myCellsSize = 0;
756 TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
757 if(anIter != aFamilyID2CellsSize.end())
758 aFamily->myCellsSize = anIter->second;
760 INITMSG(MY_FAMILY_DEBUG,
761 "- aFamilyName = '"<<aFamilyName<<"'"<<
762 "; myId = "<<aFamily->myId<<"; "<<
763 "; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
764 "; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
765 "; aVEntity = "<<aVEntity<<
766 "; myNbCells = "<<aFamily->myNbCells<<
767 "; myCellsSize = "<<aFamily->myCellsSize<<
770 const TInt aNbGroup = aFamilyInfo->GetNbGroup();
771 for(TInt i = 0; i < aNbGroup; i++){
772 std::string aGroupName = aFamilyInfo->GetGroupName(i);
773 INITMSG(MY_FAMILY_DEBUG,"- aGroupName = '"<<aGroupName<<"'\n");
782 //---------------------------------------------------------------
784 BuildGroupMap(PMEDMesh theMesh,
785 const MED::TFamilyInfoSet& theFamilyInfoSet)
787 TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
788 INITMSG(MYDEBUG,"BuildGroupMap\n");
790 TGroupMap& aGroupMap = theMesh->myGroupMap;
791 MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
792 MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
793 for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
794 const std::string& aGroupName = aGroupInfoIter->first;
795 INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
797 PMEDGroup aGroup(new TMEDGroup());
798 TFamilySet& aFamilySet = aGroup->myFamilySet;
800 const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
801 MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
802 for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
803 const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
804 std::string aFamilyName = aFamilyInfo->GetName();
806 TEntity aVEntity = TEntity(-1);
810 const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
811 TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
812 for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
813 const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
814 const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
815 TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
816 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
817 const std::string& aName = aFamilyMapIter->first;
818 aFamily = aFamilyMapIter->second;
819 if(aName == aFamilyName){
820 aVEntity = aFamily->myEntity;
826 if(aFamily && aVEntity >= 0){
827 aFamilySet.insert(aFamily);
828 INITMSG(MY_GROUP_DEBUG,
829 "- aFamilyName = '"<<aFamilyName<<"'"<<
830 "; aVEntity = "<<aVEntity<<
834 if(!aFamilySet.empty())
835 aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
840 //---------------------------------------------------------------
843 ::Init(vtkIdType theNbPoints,
845 const MED::PNodeInfo& theNodeInfo)
847 if(theNodeInfo->IsElemNum())
848 TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
850 TNamedPointCoords::Init(theNbPoints,theDim);
851 if(theNodeInfo->IsElemNames())
852 myNodeInfo = theNodeInfo;
857 ::GetNodeName(vtkIdType theObjID) const
860 return myNodeInfo->GetElemName(theObjID);
861 return TNamedPointCoords::GetNodeName(theObjID);
865 //---------------------------------------------------------------
868 ::GetElemObjID(vtkIdType theID) const
871 return myElemNum[theID];
877 //---------------------------------------------------------------
880 ::LessThan(const PGaussImpl& theGauss,
881 bool& theResult) const
883 TGaussImpl::LessThan(theGauss,theResult);
885 if(PMEDGauss aGauss = theGauss){
886 const MED::TGaussInfo& aLeft = myGaussInfo;
887 const MED::TGaussInfo& aReight = aGauss->myGaussInfo;
888 theResult = MED::TGaussInfo::TLess()(aLeft,aReight);
894 //---------------------------------------------------------------
897 ::GetObjID(vtkIdType theID) const
899 TInt aNbPoints = myGauss->myNbPoints;
900 TCellID aCellID = theID / aNbPoints;
902 aCellID = myElemNum[aCellID];
904 TLocalPntID aLocalPntID = theID % aNbPoints;
906 return TGaussPointID(aCellID,aLocalPntID);
910 //---------------------------------------------------------------
913 ::Init(const MED::PElemInfo& theElemInfo)
915 myIsElemNum = theElemInfo->IsElemNum();
916 myElemNum = theElemInfo->myElemNum;
917 if(theElemInfo->IsElemNames())
918 myElemInfo = theElemInfo;
923 ::GetElemObjID(vtkIdType theID) const
926 return myElemNum[theID];
928 return TSubMeshImpl::GetElemObjID(theID);
933 ::GetElemName(vtkIdType theObjID) const
936 return myElemInfo->GetElemName(theObjID);
937 return TSubMeshImpl::GetElemName(theObjID);
943 TSetIsDone(bool& theIsDone):
956 //---------------------------------------------------------------
959 CreateConvertor(const string& theFileName)
961 if(MED::PWrapper aMed = MED::CrWrapper(theFileName))
962 return new VISU_MedConvertor(theFileName);
967 ::VISU_MedConvertor(const string& theFileName):
968 myIsEntitiesDone(false),
969 myIsFieldsDone(false),
970 myIsGroupsDone(false),
971 myIsMinMaxDone(false)
973 myFileInfo.setFile(QString(theFileName.c_str()));
974 myName = myFileInfo.baseName().latin1();
978 //---------------------------------------------------------------
986 TSetIsDone aSetIsDone(myIsEntitiesDone);
987 TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
988 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
990 TInt aNbMeshes = aMed->GetNbMeshes();
991 TMeshMap& aMeshMap = myMeshMap;
993 INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
995 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
999 TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1001 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1002 std::string aMeshName = aMeshInfo->GetName();
1003 TInt aDim = aMeshInfo->GetDim();
1005 MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
1007 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1009 // creating TMesh structure and TMeshOnEntityMap
1010 PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
1011 aMesh->myDim = aDim;
1012 aMesh->myName = aMeshName;
1013 aMesh->myNbPoints = aNodeInfo->GetNbElem();
1014 aMesh->myMeshInfo = aMeshInfo;
1015 aMesh->myEntityInfo = anEntityInfo;
1016 aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
1018 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
1019 "'; myNbPoints = "<<aMesh->myNbPoints<<
1020 "; aDim = "<<aDim<<"\n");
1025 BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
1027 BuildMeshOnEntityMap(aMesh,
1033 }catch(std::exception& exc){
1034 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1036 MSG(MYDEBUG,"Unknown exception !!!");
1041 }catch(std::exception& exc){
1042 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1044 MSG(MYDEBUG,"Unknown exception !!!");
1053 //---------------------------------------------------------------
1061 TSetIsDone aSetIsDone(myIsFieldsDone);
1062 TTimerLog aTimerLog(MYDEBUG,"BuildFields");
1063 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1065 TInt aNbMeshes = aMed->GetNbMeshes();
1066 TMeshMap& aMeshMap = myMeshMap;
1068 INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
1070 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1074 TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1076 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1077 std::string aMeshName = aMeshInfo->GetName();
1079 TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1080 if(anIter == aMeshMap.end())
1082 PMEDMesh aMesh = anIter->second;
1084 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1088 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1090 BuildFieldMap(aMesh,
1094 }catch(std::exception& exc){
1095 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1097 MSG(MYDEBUG,"Unknown exception !!!");
1102 }catch(std::exception& exc){
1103 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1105 MSG(MYDEBUG,"Unknown exception !!!");
1114 //---------------------------------------------------------------
1122 TSetIsDone aSetIsDone(myIsMinMaxDone);
1123 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
1124 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1126 MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
1127 MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
1129 TInt aNbMeshes = aMed->GetNbMeshes();
1130 TMeshMap& aMeshMap = myMeshMap;
1132 INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
1134 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1138 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
1140 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1141 std::string aMeshName = aMeshInfo->GetName();
1143 TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1144 if(anIter == aMeshMap.end())
1146 PMEDMesh aMesh = anIter->second;
1151 TInt aNbFields = aMed->GetNbFields();
1154 "- aMeshName = '"<<aMeshName<<"'"<<
1155 "; aNbFields = "<<aNbFields<<"\n");
1157 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1159 for(TInt iField = 1; iField <= aNbFields; iField++){
1160 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
1161 MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
1162 std::string aFieldName = aFieldInfo->GetName();
1163 INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
1165 MED::TGeom2Size aGeom2Size;
1166 MED::EEntiteMaillage aMEntity;
1167 TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,
1171 if(aNbTimeStamps < 1)
1174 TEntity aVEntity = MEDEntityToVTK(aMEntity);
1175 PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
1176 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1177 PMEDField aField = aFieldMap[aFieldName];
1179 TInt aNbComp = aField->myNbComp;
1180 int aNbComp2 = aNbComp;
1181 if(aNbComp == 2 || aNbComp == 4)
1183 else if(aNbComp > 4)
1186 TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
1187 TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
1188 for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
1189 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
1190 INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
1195 MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
1200 MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
1204 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
1206 const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
1208 const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
1209 MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
1210 for(; anIter != aGeom2Value.end(); anIter++){
1211 const MED::TMeshValue& aMMeshValue = anIter->second;
1212 MED::EGeometrieElement aMGeom = anIter->first;
1214 TInt aNbElem = aMMeshValue.myNbElem;
1215 TInt aNbGauss = aMMeshValue.myNbGauss;
1217 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
1218 if(aGaussIter == aGeom2Gauss.end())
1222 "- aMGeom = "<<aMGeom<<
1223 "; aNbElem = "<<aNbElem<<
1224 "; aNbGauss = "<<aNbGauss<<
1227 // To calculate min/max per components
1228 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1229 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
1230 for(TInt iComp = 0; iComp < aNbComp; iComp++){
1231 const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
1232 TMinMax& aMinMax = aMinMaxArr[iComp+1];
1233 float& aMin = aMinMax.first;
1234 float& aMax = aMinMax.second;
1235 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1236 const float& aVal = aMValueSlice[iGauss];
1237 aMin = min(aMin,aVal);
1238 aMax = max(aMax,aVal);
1243 // To calculate min/max per vector modulus
1244 TMinMax& aMinMax = aMinMaxArr[0];
1245 float& aMin = aMinMax.first;
1246 float& aMax = aMinMax.second;
1247 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1248 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
1249 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1250 const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
1252 for(TInt iComp = 0; iComp < aNbComp2; iComp++){
1253 float aVal = aMValueSlice[iComp];
1254 aValue += aVal*aVal;
1256 aValue = sqrt(aValue);
1257 aMin = min(aMin,aValue);
1258 aMax = max(aMax,aValue);
1263 }catch(std::exception& exc){
1264 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1266 MSG(MYDEBUG,"Unknown exception !!!");
1270 for(TInt iComp = 0; iComp <= aNbComp; iComp++){
1271 VISU::TMinMax aMinMax = aField->GetMinMax(iComp);
1272 INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
1276 }catch(std::exception& exc){
1277 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1279 MSG(MYDEBUG,"Unknown exception !!!");
1284 }catch(std::exception& exc){
1285 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1287 MSG(MYDEBUG,"Unknown exception !!!");
1296 //---------------------------------------------------------------
1304 TSetIsDone aSetIsDone(myIsGroupsDone);
1305 TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
1306 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1308 TInt aNbMeshes = aMed->GetNbMeshes();
1309 TMeshMap& aMeshMap = myMeshMap;
1311 INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
1313 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1317 TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1319 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1320 std::string aMeshName = aMeshInfo->GetName();
1322 TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1323 if(anIter == aMeshMap.end())
1325 PMEDMesh aMesh = anIter->second;
1327 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1329 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1331 MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
1332 MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo);
1337 MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo);
1339 BuildFamilyMap(aMesh,
1341 anEntity2TGeom2ElemInfo,
1345 BuildGroupMap(aMesh,
1348 }catch(std::exception& exc){
1349 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1351 MSG(MYDEBUG,"Unknown exception !!!");
1356 }catch(std::exception& exc){
1357 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1359 MSG(MYDEBUG,"Unknown exception !!!");
1368 //---------------------------------------------------------------
1371 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
1372 VISU::PMeshOnEntityImpl theMeshOnEntity)
1374 TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
1375 INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
1377 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1378 const TEntity& anEntity = theMeshOnEntity->myEntity;
1380 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1381 if(anEntity == NODE_ENTITY){
1382 isPointsUpdated += LoadPoints(aMed,theMesh);
1384 isPointsUpdated += LoadPoints(aMed,theMesh);
1385 isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
1388 return (isPointsUpdated || isCellsOnEntityUpdated);
1392 //---------------------------------------------------------------
1395 ::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
1396 VISU::PMeshOnEntityImpl theMeshOnEntity,
1397 VISU::PFamilyImpl theFamily)
1399 TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
1400 INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
1402 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1403 const TEntity& anEntity = theMeshOnEntity->myEntity;
1405 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1406 if(anEntity == NODE_ENTITY){
1407 isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily);
1409 isPointsUpdated += LoadPoints(aMed,theMesh);
1410 isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,theMeshOnEntity,theFamily);
1413 return (isPointsUpdated || isCellsOnEntityUpdated);
1417 //---------------------------------------------------------------
1420 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
1421 const VISU::TFamilySet& theFamilySet)
1423 TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
1424 INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
1426 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1427 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1428 TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
1429 for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
1430 PMEDFamily aFamily = *aFamilyIter;
1431 const TEntity& anEntity = aFamily->myEntity;
1432 const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
1433 if(anEntity == NODE_ENTITY){
1434 isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily);
1436 isPointsUpdated += LoadPoints(aMed,theMesh);
1437 isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily);
1441 return (isPointsUpdated || isCellsOnEntityUpdated);
1445 //---------------------------------------------------------------
1448 ::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
1449 VISU::PMeshOnEntityImpl theMeshOnEntity,
1450 VISU::PFieldImpl theField,
1451 VISU::PValForTimeImpl theValForTime)
1453 TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
1454 INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
1456 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1458 const TEntity& anEntity = theMeshOnEntity->myEntity;
1459 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1460 isPointsUpdated += LoadPoints(aMed,theMesh);
1461 if(anEntity != NODE_ENTITY)
1462 isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
1463 int isFieldUpdated = LoadValForTimeOnMesh(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
1465 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
1469 //---------------------------------------------------------------
1472 ::LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
1473 VISU::PMeshOnEntityImpl theMeshOnEntity,
1474 VISU::PFieldImpl theField,
1475 VISU::PValForTimeImpl theValForTime)
1477 TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
1478 INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
1480 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1482 const TEntity& anEntity = theMeshOnEntity->myEntity;
1483 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1484 if(anEntity != NODE_ENTITY)
1485 isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
1486 int isFieldUpdated = LoadValForTimeOnGaussPts(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
1488 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
1492 //---------------------------------------------------------------
1495 ::LoadPoints(const MED::PWrapper& theMed,
1496 VISU::PMEDMesh theMesh)
1498 TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
1500 //Check on existing family
1501 PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1502 aMeshOnEntity->myMeshName = theMesh->myName;
1503 aMeshOnEntity->myEntity = NODE_ENTITY;
1505 INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<<theMesh->myIsDone<<"'\n");
1507 //Check on loading already done
1508 if(theMesh->myIsDone)
1512 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
1513 TInt aNbElem = aNodeInfo->GetNbElem();
1514 TInt aDim = theMesh->myDim;
1516 PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
1517 TMEDNamedPointCoords& aCoords = aNamedPointCoords;
1518 aCoords.Init(aNbElem,aDim,aNodeInfo);
1520 for(int iDim = 0; iDim < aDim; iDim++)
1521 aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
1523 for(int iElem = 0; iElem < aNbElem; iElem++){
1524 TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem);
1525 MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem);
1526 for(int iDim = 0; iDim < aDim; iDim++)
1527 aVCoordSlice[iDim] = aMCoordSlice[iDim];
1530 TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
1531 PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh());
1533 aSubMesh->Init(aNodeInfo);
1534 aSubMesh->myNbCells = theMesh->myNbPoints;
1535 aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
1537 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1538 aCell2Connect.resize(aNbElem);
1539 for (int iElem = 0; iElem < aNbElem; iElem++)
1540 aCell2Connect[iElem] = VISU::TConnect(1,iElem);
1542 theMesh->myIsDone = true;
1546 }catch(std::exception& exc){
1549 EXCEPTION(runtime_error,"Unknown exception !!!");
1556 //---------------------------------------------------------------
1559 ::LoadPointsOnFamily(const MED::PWrapper& theMed,
1560 const VISU::PMEDMesh theMesh,
1561 const VISU::PMEDFamily theFamily)
1563 TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
1565 if(theFamily->myIsDone)
1569 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
1570 TInt aNbElem = aNodeInfo->GetNbElem();
1573 TInt anId = theFamily->myId;
1574 TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
1575 for(TInt iElem = 0; iElem < aNbElem; iElem++)
1576 if(aNodeInfo->GetFamNum(iElem) == anId)
1577 aSubMeshID.push_back(iElem);
1580 theFamily->myIsDone = true;
1584 }catch(std::exception& exc){
1587 EXCEPTION(runtime_error,"Unknown exception !!!");
1594 //---------------------------------------------------------------
1597 ::LoadCellsOnEntity(const MED::PWrapper& theMed,
1598 const VISU::PMEDMesh theMesh,
1599 const VISU::PMEDMeshOnEntity theMeshOnEntity)
1601 TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
1605 const TEntity& aVEntity = theMeshOnEntity->myEntity;
1606 const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
1608 INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<<aVEntity<<"\n");
1610 if(theMeshOnEntity->myIsDone)
1613 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
1614 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
1615 TInt aNbPoints = aNodeInfo->GetNbElem();
1617 std::map<TInt,TInt> aNodeIdMap;
1618 #ifdef _EDF_NODE_IDS_
1619 EBooleen anIsNodeNum = MED::eFAUX;
1621 EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
1623 for(TInt i = 0; i < aNbPoints; i++){
1624 aNodeIdMap[aNodeInfo->GetElemNum(i)-1] = i;
1629 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
1630 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
1631 TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1633 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
1634 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
1635 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1636 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
1638 case MED::ePOLYGONE: {
1639 MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
1640 TInt aNbElem = aPolygoneInfo->GetNbElem();
1642 PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
1644 aSubMesh->Init(aPolygoneInfo);
1645 aSubMesh->myNbCells = aNbElem;
1647 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1648 aCell2Connect.resize(aNbElem);
1650 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
1651 MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
1652 TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
1653 aSubMesh->myCellsSize += aNbConn;
1654 TConnect& anArray = aCell2Connect[iElem];
1655 anArray.resize(aNbConn);
1656 for(TInt iConn = 0; iConn < aNbConn; iConn++)
1657 anArray[iConn] = aConnSlice[iConn] - 1;
1662 case MED::ePOLYEDRE: {
1663 MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
1664 TInt aNbElem = aPolyedreInfo->GetNbElem();
1667 PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
1669 aSubMesh->Init(aPolyedreInfo);
1670 aSubMesh->myNbCells = aNbElem;
1672 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1673 aCell2Connect.resize(aNbElem);
1675 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1676 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
1677 TConnect& anArray = aCell2Connect[iElem];
1678 typedef std::set<TInt> TConnectSet;
1679 TConnectSet aConnectSet;
1680 TInt aNbFaces = aConnSliceArr.size();
1681 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
1682 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
1683 TInt aNbConn = aConnSlice.size();
1684 aSubMesh->myCellsSize += aNbConn;
1685 for(TInt iConn = 0; iConn < aNbConn; iConn++){
1686 aConnectSet.insert(aConnSlice[iConn]);
1690 int aNbConn = aConnectSet.size();
1691 anArray.resize(aNbConn);
1692 TConnectSet::iterator anIter = aConnectSet.begin();
1693 for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){
1694 TInt anId = *anIter;
1695 anArray[i] = anId - 1;
1703 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
1704 INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
1706 MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
1707 TInt aNbElem = aCellInfo->GetNbElem();
1710 PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
1712 aSubMesh->Init(aCellInfo);
1713 aSubMesh->myNbCells = aNbElem;
1714 aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
1716 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1717 aCell2Connect.resize(aNbElem);
1719 TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
1720 TVector<TInt> aConnect(aMNbNodes);
1722 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
1723 MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
1724 TConnect& anArray = aCell2Connect[iElem];
1725 anArray.resize(aVNbNodes);
1728 for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
1729 aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1];
1732 for(int iConn = 0; iConn < aMNbNodes; iConn++){
1733 aConnect[iConn] = aConnSlice[iConn] - 1;
1738 #if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1740 anArray[0] = aConnect[0];
1741 anArray[2] = aConnect[1];
1743 anArray[1] = aConnect[2];
1746 #if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1748 anArray[0] = aConnect[0];
1749 anArray[2] = aConnect[1];
1750 anArray[4] = aConnect[2];
1752 anArray[1] = aConnect[3];
1753 anArray[3] = aConnect[4];
1754 anArray[5] = aConnect[5];
1757 #if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1759 anArray[0] = aConnect[0];
1760 anArray[2] = aConnect[1];
1761 anArray[4] = aConnect[2];
1762 anArray[6] = aConnect[3];
1764 anArray[1] = aConnect[4];
1765 anArray[3] = aConnect[5];
1766 anArray[5] = aConnect[6];
1767 anArray[7] = aConnect[7];
1770 #if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1772 anArray[0] = aConnect[0];
1773 anArray[1] = aConnect[2];
1774 anArray[2] = aConnect[1];
1775 anArray[3] = aConnect[3];
1777 anArray[4] = aConnect[6];
1778 anArray[5] = aConnect[5];
1779 anArray[6] = aConnect[4];
1781 anArray[7] = aConnect[7];
1782 anArray[8] = aConnect[9];
1783 anArray[9] = aConnect[8];
1787 anArray[0] = aConnect[0];
1788 anArray[1] = aConnect[2];
1789 anArray[2] = aConnect[1];
1790 anArray[3] = aConnect[3];
1792 #if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1794 anArray[0] = aConnect[0];
1795 anArray[1] = aConnect[3];
1796 anArray[2] = aConnect[2];
1797 anArray[3] = aConnect[1];
1798 anArray[4] = aConnect[4];
1800 anArray[5] = aConnect[5];
1801 anArray[6] = aConnect[8];
1802 anArray[7] = aConnect[7];
1803 anArray[8] = aConnect[6];
1805 anArray[9] = aConnect[9];
1806 anArray[10] = aConnect[12];
1807 anArray[11] = aConnect[11];
1808 anArray[12] = aConnect[10];
1812 anArray[0] = aConnect[0];
1813 anArray[1] = aConnect[3];
1814 anArray[2] = aConnect[2];
1815 anArray[3] = aConnect[1];
1816 anArray[4] = aConnect[4];
1819 for(int iNode = 0; iNode < aVNbNodes; iNode++)
1820 anArray[iNode] = aConnect[iNode];
1822 for(int iNode = 0; iNode < aVNbNodes; iNode++)
1823 if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
1824 EXCEPTION(runtime_error,"LoadCellsOnEntity - "<<
1825 " aNbPoints("<<aNbPoints<<") "<<
1826 "<= anArray["<<iElem<<"]"<<
1828 "("<<anArray[iNode]<<") < 0");
1834 theMeshOnEntity->myIsDone = true;
1839 }catch(std::exception& exc){
1842 EXCEPTION(runtime_error,"Unknown exception !!!");
1850 //---------------------------------------------------------------
1853 ::LoadCellsOnFamily(const MED::PWrapper& theMed,
1854 const VISU::PMEDMesh theMesh,
1855 const VISU::PMEDMeshOnEntity theMeshOnEntity,
1856 const VISU::PMEDFamily theFamily)
1858 TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
1862 const TEntity& aVEntity = theMeshOnEntity->myEntity;
1863 const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
1865 INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<<aVEntity<<"\n");
1867 if(theFamily->myIsDone)
1870 TInt anId = theFamily->myId;
1872 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
1873 TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
1875 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
1876 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
1877 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
1878 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
1879 MED::PElemInfo anElemInfo;
1881 case MED::ePOLYGONE: {
1882 anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
1885 case MED::ePOLYEDRE: {
1886 anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
1890 anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
1894 if(TInt aNbElem = anElemInfo->GetNbElem()){
1895 TSubMeshID aSubMeshID;
1896 for(TInt iElem = 0; iElem < aNbElem; iElem++)
1897 if(anElemInfo->GetFamNum(iElem) == anId)
1898 aSubMeshID.push_back(iElem);
1899 if(!aSubMeshID.empty()){
1900 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1901 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
1902 aGeom2SubMeshID.insert(TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
1908 theFamily->myIsDone = true;
1913 }catch(std::exception& exc){
1916 EXCEPTION(runtime_error,"Unknown exception !!!");
1924 //---------------------------------------------------------------
1926 LoadProfile(const MED::PWrapper& theMed,
1927 VISU::PMEDMesh theMesh,
1928 MED::TTimeStampVal& theTimeStampVal,
1929 VISU::TMEDValForTime& theValForTime,
1930 VISU::TMEDMeshOnEntity& theMeshOnEntity)
1932 TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
1933 INITMSG(MYDEBUG,"LoadProfile"<<endl);
1935 PMEDProfile aProfile = theValForTime.myProfile;
1936 if(aProfile->myIsDone)
1939 const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
1940 const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
1941 MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin();
1942 for(; anIter != aGeom2Profile.end(); anIter++){
1943 MED::PProfileInfo aProfileInfo = anIter->second;
1944 MED::EGeometrieElement aMGeom = anIter->first;
1945 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1947 TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
1948 if(anIter2 != aGeom2SubProfile.end()){
1949 PMEDSubProfile aSubProfile = anIter2->second;
1951 MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
1952 if(!anElemNum.empty()){
1953 TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
1954 TInt aSize = anElemNum.size();
1955 aSubMeshID.resize(aSize);
1956 for(TInt anId = 0; anId < aSize; anId++)
1957 aSubMeshID[anId] = anElemNum[anId] - 1;
1961 "- aEGeom = "<<aEGeom<<
1962 "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
1967 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
1969 TEntity aVEntity = theMeshOnEntity.myEntity;
1970 MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
1972 const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
1973 TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
1974 for(; anIter != aGeom2SubProfile.end(); anIter++){
1975 const PMEDSubProfile& aSubProfile = anIter->second;
1976 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
1977 MED::PElemInfo anElemInfo;
1978 if(aMEntity == MED::eNOEUD)
1979 anElemInfo = theMed->GetPNodeInfo(aMeshInfo);
1982 case MED::ePOLYGONE: {
1983 anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
1986 case MED::ePOLYEDRE: {
1987 anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
1991 anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
1995 aSubProfile->myIsElemNum = anElemInfo->IsElemNum();
1996 aSubProfile->myElemNum = anElemInfo->myElemNum;
2000 aProfile->myIsDone = true;
2004 //---------------------------------------------------------------
2006 LoadGaussMesh(const MED::PWrapper& theMed,
2007 VISU::PMEDMesh theMesh,
2008 MED::TTimeStampVal& theTimeStampVal,
2009 VISU::TMEDValForTime& theValForTime,
2010 VISU::TMEDMeshOnEntity& theMeshOnEntity)
2012 TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
2013 INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
2015 PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
2016 if(!aGaussMesh || aGaussMesh->myIsDone)
2019 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2020 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
2022 TEntity aVEntity = theMeshOnEntity.myEntity;
2023 MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
2025 const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
2026 const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
2027 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
2029 TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
2030 for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){
2031 PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
2032 VISU::EGeometry aEGeom = aSubMeshIter->first;
2034 if(aGaussSubMesh->myIsDone)
2037 PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
2038 const TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
2039 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2041 MED::PPolygoneInfo aPolygoneInfo;
2042 MED::PPolyedreInfo aPolyedreInfo;
2043 MED::PCellInfo aCellInfo;
2044 MED::PElemInfo anElemInfo;
2047 case MED::ePOLYGONE:
2048 aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,
2051 anElemInfo = aPolygoneInfo;
2053 case MED::ePOLYEDRE:
2054 aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,
2057 anElemInfo = aPolyedreInfo;
2060 aCellInfo = theMed->GetPCellInfo(aMeshInfo,
2063 anElemInfo = aCellInfo;
2065 aGaussSubMesh->myIsElemNum = anElemInfo->IsElemNum();
2066 aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
2069 MED::TGaussCoord aGaussCoord;
2070 bool anIsGaussCoord3D = false;
2072 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
2073 if(aGaussIter != aGeom2Gauss.end()){
2074 PMEDGauss aGauss = aGaussSubMesh->myGauss;
2075 MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo;
2077 aName = aGaussInfo->GetName();
2078 if(!aSubMeshID.empty()){
2079 const std::string& aProfileName = aSubProfile->myName;
2080 MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2083 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2084 anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2091 anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2097 if(!aSubMeshID.empty()){
2098 const std::string& aProfileName = aSubProfile->myName;
2099 MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2102 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2104 case MED::ePOLYGONE:
2105 anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2110 case MED::ePOLYEDRE:
2111 anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2117 anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2125 case MED::ePOLYGONE:
2126 anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2130 case MED::ePOLYEDRE:
2131 anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2136 anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2142 if(anIsGaussCoord3D){
2143 TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
2144 TInt aNbGauss = aGaussCoord.GetNbGauss();
2145 TInt aNbElem = aGaussCoord.GetNbElem();
2146 TInt aDim = aGaussCoord.GetDim();
2147 vtkIdType aNbCells = aNbElem*aNbGauss;
2148 aCoords.Init(aNbCells,aDim);
2149 for(TInt anElemId = 0, aNodeId = 0; anElemId < aNbElem; anElemId++){
2150 MED::TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId);
2151 for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aNodeId++){
2152 MED::TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
2153 TCoordSlice aSlice = aCoords.GetCoordSlice(aNodeId);
2154 for(TInt aDimId = 0; aDimId < aDim; aDimId++)
2155 aSlice[aDimId] = aCoordSlice[aDimId];
2159 aGaussSubMesh->myIsDone = true;;
2162 "- aEGeom = "<<aEGeom<<
2163 "; aName = '"<<aName<<"'"<<
2164 "; aStatus = "<<aGaussSubMesh->myStatus<<
2165 "; aNbElem = "<<aNbElem<<
2166 "; aNbGauss = "<<aNbGauss<<
2167 "; aNbCells = "<<aNbCells<<
2172 aGaussMesh->myIsDone = true;
2176 //---------------------------------------------------------------
2178 LoadValForTime(const MED::PWrapper& theMed,
2179 VISU::PMEDMesh theMesh,
2180 VISU::PMEDMeshOnEntity theMeshOnEntity,
2181 VISU::PMEDField theField,
2182 VISU::PMEDValForTime theValForTime,
2186 TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
2187 INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
2189 //Check on loading already done
2194 const std::string& aMeshName = theMeshOnEntity->myMeshName;
2195 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2196 MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,
2199 MED::TGeom2Size aGeom2Size;
2200 MED::EEntiteMaillage aMEntity;
2201 theMed->GetNbTimeStamps(aFieldInfo,
2202 theMesh->myEntityInfo,
2206 MED::PTimeStampInfo aTimeStampInfo =
2207 theMed->GetPTimeStampInfo(aFieldInfo,
2210 theValForTime->myId);
2212 MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
2213 MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
2215 MED::PTimeStampVal aTimeStampVal =
2216 theMed->GetPTimeStampVal(aTimeStampInfo,
2220 InitGaussProfile(theMed,
2235 LoadGaussMesh(theMed,
2241 PMEDProfile aProfile = theValForTime->myProfile;
2242 TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2244 TInt aNbComp = theField->myNbComp;
2247 "- aMeshName = '"<<aMeshName<<"'"<<
2248 "; aFieldName = '"<<aFieldInfo->GetName()<<"'"<<
2249 "; aMEntity = "<<aMEntity<<
2250 "; aNbComp = "<<aNbComp<<
2253 theField->myDataSize = 0;
2255 const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
2256 TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
2257 for(; anIter != aGeom2SubProfile.end(); anIter++){
2258 VISU::EGeometry aEGeom = anIter->first;
2259 PMEDSubProfile aSubProfile(anIter->second);
2261 TInt aNbElem = aSubProfile->myNbCells;
2262 theField->myDataSize += aNbElem*aNbComp;
2264 if(aSubProfile->myStatus != eRemoveAll){
2265 TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
2268 "- aEGeom = "<<aEGeom<<
2269 "; aNbElem = "<<aNbElem<<
2270 "; aNbGauss = "<<aNbGauss<<
2273 TMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
2274 aVMeshValue.Init(aNbElem,aNbGauss,aNbComp);
2276 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2277 const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
2278 for(TInt iElem = 0; iElem < aNbElem; iElem++){
2279 TValueSliceArr aVValueSliceArr = aVMeshValue.GetGaussValueSliceArr(iElem);
2280 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
2281 ADDMSG(MYVALUEDEBUG,"{");
2282 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
2283 TValueSlice& aVValueSlice = aVValueSliceArr[iGauss];
2284 const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
2285 for(TInt iComp = 0; iComp < aNbComp; iComp++){
2286 aVValueSlice[iComp] = aMValueSlice[iComp];
2287 ADDMSG(MYVALUEDEBUG,aVValueSlice[iComp]<<" ");
2289 ADDMSG(MYVALUEDEBUG,"| ");
2291 ADDMSG(MYVALUEDEBUG,"} ");
2293 ADDMSG(MYDEBUG,"\n");
2303 //---------------------------------------------------------------
2306 ::LoadValForTimeOnMesh(const MED::PWrapper& theMed,
2307 VISU::PMEDMesh theMesh,
2308 VISU::PMEDMeshOnEntity theMeshOnEntity,
2309 VISU::PMEDField theField,
2310 VISU::PMEDValForTime theValForTime)
2312 PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
2313 return LoadValForTime(theMed,
2319 anIDMapperFilter->myIsVTKDone);
2323 //---------------------------------------------------------------
2326 ::LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
2327 VISU::PMEDMesh theMesh,
2328 VISU::PMEDMeshOnEntity theMeshOnEntity,
2329 VISU::PMEDField theField,
2330 VISU::PMEDValForTime theValForTime)
2332 PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
2333 return LoadValForTime(theMed,
2339 aGaussPtsIDFilter->myIsVTKDone);