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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VISU_MedConvertor.cxx
24 // Author : Alexey PETROV
29 #include "VISU_MedConvertor.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 "SALOMEconfig.h"
39 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
43 #include <Standard_Failure.hxx>
46 #include <Standard_ErrorHandler.hxx>
49 #include <vtkCellType.h>
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 static int MYDEBUG = 0;
63 static int MYVALUEDEBUG = 0;
64 static int MY_FAMILY_DEBUG = 0;
65 static int MY_GROUP_DEBUG = 0;
68 #define _LOAD_FAMILIES_
69 #define _EDF_NODE_IDS_
75 //---------------------------------------------------------------
77 MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
79 return theMEDGeomType % 100;
83 //---------------------------------------------------------------
85 MEDGeom2VISU(MED::EGeometrieElement theGeom)
88 case MED::ePOINT1: return VISU::ePOINT1;
89 case MED::eSEG2: return VISU::eSEG2;
90 case MED::eTRIA3: return VISU::eTRIA3;
91 case MED::eQUAD4: return VISU::eQUAD4;
92 case MED::eTETRA4: return VISU::eTETRA4;
93 case MED::eHEXA8: return VISU::eHEXA8;
94 case MED::ePENTA6: return VISU::ePENTA6;
95 case MED::ePYRA5: return VISU::ePYRA5;
97 case MED::eSEG3: return VISU::eSEG3;
98 case MED::eTRIA6: return VISU::eTRIA6;
99 case MED::eQUAD8: return VISU::eQUAD8;
100 case MED::eTETRA10: return VISU::eTETRA10;
101 case MED::eHEXA20: return VISU::eHEXA20;
102 case MED::ePENTA15: return VISU::ePENTA15;
103 case MED::ePYRA13: return VISU::ePYRA13;
105 case MED::ePOLYGONE: return VISU::ePOLYGONE;
106 case MED::ePOLYEDRE: return VISU::ePOLYEDRE;
112 //---------------------------------------------------------------
113 MED::EGeometrieElement
114 VISUGeom2MED(int theGeom)
117 case VISU::ePOINT1: return MED::ePOINT1;
118 case VISU::eSEG2: return MED::eSEG2;
119 case VISU::eTRIA3: return MED::eTRIA3;
120 case VISU::eQUAD4: return MED::eQUAD4;
121 case VISU::eTETRA4: return MED::eTETRA4;
122 case VISU::eHEXA8: return MED::eHEXA8;
123 case VISU::ePENTA6: return MED::ePENTA6;
124 case VISU::ePYRA5: return MED::ePYRA5;
126 case VISU::eSEG3: return MED::eSEG3;
127 case VISU::eTRIA6: return MED::eTRIA6;
128 case VISU::eQUAD8: return MED::eQUAD8;
129 case VISU::eTETRA10: return MED::eTETRA10;
130 case VISU::eHEXA20: return MED::eHEXA20;
131 case VISU::ePENTA15: return MED::ePENTA15;
132 case VISU::ePYRA13: return MED::ePYRA13;
134 case VISU::ePOLYGONE: return MED::ePOLYGONE;
135 case VISU::ePOLYEDRE: return MED::ePOLYEDRE;
137 return MED::EGeometrieElement(-1);
141 //---------------------------------------------------------------
143 MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
145 switch(theMEDEntity){
146 case MED::eNOEUD: return VISU::NODE_ENTITY;
147 case MED::eARETE: return VISU::EDGE_ENTITY;
148 case MED::eFACE: return VISU::FACE_ENTITY;
149 case MED::eMAILLE: return VISU::CELL_ENTITY;
151 return VISU::TEntity(-1);
155 //---------------------------------------------------------------
157 VTKEntityToMED(VISU::TEntity theVTKEntity)
159 switch(theVTKEntity){
160 case VISU::NODE_ENTITY: return MED::eNOEUD;
161 case VISU::EDGE_ENTITY: return MED::eARETE;
162 case VISU::FACE_ENTITY: return MED::eFACE;
163 case VISU::CELL_ENTITY: return MED::eMAILLE;
165 return MED::EEntiteMaillage(-1);
169 //---------------------------------------------------------------
171 CrSubProfile(const MED::PWrapper& theMEDWrapper,
172 const MED::PMeshInfo& theMeshInfo,
173 MED::EEntiteMaillage theMEntity,
174 MED::EGeometrieElement theMGeom,
175 const MED::TGeom2Size& theGeom2Size,
176 const MED::TGeom2Profile& theGeom2Profile)
178 VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
179 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
181 VISU::PMEDSubProfile aSubProfile(new VISU::TMEDSubProfile());
182 aSubProfile->myGeom = aEGeom;
183 aSubProfile->myMGeom = theMGeom;
184 aSubProfile->myStatus = VISU::eAddAll;
186 MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom);
187 if(aTimeStampIter == theGeom2Size.end())
188 aSubProfile->myStatus = VISU::eRemoveAll;
190 MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom);
191 if(aProfileIter != theGeom2Profile.end()){
192 MED::PProfileInfo aProfileInfo = aProfileIter->second;
194 aSubProfile->myName = aProfileInfo->GetName();
195 aSubProfile->myStatus = VISU::eAddPart;
197 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
198 TInt aNbElem = anElemNum.size();
199 aSubProfile->myNbCells = aNbElem;
201 case MED::ePOLYGONE: {
202 MED::PPolygoneInfo aPolygoneInfo =
203 theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
204 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
205 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemNum[anElemId]);
206 aSubProfile->myCellsSize += aNbConn;
210 case MED::ePOLYEDRE: {
211 MED::PPolyedreInfo aPolyedreInfo =
212 theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
213 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
214 MED::TCConnSliceArr aConnSliceArr =
215 aPolyedreInfo->GetConnSliceArr(anElemNum[anElemId]);
216 TInt aNbFaces = aConnSliceArr.size();
218 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
219 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
220 TInt aNbConn = aConnSlice.size();
221 aCellSize += aNbConn;
223 aSubProfile->myCellsSize += aCellSize;
228 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
231 TInt aNbElem = aTimeStampIter->second;
232 aSubProfile->myNbCells = aNbElem;
234 case MED::ePOLYGONE: {
235 MED::PPolygoneInfo aPolygoneInfo =
236 theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
237 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
238 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
239 aSubProfile->myCellsSize += aNbConn;
243 case MED::ePOLYEDRE: {
244 MED::PPolyedreInfo aPolyedreInfo =
245 theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
246 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
247 MED::TCConnSliceArr aConnSliceArr =
248 aPolyedreInfo->GetConnSliceArr(anElemId);
249 TInt aNbFaces = aConnSliceArr.size();
251 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
252 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
253 TInt aNbConn = aConnSlice.size();
254 aCellSize += aNbConn;
256 aSubProfile->myCellsSize += aCellSize;
261 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
266 "- aMGeom = "<<theMGeom<<
267 "; aEGeom = "<<aEGeom<<
268 "; aName = '"<<aSubProfile->myName<<"'"<<
269 "; aStatus = "<<aSubProfile->myStatus<<
270 "; aNbCells = "<<aSubProfile->myNbCells<<
271 "; aCellsSize = "<<aSubProfile->myCellsSize<<
278 //---------------------------------------------------------------
280 GetProfileKey(const MED::PWrapper& theMEDWrapper,
281 const MED::PMeshInfo& theMeshInfo,
282 const MED::PTimeStampValueBase& theTimeStampValue,
283 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
284 MED::EEntiteMaillage theMEntity,
285 const MED::TGeom2Size& theGeom2Size)
287 INITMSG(MYDEBUG,"GetProfileKey"<<endl);
289 VISU::TProfileKey aProfileKey;
290 const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile();
292 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
293 MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
294 for(; anIter != aGeom2Size.end(); anIter++){
295 MED::EGeometrieElement aMGeom = anIter->first;
296 VISU::PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
302 aProfileKey.insert(aSubProfile);
309 //---------------------------------------------------------------
311 InitProfile(const MED::PWrapper& theMEDWrapper,
312 const MED::PMeshInfo& theMeshInfo,
313 MED::PTimeStampValueBase& theTimeStampValue,
314 VISU::TMEDMeshOnEntity& theMeshOnEntity,
315 MED::EEntiteMaillage theMEntity,
316 const MED::TGeom2Size& theGeom2Size,
317 VISU::TMEDValForTime& theValForTime)
319 VISU::TTimerLog aTimerLog(MYDEBUG,"InitProfile");
320 INITMSG(MYDEBUG,"InitProfile"<<endl);
322 VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
324 VISU::TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
331 VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
332 if(anIter != aProfileMap.end()){
333 theValForTime.myProfile = anIter->second;
334 INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<<endl);
336 VISU::PMEDProfile aProfile(new VISU::TMEDProfile());
337 VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
339 VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
340 for(; anIter != aProfileKey.end(); anIter++){
341 VISU::PMEDSubProfile aSubProfile(*anIter);
343 if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
344 aProfile->myIsAll = false;
346 VISU::EGeometry aEGeom = aSubProfile->myGeom;
347 aGeom2SubProfile[aEGeom] = aSubProfile;
350 aProfileMap[aProfileKey] = aProfile;
351 theValForTime.myProfile = aProfile;
356 //---------------------------------------------------------------
358 GetGaussKey(const MED::PTimeStampValueBase& theTimeStampValue,
359 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
360 const MED::TGeom2Size& theGeom2Size,
361 VISU::TMEDValForTime& theValForTime)
363 VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
364 INITMSG(MYDEBUG,"GetGaussKey"<<endl);
366 VISU::TGaussKey aGaussKey;
367 VISU::PMEDProfile aProfile = theValForTime.myProfile;
368 VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
370 const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo();
371 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
373 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
374 MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
375 for(; anIter != aGeom2Size.end(); anIter++){
376 MED::EGeometrieElement aMGeom = anIter->first;
377 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
379 VISU::TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
380 if(anIter2 == aGeom2SubProfile.end()){
381 INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
384 VISU::PMEDSubProfile aSubProfile = anIter2->second;
386 MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
387 if(aTimeStampIter != theGeom2Size.end()){
388 TInt aNbCells = aTimeStampIter->second;
389 if(aSubProfile->myStatus == VISU::eAddPart)
390 aNbCells = aSubProfile->myNbCells;
392 VISU::PMEDGaussSubMesh aGaussSubMesh(new VISU::TMEDGaussSubMesh());
393 aGaussSubMesh->mySubProfile = aSubProfile;
394 aGaussSubMesh->myStatus = aSubProfile->myStatus;
396 VISU::PMEDGauss aGauss(new VISU::TMEDGauss());
397 aGaussSubMesh->myGauss = aGauss;
398 aGauss->myGeom = aEGeom;
399 aGauss->myNbPoints = 1;
401 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
402 if(aGaussIter != aGeom2Gauss.end()){
403 MED::PGaussInfo aGaussInfo = aGaussIter->second;
404 aGauss->myGaussInfo = aGaussInfo;
405 aGauss->myName = aGaussInfo->GetName();
406 aGauss->myNbPoints = aGaussInfo->GetNbGauss();
409 aGaussSubMesh->myNbCells = aNbCells*aGauss->myNbPoints;
410 aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2;
412 aGaussKey.insert(aGaussSubMesh);
415 "- aEGeom = "<<aGauss->myGeom<<
416 "; aName = '"<<aGauss->myName<<"'"<<
417 "; aNbGauss = "<<aGauss->myNbPoints<<
418 "; aStatus = "<<aGaussSubMesh->myStatus<<
419 "; aNbCells = "<<aGaussSubMesh->myNbCells<<
420 "; aCellsSize = "<<aGaussSubMesh->myCellsSize<<
431 //---------------------------------------------------------------
433 InitGaussMesh(MED::PTimeStampValueBase& theTimeStampValue,
434 VISU::TMEDMeshOnEntity& theMeshOnEntity,
435 const MED::TGeom2Size& theGeom2Size,
436 VISU::TMEDValForTime& theValForTime)
438 VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
439 INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
441 if(theMeshOnEntity.myEntity == VISU::NODE_ENTITY)
444 VISU::TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
446 VISU::TGaussKey aGaussKey = GetGaussKey(theTimeStampValue,
451 VISU::TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
452 if(anIter != aGaussMeshMap.end()){
453 theValForTime.myGaussMesh = anIter->second;
454 INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<<endl);
456 VISU::PMEDGaussMesh aGaussMesh(new VISU::TMEDGaussMesh());
457 VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
459 VISU::TGaussKey::const_iterator anIter = aGaussKey.begin();
460 for(; anIter != aGaussKey.end(); anIter++){
461 VISU::PMEDGaussSubMesh aGaussSubMesh(*anIter);
462 VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss;
463 VISU::EGeometry aEGeom = aGauss->myGeom;
464 aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh;
468 VISU::TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
469 aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size());
470 VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
471 for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){
472 const VISU::PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
473 aGaussSubMeshArr[anID] = aGaussSubMesh;
476 INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<std::endl);
477 aGaussMeshMap[aGaussKey] = aGaussMesh;
478 theValForTime.myGaussMesh = aGaussMesh;
483 //---------------------------------------------------------------
485 InitGaussProfile(const MED::PWrapper& theMEDWrapper,
486 const MED::PMeshInfo& theMeshInfo,
487 MED::PTimeStampValueBase& theTimeStampValue,
488 VISU::TMEDMeshOnEntity& theMeshOnEntity,
489 MED::EEntiteMaillage theMEntity,
490 const MED::TGeom2Size& theGeom2Size,
491 VISU::TMEDValForTime& theValForTime)
493 VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile");
494 INITMSG(MYDEBUG,"InitGaussProfile"<<std::endl);
496 // The order of the function calls is important
497 InitProfile(theMEDWrapper,
505 InitGaussMesh(theTimeStampValue,
512 //---------------------------------------------------------------
514 BuildMeshOnEntityMap(VISU::PMEDMesh theMesh,
515 const MED::TEntityInfo& theEntityInfo,
516 const MED::PNodeInfo& theNodeInfo,
517 const MED::PWrapper& theMEDWrapper)
519 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
520 INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
522 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
523 const std::string& aMeshName = theMesh->myName;
524 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
525 MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
526 for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
527 const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
528 const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
530 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
531 VISU::PMEDMeshOnEntity aMeshOnEntity =
532 aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity());
533 aMeshOnEntity->myEntity = aVEntity;
534 aMeshOnEntity->myMeshName = aMeshName;
535 aMeshOnEntity->myGeom2Size = aGeom2Size;
536 VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
539 "- aMEntity = "<<aMEntity<<
540 "; aVEntity = "<<aVEntity<<
543 if(aMEntity == MED::eNOEUD){
544 aMeshOnEntity->myNbCells = theMesh->myNbPoints;
545 aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
547 for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
548 TInt aFamId = theNodeInfo->GetFamNum(iElem);
550 aFamilyID2CellsSize[aFamId] += 2;
554 "- myNbCells = "<<aMeshOnEntity->myNbCells<<
555 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
559 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
560 aMeshOnEntity->myNbCells = 0;
561 aMeshOnEntity->myCellsSize = 0;
562 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
563 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
566 case MED::ePOLYGONE: {
567 MED::PPolygoneInfo aPolygoneInfo = theMEDWrapper->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
568 TInt aNbElem = aPolygoneInfo->GetNbElem();
571 "- aMGeom = "<<aMGeom<<
572 "; aNbElem = "<<aNbElem<<
575 aMeshOnEntity->myNbCells += aNbElem;
576 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
577 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
578 aMeshOnEntity->myCellsSize += aNbConn;
579 TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
581 aFamilyID2CellsSize[aFamId] += aNbConn + 1;
585 case MED::ePOLYEDRE: {
586 MED::PPolyedreInfo aPolyedreInfo = theMEDWrapper->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
587 TInt aNbElem = aPolyedreInfo->GetNbElem();
590 "- aMGeom = "<<aMGeom<<
591 "; aNbElem = "<<aNbElem<<
594 aMeshOnEntity->myNbCells += aNbElem;
595 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
596 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(anElemId);
597 TInt aNbFaces = aConnSliceArr.size();
599 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
600 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
601 TInt aNbConn = aConnSlice.size();
602 aCellSize += aNbConn;
604 aMeshOnEntity->myCellsSize += aCellSize;
605 TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
607 aFamilyID2CellsSize[aFamId] += aCellSize + 1;
612 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
613 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
614 MED::PCellInfo aCellInfo = theMEDWrapper->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
615 TInt aNbElem = aCellInfo->GetNbElem();
616 aMeshOnEntity->myNbCells += aNbElem;
617 aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
620 "- aMGeom = "<<aMGeom<<
621 "; aNbElem = "<<aNbElem<<
622 "; myNbCells = "<<aMeshOnEntity->myNbCells<<
623 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
626 for(TInt iElem = 0; iElem < aNbElem; iElem++){
627 TInt aFamId = aCellInfo->GetFamNum(iElem);
629 aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
631 }} // end switch(...)
637 //---------------------------------------------------------------
639 BuildMeshGrilleOnEntityMap(VISU::PMEDMesh theMesh,
640 const MED::TEntityInfo& theEntityInfo,
641 const MED::PGrilleInfo& theGrilleInfo,
642 const MED::PWrapper& theMEDWrapper)
644 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMeshGrilleOnEntityMap");
645 INITMSG(MYDEBUG,"BuildMeshGrilleOnEntityMap"<<endl);
647 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
648 const std::string& aMeshName = theMesh->myName;
649 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
650 MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
652 //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
656 MED::TIntVector aIntVec;
657 if(theGrilleInfo->GetGrilleType()!=MED::eGRILLE_STANDARD)
658 for(int i=0;i<theMesh->myDim;i++)
659 aIntVec.push_back(theGrilleInfo->GetNbIndexes(i));
661 aIntVec = theGrilleInfo->GetGrilleStructure();
663 theMesh->myGrilleStructure = aIntVec;
665 switch((theMesh->GetStructure()).size()){
666 case 3: kMax=theMesh->GetStructure()[2];
667 case 2: jMax=theMesh->GetStructure()[1];
668 case 1: iMax=theMesh->GetStructure()[0];
672 switch(theMesh->myDim){
674 for(int i=1;i<=iMax;i++)
675 (theMesh->myObjID2StructureID[i-1]).push_back(i);
678 for(int j=1;j<=jMax;j++)
679 for(int i=1;i<=iMax;i++){
680 (theMesh->myObjID2StructureID[iii]).push_back(i);
681 (theMesh->myObjID2StructureID[iii]).push_back(j);
686 for(int k=1;k<=kMax ;k++)
687 for(int j=1;j<=jMax;j++)
688 for(int i=1;i<=iMax;i++)
690 (theMesh->myObjID2StructureID[iii]).push_back(i);
691 (theMesh->myObjID2StructureID[iii]).push_back(j);
692 (theMesh->myObjID2StructureID[iii]).push_back(k);
698 for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
699 const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
700 const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
702 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
703 VISU::PMEDMeshOnEntity aMeshOnEntity =
704 aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity());
705 aMeshOnEntity->myEntity = aVEntity;
706 aMeshOnEntity->myMeshName = aMeshName;
707 aMeshOnEntity->myGeom2Size = aGeom2Size;
708 VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
711 "- aMEntity = "<<aMEntity<<
712 "; aVEntity = "<<aVEntity<<
715 if(aMEntity == MED::eNOEUD){
716 aMeshOnEntity->myNbCells = theGrilleInfo->GetNbNodes();
717 aMeshOnEntity->myCellsSize = 2*theGrilleInfo->GetNbNodes();
719 if((theGrilleInfo->myFamNumNode).size() > 0)
720 for(TInt iElem = 0; iElem < theGrilleInfo->GetNbNodes(); iElem++){
721 TInt aFamId = theGrilleInfo->GetFamNumNode(iElem);
723 aFamilyID2CellsSize[aFamId] += 2;
727 "- myNbCells = "<<aMeshOnEntity->myNbCells<<
728 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
732 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
733 aMeshOnEntity->myNbCells = 0;
734 aMeshOnEntity->myCellsSize = 0;
735 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
736 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
737 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
738 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
739 TInt aNbElem = aGeom2SizeIter->second;//theGrilleInfo->GetNbCells();
740 aMeshOnEntity->myNbCells += aNbElem;
741 aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
744 "- aMGeom = "<<aMGeom<<
745 "; aNbElem = "<<aNbElem<<
746 "; myNbCells = "<<aMeshOnEntity->myNbCells<<
747 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
750 if((theGrilleInfo->myFamNum).size() > 0)
751 for(TInt iElem = 0; iElem < aNbElem; iElem++){
752 TInt aFamId = theGrilleInfo->GetFamNum(iElem);
754 aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
762 //---------------------------------------------------------------
764 BuildFieldMap(VISU::PMEDMesh theMesh,
765 const MED::TEntityInfo& theEntityInfo,
766 MED::PWrapper theMEDWrapper)
768 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
769 TInt aNbFields = theMEDWrapper->GetNbFields();
770 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
771 const std::string& aMeshName = theMesh->myName;
772 INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
773 for(TInt iField = 1; iField <= aNbFields; iField++){
774 VISU::TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
776 MED::TErr anError = 0;
777 MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo, iField, &anError);
781 TInt aNbComp = aFieldInfo->GetNbComp();
782 std::string aFieldName = aFieldInfo->GetName();
784 MED::TGeom2Size aGeom2Size;
785 MED::EEntiteMaillage aMEntity;
786 TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
790 if(aNbTimeStamps < 1)
793 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
794 vtkIdType aDataType = VTK_DOUBLE;
795 if(aFieldInfo->GetType() != MED::eFLOAT64){
796 #if defined(HAVE_F77INT64)
797 aDataType = VTK_LONG;
802 VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
803 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
804 VISU::PMEDField aField = aFieldMap[aFieldName](new VISU::TMEDField());
805 aField->myId = iField;
806 aField->Init(aNbComp, aDataType);
807 aField->myEntity = aVEntity;
808 aField->myName = aFieldName;
809 aField->myMeshName = aMeshName;
810 aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
812 INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
813 "; myId = "<<aField->myId<<
814 "; myEntity = "<<aField->myEntity<<
815 "; myDataSize = "<<aField->myDataSize<<
816 "; myNbComp = "<<aField->myNbComp<<"\n");
818 for(TInt iComp = 0; iComp < aNbComp; iComp++){
819 aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp);
820 aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp);
823 for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
824 VISU::TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
826 MED::TErr anError = 0;
827 MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
835 TFloat aDt = aTimeStampInfo->GetDt();
836 std::string anUnitDt = aTimeStampInfo->GetUnitDt();
838 VISU::TValField& aValField = aField->myValField;
839 VISU::PMEDValForTime aValForTime = aValField[iTimeStamp](new VISU::TMEDValForTime());
840 aValForTime->myId = iTimeStamp;
841 aValForTime->myFieldName = aField->myName;
842 aValForTime->myEntity = aField->myEntity;
843 aValForTime->myMeshName = aField->myMeshName;
844 aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
845 INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
847 VISU::TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
848 const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss;
849 MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
850 for(; anIter != aMGeom2NbGauss.end(); anIter++){
851 const MED::EGeometrieElement& aMGeom = anIter->first;
852 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
853 TInt aNbGauss = anIter->second;
854 aVGeom2NbGauss[aEGeom] = aNbGauss;
861 //---------------------------------------------------------------
863 BuildFamilyMap(VISU::PMEDMesh theMesh,
864 const MED::TEntityInfo& theEntityInfo,
865 const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
866 const MED::TFamilyInfoSet& theFamilyInfoSet,
867 MED::PWrapper theMEDWrapper)
869 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
870 INITMSG(MYDEBUG,"BuildFamilyMap\n");
872 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
873 MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
874 MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
875 for(; aEntity2FamilySetIter != aEntity2FamilySet.end(); aEntity2FamilySetIter++){
876 const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
877 const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
879 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
880 VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
881 const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
882 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
884 if(aFamilyTSizeSet.empty())
887 INITMSG(MY_FAMILY_DEBUG,
888 "- aMEntity = "<<aMEntity<<
889 "; aVEntity = "<<aVEntity<<
892 MED::TFamilyTSizeSet::const_iterator aFamilyTSizeSetIter = aFamilyTSizeSet.begin();
893 for(; aFamilyTSizeSetIter != aFamilyTSizeSet.end(); aFamilyTSizeSetIter++){
894 const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
895 const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
896 TInt aSize = boost::get<1>(aFamilyTSize);
897 TInt anId = aFamilyInfo->GetId();
901 std::string aFamilyName = aFamilyInfo->GetName();
903 VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily());
904 aFamily->myId = anId;
905 aFamily->myEntity = aVEntity;
906 aFamily->myName = aFamilyName;
907 aFamily->myNbCells = aSize;
909 aFamily->myCellsSize = 0;
910 VISU::TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
911 if(anIter != aFamilyID2CellsSize.end())
912 aFamily->myCellsSize = anIter->second;
914 INITMSG(MY_FAMILY_DEBUG,
915 "- aFamilyName = '"<<aFamilyName<<"'"<<
916 "; myId = "<<aFamily->myId<<"; "<<
917 "; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
918 "; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
919 "; aVEntity = "<<aVEntity<<
920 "; myNbCells = "<<aFamily->myNbCells<<
921 "; myCellsSize = "<<aFamily->myCellsSize<<
924 const TInt aNbGroup = aFamilyInfo->GetNbGroup();
925 for(TInt i = 0; i < aNbGroup; i++){
926 std::string aGroupName = aFamilyInfo->GetGroupName(i);
927 INITMSG(MY_FAMILY_DEBUG,"- aGroupName = '"<<aGroupName<<"'\n");
937 * Build grille family map
940 BuildGrilleFamilyMap(VISU::PMEDMesh theMesh,
941 const MED::TEntityInfo& theEntityInfo,
942 const MED::TFamilyInfoSet& theFamilyInfoSet,
943 MED::PWrapper theMEDWrapper)
945 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap");
946 INITMSG(MYDEBUG,"BuildGrilleFamilyMap\n");
948 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
950 MED::TEntityInfo::const_iterator aEntityIter = theEntityInfo.begin();
952 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
953 MED::PGrilleInfo aGrilleInfo = theMEDWrapper->GetPGrilleInfo(aMeshInfo);
955 const MED::TFamilyID2NbCells& aFam2NbCells = MED::GetFamilyID2NbCells(aGrilleInfo);
957 MED::TFamilyInfoSet::const_iterator aFamInter = theFamilyInfoSet.begin();
958 for(; aFamInter != theFamilyInfoSet.end(); aFamInter++){
959 const MED::PFamilyInfo& aFamilyInfo = *aFamInter;
960 TInt anId = aFamilyInfo->GetId();
965 std::string aFamilyName = aFamilyInfo->GetName();
966 const MED::EEntiteMaillage& aMEntity = MED::GetEntityByFamilyId(aGrilleInfo,
968 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
970 VISU::PMEDMeshOnEntity aMeshOnEntity;
971 VISU::TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity);
972 if(aMeshOnEntityIter != aMeshOnEntityMap.end())
973 aMeshOnEntity = aMeshOnEntityIter->second;
975 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
977 VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily());
978 aFamily->myId = anId;
979 aFamily->myEntity = aVEntity;
980 aFamily->myName = aFamilyName;
981 aFamily->myNbCells = 0;
982 aFamily->myCellsSize = 0;
984 const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
985 VISU::TFamilyID2CellsSize::const_iterator aFamilyid2CellsSizeIter = aFamilyID2CellsSize.find(anId);
986 if(aFamilyid2CellsSizeIter != (aMeshOnEntity->myFamilyID2CellsSize).end())
987 aFamily->myCellsSize = aFamilyid2CellsSizeIter->second;
988 MED::TFamilyID2NbCells::const_iterator aFam2NbCellsIter = aFam2NbCells.find(anId);
989 if(aFam2NbCellsIter != aFam2NbCells.end())
990 aFamily->myNbCells = aFam2NbCellsIter->second;
992 INITMSG(MY_FAMILY_DEBUG,
993 "- aFamilyName =|"<<aFamily->myName<<"|"
994 << "; myId = "<<aFamily->myId
995 << "; aNbAttr = "<<aFamilyInfo->GetNbAttr()
996 << "; aNbGroup = "<<aFamilyInfo->GetNbGroup()
997 << "; aVEntity = "<<aVEntity
998 << "; myNbCells = "<<aFamily->myNbCells
999 << "; myCellsSize = "<<aFamily->myCellsSize
1006 //---------------------------------------------------------------
1008 BuildGroupMap(VISU::PMEDMesh theMesh,
1009 const MED::TFamilyInfoSet& theFamilyInfoSet)
1011 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
1012 INITMSG(MYDEBUG,"BuildGroupMap\n");
1014 VISU::TGroupMap& aGroupMap = theMesh->myGroupMap;
1015 MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
1016 MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
1017 for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
1018 const std::string& aGroupName = aGroupInfoIter->first;
1019 INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
1021 VISU::PMEDGroup aGroup(new VISU::TMEDGroup());
1022 VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
1024 const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
1025 MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
1026 for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
1027 const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
1028 std::string aFamilyName = aFamilyInfo->GetName();
1030 VISU::TEntity aVEntity = VISU::TEntity(-1);
1031 VISU::PMEDFamily aFamily;
1034 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
1035 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
1036 for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
1037 const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
1038 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1039 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1040 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1041 const std::string& aName = aFamilyMapIter->first;
1042 if(aName == aFamilyName){
1043 aFamily = aFamilyMapIter->second;
1044 aVEntity = aFamily->myEntity;
1050 if(aFamily && aVEntity >= 0){
1051 aFamilySet.insert(aFamily);
1052 INITMSG(MY_GROUP_DEBUG,
1053 "- aFamilyName = '"<<aFamilyName<<"'"<<
1054 "; aVEntity = "<<aVEntity<<
1058 if(!aFamilySet.empty())
1059 aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
1064 //---------------------------------------------------------------
1068 TSetIsDone(bool& theIsDone):
1080 //---------------------------------------------------------------
1085 //---------------------------------------------------------------
1087 TMEDNamedPointCoords
1088 ::Init(const MED::PNodeInfo& theNodeInfo,
1089 MED::EVersion theVersion)
1091 TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
1092 TInt aNbElem = theNodeInfo->GetNbElem();
1093 TInt aDim = theNodeInfo->GetMeshInfo()->GetDim();
1094 aCoordHolder->Init(aNbElem, aDim, theNodeInfo->myCoord);
1095 TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
1096 myVersion = theVersion;
1098 for(TInt iDim = 0; iDim < aDim; iDim++)
1099 myPointsDim[iDim] = theNodeInfo->GetCoordName(iDim);
1101 myIsElemNum = theNodeInfo->IsElemNum();
1102 if(theNodeInfo->IsElemNum())
1103 myElemNum = theNodeInfo->myElemNum;
1105 myIsElemNames = theNodeInfo->IsElemNames();
1106 if(theNodeInfo->IsElemNames())
1107 myElemNames = theNodeInfo->myElemNames;
1111 TMEDNamedPointCoords
1112 ::Init(const MED::PGrilleInfo& theGrilleInfo)
1114 TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
1115 TInt aNbElem = theGrilleInfo->GetNbNodes();
1116 TInt aDim = theGrilleInfo->GetMeshInfo()->GetDim();
1117 MED::PNodeCoord aCoord(new MED::TNodeCoord(aNbElem * aDim));
1118 aCoordHolder->Init(aNbElem, aDim, aCoord);
1119 TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
1121 for(TInt iDim = 0; iDim < aDim; iDim++)
1122 myPointsDim[iDim] = theGrilleInfo->GetCoordName(iDim);
1124 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1125 VISU::TCoordSlice aVCoordSlice = GetCoordSlice(iElem);
1126 MED::TNodeCoord aMCoord = theGrilleInfo->GetCoord(iElem);
1127 for(TInt iDim = 0; iDim < aDim; iDim++){
1128 aVCoordSlice[iDim] = aMCoord[iDim];
1134 TMEDNamedPointCoords
1135 ::GetObjID(vtkIdType theID) const
1138 return (*myElemNum)[theID];
1139 return TNamedPointCoords::GetObjID(theID);
1144 TMEDNamedPointCoords
1145 ::GetVTKID(vtkIdType theID) const
1148 // To prepare corresponding mapper engine
1149 if(myObj2VTKID.empty()){
1150 vtkIdType anEnd = myElemNum->size();
1151 for(vtkIdType anID = 0; anID < anEnd; anID++)
1152 myObj2VTKID[(*myElemNum)[anID]] = anID;
1154 TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
1155 if(anIter != myObj2VTKID.end())
1156 return anIter->second;
1159 return TNamedPointCoords::GetVTKID(theID);
1163 GetPNOMLength(MED::EVersion theVersion)
1165 if(theVersion == MED::eV2_1)
1166 return MED::GetPNOMLength<MED::eV2_1>();
1167 return MED::GetPNOMLength<MED::eV2_2>();
1171 TMEDNamedPointCoords
1172 ::GetNodeName(vtkIdType theObjID) const
1175 return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
1176 return TNamedPointCoords::GetNodeName(theObjID);
1180 TMEDNamedPointCoords
1183 size_t aSize = TNamedPointCoords::GetMemorySize();
1186 aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2;
1187 aSize += myElemNum->size() * sizeof(MED::TInt);
1191 aSize += myElemNames->size() * sizeof(char);
1196 //---------------------------------------------------------------
1199 ::GetElemObjID(vtkIdType theID) const
1201 if ( !mySubMeshID.empty() )
1202 theID = mySubMeshID[theID];
1205 return (*myElemNum)[theID];
1210 //---------------------------------------------------------------
1213 ::GetElemVTKID(vtkIdType theID) const
1216 for ( size_t anId = 0; anId < (*myElemNum).size(); anId++ )
1217 if ( (*myElemNum)[ anId ] == theID ) {
1222 return TSubProfileImpl::GetElemVTKID( theID );
1225 //----------------------------------------------------------------
1231 size_t aSize = TSubProfileImpl::GetMemorySize();
1233 aSize += myElemNum->size() * sizeof(MED::TInt);
1238 //---------------------------------------------------------------
1241 ::LessThan(const PGaussImpl& theGauss,
1242 bool& theResult) const
1244 TGaussImpl::LessThan(theGauss,theResult);
1246 if(PMEDGauss aGauss = theGauss){
1247 const MED::TGaussInfo& aLeft = myGaussInfo;
1248 const MED::TGaussInfo& aReight = aGauss->myGaussInfo;
1249 theResult = MED::TGaussInfo::TLess()(aLeft,aReight);
1255 //---------------------------------------------------------------
1258 ::GetObjID(vtkIdType theID) const
1260 vtkIdType aNbPoints = myGauss->myNbPoints;
1261 TCellID aCellID = theID / aNbPoints;
1262 TLocalPntID aLocalPntID = theID % aNbPoints;
1265 aCellID = GetElemObjID(aCellID);
1267 aCellID += myStartID;
1269 return TGaussPointID(aCellID, aLocalPntID);
1272 //---------------------------------------------------------------
1275 ::GetVTKID(const TGaussPointID& theID,
1276 vtkIdType theStartID) const
1278 vtkIdType aResult = -1;
1280 TCellID aCellID = theID.first;
1281 TLocalPntID aLocalPntID = theID.second;
1283 vtkIdType aNbPoints = myGauss->myNbPoints;
1284 if ( aLocalPntID >= aNbPoints )
1287 if ( myIsElemNum ) {
1288 aCellID = GetElemVTKID( aCellID );
1290 aCellID -= theStartID;
1292 return aCellID * aNbPoints + aLocalPntID + theStartID;
1296 //---------------------------------------------------------------
1302 size_t aSize = TGaussSubMeshImpl::GetMemorySize();
1304 aSize += myElemNum->size() * sizeof(MED::TInt);
1309 //---------------------------------------------------------------
1312 ::Init(const MED::PElemInfo& theElemInfo,
1313 MED::EVersion theVersion)
1315 myIsElemNum = theElemInfo->IsElemNum();
1317 myElemNum = theElemInfo->myElemNum;
1319 myIsElemNames = theElemInfo->IsElemNames();
1320 if(theElemInfo->IsElemNames())
1321 myElemNames = theElemInfo->myElemNames;
1327 ::Init(const MED::PGrilleInfo& theGrilleInfo)
1332 ::GetElemObjID(vtkIdType theID) const
1335 return (*myElemNum)[theID];
1337 return TSubMeshImpl::GetElemObjID(theID);
1342 ::GetElemName(vtkIdType theObjID) const
1345 return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
1346 return TSubMeshImpl::GetElemName(theObjID);
1353 size_t aSize = TSubMeshImpl::GetMemorySize();
1356 aSize += myElemNum->size() * sizeof(MED::TInt);
1359 aSize += myElemNames->size() * sizeof(char);
1365 //---------------------------------------------------------------
1369 //---------------------------------------------------------------
1372 CreateConvertor(const std::string& theFileName)
1374 if(MED::PWrapper aMed = MED::CrWrapper(theFileName,true))
1375 return new VISU_MedConvertor(theFileName, aMed);
1380 ::VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed):
1381 myIsEntitiesDone(false),
1382 myIsFieldsDone(false),
1383 myIsGroupsDone(false),
1384 myIsMinMaxDone(false),
1387 myName = theFileName;
1391 //---------------------------------------------------------------
1396 if(myIsEntitiesDone)
1399 TSetIsDone aSetIsDone(myIsEntitiesDone);
1400 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
1402 TInt aNbMeshes = myMed->GetNbMeshes();
1403 VISU::TMeshMap& aMeshMap = myMeshMap;
1405 INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
1407 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1411 VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1413 MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1414 std::string aMeshName = aMeshInfo->GetName();
1415 TInt aDim = aMeshInfo->GetDim();
1416 MED::EMaillage aType = aMeshInfo->GetType();
1418 // creating TMesh structure and TMeshOnEntityMap
1419 VISU::PMEDMesh aMesh = aMeshMap[aMeshName](new VISU::TMEDMesh());
1421 aMesh->myDim = aDim;
1422 aMesh->myName = aMeshName;
1423 aMesh->myMeshInfo = aMeshInfo;
1424 aMesh->myNamedPointCoords(new VISU::TMEDNamedPointCoords());
1426 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
1427 "; aDim = "<<aDim<<"\n");
1429 if(aType == MED::eNON_STRUCTURE){
1431 if(MED::PNodeInfo aNodeInfo = myMed->GetPNodeInfo(aMeshInfo)){
1432 MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1434 aMesh->myNbPoints = aNodeInfo->GetNbElem();
1435 aMesh->myEntityInfo = anEntityInfo;
1441 INITMSG(MYDEBUG,"myNbPoints = "<<aMesh->myNbPoints<<
1442 "; anEntityInfo.size() = "<<anEntityInfo.size()<<
1445 BuildMeshOnEntityMap(aMesh,
1451 }catch(std::exception& exc){
1452 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1454 MSG(MYDEBUG,"Unknown exception !!!");
1458 } // NON STRUCTURED MESH
1460 MED::PGrilleInfo aGrilleInfo = myMed->GetPGrilleInfo(aMeshInfo);
1462 MED::TEntityInfo anEntityInfo;
1463 anEntityInfo[MED::eNOEUD][MED::ePOINT1] = aGrilleInfo->GetNbNodes();
1464 anEntityInfo[aGrilleInfo->GetEntity()][aGrilleInfo->GetGeom()] = aGrilleInfo->GetNbCells();
1466 aMesh->myNbPoints = aGrilleInfo->GetNbNodes();
1467 aMesh->myEntityInfo = anEntityInfo;
1468 //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
1469 aMesh->myIsStructured = true;
1470 aMesh->myType = (MED::eGRILLE_POLAIRE == aGrilleInfo->GetGrilleType());
1475 BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
1477 BuildMeshGrilleOnEntityMap(aMesh,
1483 }catch(std::exception& exc){
1484 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1486 MSG(MYDEBUG,"Unknown exception !!!");
1493 }catch(std::exception& exc){
1494 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1496 MSG(MYDEBUG,"Unknown exception !!!");
1505 //---------------------------------------------------------------
1513 VISU_Convertor_impl::BuildFields();
1515 TSetIsDone aSetIsDone(myIsFieldsDone);
1516 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFields");
1518 TInt aNbMeshes = myMed->GetNbMeshes();
1519 VISU::TMeshMap& aMeshMap = myMeshMap;
1521 INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
1523 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1527 VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1529 MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1530 std::string aMeshName = aMeshInfo->GetName();
1532 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1533 if(anIter == aMeshMap.end())
1535 VISU::PMEDMesh aMesh = anIter->second;
1537 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1541 MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1543 BuildFieldMap(aMesh,
1547 }catch(std::exception& exc){
1548 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1550 MSG(MYDEBUG,"Unknown exception !!!");
1555 }catch(std::exception& exc){
1556 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1558 MSG(MYDEBUG,"Unknown exception !!!");
1567 //---------------------------------------------------------------
1568 template<class TimeStampValueType>
1570 BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
1571 const MED::TGeom2Gauss& theGeom2Gauss,
1572 VISU::TMinMaxArr& theMinMaxArr,
1576 const typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
1577 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
1578 for(; anIter != aGeom2Value.end(); anIter++){
1579 const typename TimeStampValueType::TTMeshValue& aMMeshValue = anIter->second;
1580 MED::EGeometrieElement aMGeom = anIter->first;
1582 TInt aNbElem = aMMeshValue.myNbElem;
1583 TInt aNbGauss = aMMeshValue.myNbGauss;
1585 MED::TGeom2Gauss::const_iterator aGaussIter = theGeom2Gauss.find(aMGeom);
1586 if(aGaussIter == theGeom2Gauss.end())
1590 "- aMGeom = "<<aMGeom<<
1591 "; aNbElem = "<<aNbElem<<
1592 "; aNbGauss = "<<aNbGauss<<
1595 // To calculate min/max per components
1596 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1597 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
1598 for(TInt iComp = 0; iComp < theNbComp; iComp++){
1599 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
1600 VISU::TMinMax& aMinMax = theMinMaxArr[iComp+1];
1601 vtkFloatingPointType& aMin = aMinMax.first;
1602 vtkFloatingPointType& aMax = aMinMax.second;
1603 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1604 const vtkFloatingPointType& aVal = aMValueSlice[iGauss];
1605 aMin = min(aMin,aVal);
1606 aMax = max(aMax,aVal);
1611 // To calculate min/max per vector modulus
1612 VISU::TMinMax& aMinMax = theMinMaxArr[0];
1613 vtkFloatingPointType& aMin = aMinMax.first;
1614 vtkFloatingPointType& aMax = aMinMax.second;
1615 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1616 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
1617 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1618 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
1619 vtkFloatingPointType aValue = 0.0;
1620 for(TInt iComp = 0; iComp < theNbComp2; iComp++){
1621 vtkFloatingPointType aVal = aMValueSlice[iComp];
1622 aValue += aVal*aVal;
1624 aValue = sqrt(aValue);
1625 aMin = min(aMin,aValue);
1626 aMax = max(aMax,aValue);
1633 //---------------------------------------------------------------
1641 VISU_Convertor_impl::BuildMinMax();
1643 TSetIsDone aSetIsDone(myIsMinMaxDone);
1644 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
1646 MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(myMed);
1647 MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(myMed);
1649 TInt aNbMeshes = myMed->GetNbMeshes();
1650 VISU::TMeshMap& aMeshMap = myMeshMap;
1652 INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
1654 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1658 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
1660 MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1661 std::string aMeshName = aMeshInfo->GetName();
1663 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1664 if(anIter == aMeshMap.end())
1666 VISU::PMEDMesh aMesh = anIter->second;
1671 TInt aNbFields = myMed->GetNbFields();
1674 "- aMeshName = '"<<aMeshName<<"'"<<
1675 "; aNbFields = "<<aNbFields<<"\n");
1677 MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1679 for(TInt iField = 1; iField <= aNbFields; iField++){
1680 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
1682 MED::TErr anError = 0;
1683 MED::PFieldInfo aFieldInfo = myMed->GetPFieldInfo(aMeshInfo, iField, &anError);
1687 std::string aFieldName = aFieldInfo->GetName();
1688 INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
1690 MED::TGeom2Size aGeom2Size;
1691 MED::EEntiteMaillage aMEntity;
1692 TInt aNbTimeStamps = myMed->GetNbTimeStamps(aFieldInfo,
1696 if(aNbTimeStamps < 1)
1699 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
1700 VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
1701 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1702 VISU::PMEDField aField = aFieldMap[aFieldName];
1704 TInt aNbComp = aField->myNbComp;
1705 int aNbComp2 = aNbComp;
1706 if(aNbComp == 2 || aNbComp == 4)
1708 else if(aNbComp > 4)
1711 VISU::TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
1712 TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
1713 for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
1714 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
1715 INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
1723 MED::PTimeStampInfo aTimeStampInfo =
1724 myMed->GetPTimeStampInfo(aFieldInfo,
1729 MED::PTimeStampValueBase aTimeStampValue =
1730 myMed->GetPTimeStampValue(aTimeStampInfo,
1734 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
1736 if(aFieldInfo->GetType() == MED::eFLOAT64)
1737 BuildTimeStampMinMax<MED::TFloatTimeStampValue>(CastToFloatTimeStampValue(aTimeStampValue),
1743 BuildTimeStampMinMax<MED::TIntTimeStampValue>(CastToIntTimeStampValue(aTimeStampValue),
1750 }catch(Standard_Failure){
1751 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1752 MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
1753 }catch(std::exception& exc){
1754 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1756 MSG(MYDEBUG,"Unknown exception !!!");
1760 for(TInt iComp = 0; iComp <= aNbComp; iComp++){
1761 VISU::TMinMax aMinMax = aField->GetMinMax(iComp);
1762 INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
1766 }catch(std::exception& exc){
1767 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1769 MSG(MYDEBUG,"Unknown exception !!!");
1774 }catch(std::exception& exc){
1775 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1777 MSG(MYDEBUG,"Unknown exception !!!");
1786 //---------------------------------------------------------------
1794 TSetIsDone aSetIsDone(myIsGroupsDone);
1795 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
1797 TInt aNbMeshes = myMed->GetNbMeshes();
1798 VISU::TMeshMap& aMeshMap = myMeshMap;
1800 INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
1802 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1806 VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1808 MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
1809 std::string aMeshName = aMeshInfo->GetName();
1811 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1812 if(anIter == aMeshMap.end())
1814 VISU::PMEDMesh aMesh = anIter->second;
1816 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1818 MED::EMaillage aType = aMeshInfo->GetType();
1820 MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
1822 MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
1823 MED::GetEntity2TGeom2ElemInfo(myMed, aMeshInfo, anEntityInfo);
1828 MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(myMed, aMeshInfo);
1830 if(aType == MED::eNON_STRUCTURE)
1831 BuildFamilyMap(aMesh,
1833 anEntity2TGeom2ElemInfo,
1837 BuildGrilleFamilyMap(aMesh,
1842 BuildGroupMap(aMesh,
1845 }catch(std::exception& exc){
1846 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1848 MSG(MYDEBUG,"Unknown exception !!!");
1853 }catch(std::exception& exc){
1854 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1856 MSG(MYDEBUG,"Unknown exception !!!");
1865 //---------------------------------------------------------------
1868 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
1869 VISU::PMeshOnEntityImpl theMeshOnEntity)
1871 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
1872 INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
1874 const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
1876 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1877 if(anEntity == VISU::NODE_ENTITY){
1878 isPointsUpdated += LoadPoints(myMed, theMesh);
1880 isPointsUpdated += LoadPoints(myMed, theMesh);
1881 isCellsOnEntityUpdated += LoadCellsOnEntity(myMed, theMesh, theMeshOnEntity);
1884 return (isPointsUpdated || isCellsOnEntityUpdated);
1888 //---------------------------------------------------------------
1891 ::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
1892 VISU::PMeshOnEntityImpl theMeshOnEntity,
1893 VISU::PFamilyImpl theFamily)
1895 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
1896 INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
1898 const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
1900 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1901 if(anEntity == VISU::NODE_ENTITY){
1902 isPointsUpdated += LoadPointsOnFamily(myMed, theMesh, theFamily);
1904 isPointsUpdated += LoadPoints(myMed, theMesh);
1905 isCellsOnEntityUpdated += LoadCellsOnFamily(myMed, theMesh, theMeshOnEntity, theFamily);
1908 return (isPointsUpdated || isCellsOnEntityUpdated);
1912 //---------------------------------------------------------------
1915 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
1916 const VISU::TFamilySet& theFamilySet)
1918 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
1919 INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
1921 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1922 VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
1923 for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
1924 VISU::PMEDFamily aFamily = *aFamilyIter;
1925 const VISU::TEntity& anEntity = aFamily->myEntity;
1926 const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
1927 isPointsUpdated += LoadPoints(myMed, theMesh);
1928 if(anEntity == VISU::NODE_ENTITY){
1929 isPointsUpdated += LoadPointsOnFamily(myMed, theMesh, aFamily);
1931 isCellsOnEntityUpdated += LoadCellsOnFamily(myMed,theMesh,aMeshOnEntity,aFamily);
1935 return (isPointsUpdated || isCellsOnEntityUpdated);
1939 //---------------------------------------------------------------
1942 ::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
1943 VISU::PMeshOnEntityImpl theMeshOnEntity,
1944 VISU::PFieldImpl theField,
1945 VISU::PValForTimeImpl theValForTime)
1947 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
1948 INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
1950 const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
1951 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1952 isPointsUpdated += LoadPoints(myMed,theMesh);
1953 if(anEntity != VISU::NODE_ENTITY)
1954 isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity);
1955 int isFieldUpdated = LoadValForTimeOnMesh(myMed,theMesh,theMeshOnEntity,theField,theValForTime);
1957 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
1961 //---------------------------------------------------------------
1964 ::LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
1965 VISU::PMeshOnEntityImpl theMeshOnEntity,
1966 VISU::PFieldImpl theField,
1967 VISU::PValForTimeImpl theValForTime)
1969 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
1970 INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
1972 const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
1973 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1974 if(anEntity != VISU::NODE_ENTITY)
1975 isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity);
1976 int isFieldUpdated = LoadValForTimeOnGaussPts(myMed,theMesh,theMeshOnEntity,theField,theValForTime);
1978 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
1982 //---------------------------------------------------------------
1985 ::LoadPoints(const MED::PWrapper& theMed,
1986 VISU::PMEDMesh theMesh)
1988 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
1990 //Check on existing family
1991 VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1992 aMeshOnEntity->myMeshName = theMesh->myName;
1993 aMeshOnEntity->myEntity = VISU::NODE_ENTITY;
1995 INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<<theMesh->myIsDone<<"'\n");
1997 //Check on loading already done
1998 if(theMesh->myIsDone)
2001 MED::EMaillage aType = theMesh->myMeshInfo->GetType();
2003 if(aType == MED::eNON_STRUCTURE){
2005 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
2006 TInt aNbElem = aNodeInfo->GetNbElem();
2008 VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
2009 aNamedPointCoords->Init(aNodeInfo, theMed->GetVersion());
2011 VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
2012 VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh());
2014 aSubMesh->Init(MED::PElemInfo(aNodeInfo), theMed->GetVersion());
2015 aSubMesh->myNbCells = theMesh->myNbPoints;
2016 aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
2018 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2019 aCell2Connect.resize(aNbElem);
2020 for (int iElem = 0; iElem < aNbElem; iElem++)
2021 aCell2Connect[iElem] = VISU::TConnect(1,iElem);
2022 } // END NON_STRUCTURED
2023 else { // STRUCTURED
2025 MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(theMesh->myMeshInfo);
2026 TInt aNbElem = aGrilleInfo->GetNbNodes();
2028 VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
2029 aNamedPointCoords->Init(aGrilleInfo);
2031 VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
2032 VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh());
2034 aSubMesh->Init(aGrilleInfo);
2035 aSubMesh->myNbCells = theMesh->myNbPoints;
2036 aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
2038 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2039 aCell2Connect.resize(aNbElem);
2040 for(int iElem = 0; iElem < aNbElem; iElem++)
2041 aCell2Connect[iElem] = VISU::TConnect(1,iElem);
2045 theMesh->myIsDone = true;
2049 }catch(std::exception& exc){
2052 EXCEPTION(runtime_error,"Unknown exception !!!");
2059 //---------------------------------------------------------------
2062 ::LoadPointsOnFamily(const MED::PWrapper& theMed,
2063 const VISU::PMEDMesh theMesh,
2064 const VISU::PMEDFamily theFamily)
2066 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
2068 if(theFamily->myIsDone)
2071 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2072 MED::EMaillage aType = aMeshInfo->GetType();
2075 if(aType == MED::eNON_STRUCTURE){
2076 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
2077 TInt aNbElem = aNodeInfo->GetNbElem();
2080 TInt anId = theFamily->myId;
2081 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
2082 for(TInt iElem = 0; iElem < aNbElem; iElem++)
2083 if(aNodeInfo->GetFamNum(iElem) == anId)
2084 aSubMeshID.push_back(iElem);
2088 MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(aMeshInfo);
2089 TInt aNbElem = aGrilleInfo->GetNbNodes();
2092 TInt anId = theFamily->myId;
2093 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
2094 for(TInt iElem = 0; iElem < aNbElem; iElem++)
2095 if(aGrilleInfo->GetFamNumNode(iElem) == anId)
2096 aSubMeshID.push_back(iElem);
2100 theFamily->myIsDone = true;
2104 }catch(std::exception& exc){
2107 EXCEPTION(runtime_error,"Unknown exception !!!");
2114 //---------------------------------------------------------------
2117 ::LoadCellsOnEntity(const MED::PWrapper& theMed,
2118 const VISU::PMEDMesh theMesh,
2119 const VISU::PMEDMeshOnEntity theMeshOnEntity)
2121 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
2125 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
2126 const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
2128 INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<<aVEntity<<"\n");
2130 if(theMeshOnEntity->myIsDone)
2133 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2135 MED::EMaillage aType = aMeshInfo->GetType();
2137 if(aType == MED::eSTRUCTURE){
2139 MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(aMeshInfo);
2140 TInt aNbPoints = aGrilleInfo->GetNbNodes();
2142 std::map<TInt,TInt> aNodeIdMap;
2143 EBooleen anIsNodeNum = MED::eFAUX;
2145 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
2146 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
2147 VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
2149 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
2150 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
2151 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2152 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
2154 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
2155 INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
2157 TInt aNbElem = aGeom2SizeIter->second;//aGrilleInfo->GetNbCells();
2160 VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2162 aSubMesh->Init(aGrilleInfo);
2163 aSubMesh->myNbCells = aNbElem;
2164 aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
2166 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2167 aCell2Connect.resize(aNbElem);
2169 TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
2170 VISU::TVector<TInt> aConnect(aMNbNodes);
2172 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
2173 MED::TIntVector aConn = aGrilleInfo->GetConn(iElem);
2174 VISU::TConnect& anArray = aCell2Connect[iElem];
2175 anArray.resize(aVNbNodes);
2178 for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
2179 aConnect[iConn] = aNodeIdMap[aConn[iConn] - 1];
2182 for(int iConn = 0; iConn < aMNbNodes; ++iConn){
2183 aConnect[iConn] = aConn[iConn];
2189 anArray[0] = aConnect[0];
2190 anArray[1] = aConnect[2];
2191 anArray[2] = aConnect[3];
2192 anArray[3] = aConnect[1];
2195 anArray[0] = aConnect[0];
2196 anArray[1] = aConnect[2];
2197 anArray[2] = aConnect[3];
2198 anArray[3] = aConnect[1];
2199 anArray[4] = aConnect[4];
2200 anArray[5] = aConnect[6];
2201 anArray[6] = aConnect[7];
2202 anArray[7] = aConnect[5];
2205 for(int iNode = 0; iNode < aVNbNodes; iNode++)
2206 anArray[iNode] = aConnect[iNode];
2209 for(int iNode = 0; iNode < aVNbNodes; iNode++)
2210 if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
2211 EXCEPTION(runtime_error,"LoadCellsOnEntity - "<<
2212 " aNbPoints("<<aNbPoints<<") "<<
2213 "<= anArray["<<iElem<<"]"<<
2215 "("<<anArray[iNode]<<") < 0");
2221 theMeshOnEntity->myIsDone = true;
2227 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
2228 TInt aNbPoints = aNodeInfo->GetNbElem();
2230 std::map<TInt,TInt> aNodeIdMap;
2231 #ifdef _EDF_NODE_IDS_
2232 EBooleen anIsNodeNum = MED::eFAUX;
2234 EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
2236 for(TInt i = 0; i < aNbPoints; i++){
2237 aNodeIdMap[aNodeInfo->GetElemNum(i)-1] = i;
2242 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
2243 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
2244 VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
2246 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
2247 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
2248 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2249 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
2251 case MED::ePOLYGONE: {
2252 MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
2253 TInt aNbElem = aPolygoneInfo->GetNbElem();
2255 VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2257 aSubMesh->Init(MED::PElemInfo(aPolygoneInfo),theMed->GetVersion());
2258 aSubMesh->myNbCells = aNbElem;
2260 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2261 aCell2Connect.resize(aNbElem);
2263 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
2264 MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
2265 TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
2266 aSubMesh->myCellsSize += aNbConn;
2267 VISU::TConnect& anArray = aCell2Connect[iElem];
2268 anArray.resize(aNbConn);
2269 for(TInt iConn = 0; iConn < aNbConn; iConn++)
2270 anArray[iConn] = aConnSlice[iConn] - 1;
2275 case MED::ePOLYEDRE: {
2276 MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
2277 TInt aNbElem = aPolyedreInfo->GetNbElem();
2280 VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2282 aSubMesh->Init(MED::PElemInfo(aPolyedreInfo),theMed->GetVersion());
2283 aSubMesh->myNbCells = aNbElem;
2285 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2286 aCell2Connect.resize(aNbElem);
2288 for(TInt iElem = 0; iElem < aNbElem; iElem++){
2289 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
2290 VISU::TConnect& anArray = aCell2Connect[iElem];
2291 typedef std::set<TInt> TConnectSet;
2292 TConnectSet aConnectSet;
2293 TInt aNbFaces = aConnSliceArr.size();
2294 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
2295 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
2296 TInt aNbConn = aConnSlice.size();
2297 aSubMesh->myCellsSize += aNbConn;
2298 for(TInt iConn = 0; iConn < aNbConn; iConn++){
2299 aConnectSet.insert(aConnSlice[iConn]);
2303 int aNbConn = aConnectSet.size();
2304 anArray.resize(aNbConn);
2305 TConnectSet::iterator anIter = aConnectSet.begin();
2306 for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){
2307 TInt anId = *anIter;
2308 anArray[i] = anId - 1;
2316 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
2317 INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
2319 MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
2320 TInt aNbElem = aCellInfo->GetNbElem();
2323 VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
2325 aSubMesh->Init(MED::PElemInfo(aCellInfo), theMed->GetVersion());
2326 aSubMesh->myNbCells = aNbElem;
2327 aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
2329 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
2330 aCell2Connect.resize(aNbElem);
2332 TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
2333 VISU::TVector<TInt> aConnect(aMNbNodes);
2335 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
2336 MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
2337 VISU::TConnect& anArray = aCell2Connect[iElem];
2338 anArray.resize(aVNbNodes);
2341 for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
2342 aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1];
2345 for(int iConn = 0; iConn < aMNbNodes; iConn++){
2346 aConnect[iConn] = aConnSlice[iConn] - 1;
2351 #if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2353 anArray[0] = aConnect[0];
2354 anArray[2] = aConnect[1];
2356 anArray[1] = aConnect[2];
2359 #if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2361 anArray[0] = aConnect[0];
2362 anArray[2] = aConnect[1];
2363 anArray[4] = aConnect[2];
2365 anArray[1] = aConnect[3];
2366 anArray[3] = aConnect[4];
2367 anArray[5] = aConnect[5];
2370 #if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2372 anArray[0] = aConnect[0];
2373 anArray[2] = aConnect[1];
2374 anArray[4] = aConnect[2];
2375 anArray[6] = aConnect[3];
2377 anArray[1] = aConnect[4];
2378 anArray[3] = aConnect[5];
2379 anArray[5] = aConnect[6];
2380 anArray[7] = aConnect[7];
2383 #if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2385 anArray[0] = aConnect[0];
2386 anArray[1] = aConnect[2];
2387 anArray[2] = aConnect[1];
2388 anArray[3] = aConnect[3];
2390 anArray[4] = aConnect[6];
2391 anArray[5] = aConnect[5];
2392 anArray[6] = aConnect[4];
2394 anArray[7] = aConnect[7];
2395 anArray[8] = aConnect[9];
2396 anArray[9] = aConnect[8];
2400 anArray[0] = aConnect[0];
2401 anArray[1] = aConnect[2];
2402 anArray[2] = aConnect[1];
2403 anArray[3] = aConnect[3];
2405 #if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
2407 anArray[0] = aConnect[0];
2408 anArray[1] = aConnect[3];
2409 anArray[2] = aConnect[2];
2410 anArray[3] = aConnect[1];
2411 anArray[4] = aConnect[4];
2413 anArray[5] = aConnect[5];
2414 anArray[6] = aConnect[8];
2415 anArray[7] = aConnect[7];
2416 anArray[8] = aConnect[6];
2418 anArray[9] = aConnect[9];
2419 anArray[10] = aConnect[12];
2420 anArray[11] = aConnect[11];
2421 anArray[12] = aConnect[10];
2425 anArray[0] = aConnect[0];
2426 anArray[1] = aConnect[3];
2427 anArray[2] = aConnect[2];
2428 anArray[3] = aConnect[1];
2429 anArray[4] = aConnect[4];
2432 for(int iNode = 0; iNode < aVNbNodes; iNode++)
2433 anArray[iNode] = aConnect[iNode];
2435 for(int iNode = 0; iNode < aVNbNodes; iNode++)
2436 if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
2437 EXCEPTION(runtime_error,"LoadCellsOnEntity - "<<
2438 " aNbPoints("<<aNbPoints<<") "<<
2439 "<= anArray["<<iElem<<"]"<<
2441 "("<<anArray[iNode]<<") < 0");
2447 // END NON_STRUCTURED
2449 theMeshOnEntity->myIsDone = true;
2454 }catch(std::exception& exc){
2457 EXCEPTION(runtime_error,"Unknown exception !!!");
2465 //---------------------------------------------------------------
2468 ::LoadCellsOnFamily(const MED::PWrapper& theMed,
2469 const VISU::PMEDMesh theMesh,
2470 const VISU::PMEDMeshOnEntity theMeshOnEntity,
2471 const VISU::PMEDFamily theFamily)
2473 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
2477 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
2478 const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
2480 INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<<aVEntity<<"\n");
2482 if(theFamily->myIsDone)
2485 TInt anId = theFamily->myId;
2487 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2488 VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
2489 MED::EMaillage aType = aMeshInfo->GetType();
2491 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
2492 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
2493 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
2494 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
2495 if(aType == MED::eNON_STRUCTURE){
2496 MED::PElemInfo anElemInfo;
2498 case MED::ePOLYGONE: {
2499 anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
2502 case MED::ePOLYEDRE: {
2503 anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
2507 anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
2511 if(TInt aNbElem = anElemInfo->GetNbElem()){
2512 VISU::TSubMeshID aSubMeshID;
2513 for(TInt iElem = 0; iElem < aNbElem; iElem++)
2514 if(anElemInfo->GetFamNum(iElem) == anId)
2515 aSubMeshID.push_back(iElem);
2516 if(!aSubMeshID.empty()){
2517 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2518 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
2519 aGeom2SubMeshID.insert(VISU::TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
2524 MED::PGrilleInfo anElemInfo = theMed->GetPGrilleInfo(aMeshInfo);
2526 TInt aNbElem = anElemInfo->GetNbCells();
2527 if(aNbElem>0 && (aMGeom == anElemInfo->GetGeom()) ){
2528 VISU::TSubMeshID aSubMeshID;
2529 for(TInt iElem = 0; iElem < aNbElem; iElem++)
2530 if(anElemInfo->GetFamNum(iElem) == anId)
2531 aSubMeshID.push_back(iElem);
2532 if(!aSubMeshID.empty()){
2533 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2534 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
2535 aGeom2SubMeshID.insert(VISU::TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
2542 theFamily->myIsDone = true;
2547 }catch(std::exception& exc){
2550 EXCEPTION(runtime_error,"Unknown exception !!!");
2558 //---------------------------------------------------------------
2560 LoadProfile(const MED::PWrapper& theMed,
2561 VISU::PMEDMesh theMesh,
2562 MED::PTimeStampValueBase theTimeStampValue,
2563 VISU::TMEDValForTime& theValForTime,
2564 VISU::TMEDMeshOnEntity& theMeshOnEntity)
2566 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
2567 INITMSG(MYDEBUG,"LoadProfile"<<endl);
2569 VISU::PMEDProfile aProfile = theValForTime.myProfile;
2570 if(aProfile->myIsDone)
2573 const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2574 const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile();
2575 MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin();
2576 for(; anIter != aGeom2Profile.end(); anIter++){
2577 MED::PProfileInfo aProfileInfo = anIter->second;
2578 MED::EGeometrieElement aMGeom = anIter->first;
2579 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
2581 VISU::TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
2582 if(anIter2 != aGeom2SubProfile.end()){
2583 VISU::PMEDSubProfile aSubProfile = anIter2->second;
2585 MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2586 if(!anElemNum.empty()){
2587 VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
2588 TInt aSize = anElemNum.size();
2589 aSubMeshID.resize(aSize);
2590 for(TInt anId = 0; anId < aSize; anId++)
2591 aSubMeshID[anId] = anElemNum[anId] - 1;
2595 "- aEGeom = "<<aEGeom<<
2596 "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
2601 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2603 VISU::TEntity aVEntity = theMeshOnEntity.myEntity;
2604 MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
2606 const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2607 VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
2608 for(; anIter != aGeom2SubProfile.end(); anIter++){
2609 const VISU::PMEDSubProfile& aSubProfile = anIter->second;
2610 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2611 MED::PElemInfo anElemInfo;
2612 anElemInfo = theMed->GetPElemInfo(aMeshInfo,aMEntity,aMGeom);
2613 aSubProfile->myIsElemNum = anElemInfo->IsElemNum();
2614 aSubProfile->myElemNum = anElemInfo->myElemNum;
2618 aProfile->myIsDone = true;
2622 //---------------------------------------------------------------
2624 LoadGaussMesh(const MED::PWrapper& theMed,
2625 VISU::PMEDMesh theMesh,
2626 MED::PTimeStampValueBase theTimeStampValue,
2627 VISU::TMEDValForTime& theValForTime,
2628 VISU::TMEDMeshOnEntity& theMeshOnEntity)
2630 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
2631 INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
2633 // this part of code must be reimplemented in connection with GRILLE structures
2634 if(theMesh->myMeshInfo->GetType() == MED::eSTRUCTURE)
2635 EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
2637 VISU::PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
2638 if(!aGaussMesh || aGaussMesh->myIsDone)
2641 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2642 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
2644 VISU::TEntity aVEntity = theMeshOnEntity.myEntity;
2645 MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
2647 const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
2648 const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo();
2649 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
2651 VISU::TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
2652 for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){
2653 VISU::PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
2654 VISU::EGeometry aEGeom = aSubMeshIter->first;
2656 if(aGaussSubMesh->myIsDone)
2659 VISU::PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
2660 const VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
2661 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2663 MED::PPolygoneInfo aPolygoneInfo;
2664 MED::PPolyedreInfo aPolyedreInfo;
2665 MED::PCellInfo aCellInfo;
2666 MED::PElemInfo anElemInfo;
2669 case MED::ePOLYGONE:
2670 aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,
2673 anElemInfo = aPolygoneInfo;
2675 case MED::ePOLYEDRE:
2676 aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,
2679 anElemInfo = aPolyedreInfo;
2682 aCellInfo = theMed->GetPCellInfo(aMeshInfo,
2685 anElemInfo = aCellInfo;
2687 aGaussSubMesh->myIsElemNum = anElemInfo->IsElemNum();
2688 aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
2691 bool anIsGaussCoord3D = false;
2692 MED::PGaussCoord aGaussCoordPtr(new MED::TGaussCoord());
2693 MED::TGaussCoord& aGaussCoord = *aGaussCoordPtr;
2695 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
2696 if(aGaussIter != aGeom2Gauss.end()){
2697 VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss;
2698 MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo;
2700 aName = aGaussInfo->GetName();
2701 if(!aSubMeshID.empty()){
2702 const std::string& aProfileName = aSubProfile->myName;
2703 MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2706 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2707 anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2714 anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2720 if(!aSubMeshID.empty()){
2721 const std::string& aProfileName = aSubProfile->myName;
2722 MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2725 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2727 case MED::ePOLYGONE:
2728 anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2733 case MED::ePOLYEDRE:
2734 anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2740 anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2748 case MED::ePOLYGONE:
2749 anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2753 case MED::ePOLYEDRE:
2754 anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2759 anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2765 if(anIsGaussCoord3D){
2766 VISU::TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
2767 VISU::TMEDGaussCoordHolder* aCoordHolder = new VISU::TMEDGaussCoordHolder();
2768 aCoordHolder->Init(aGaussCoordPtr);
2769 aCoords.Init(VISU::PCoordHolder(aCoordHolder));
2771 aGaussSubMesh->myIsDone = true;
2773 TInt aNbGauss = aGaussCoord.GetNbGauss();
2774 TInt aNbElem = aGaussCoord.GetNbElem();
2775 TInt aNbCells = aNbElem*aNbGauss;
2778 "- aEGeom = "<<aEGeom<<
2779 "; aName = '"<<aName<<"'"<<
2780 "; aStatus = "<<aGaussSubMesh->myStatus<<
2781 "; aNbElem = "<<aNbElem<<
2782 "; aNbGauss = "<<aNbGauss<<
2783 "; aNbCells = "<<aNbCells<<
2786 EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
2789 aGaussMesh->myIsDone = true;
2793 //---------------------------------------------------------------
2794 template<class TimeStampValueType>
2796 FillValForTime(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
2797 const VISU::TGeom2SubProfile& theGeom2SubProfile,
2798 VISU::PMEDValForTime theValForTime,
2799 VISU::PMEDField theField)
2801 theField->myDataSize = 0;
2802 TInt aNbComp = theField->myNbComp;
2804 VISU::TGeom2SubProfile::const_iterator anIter = theGeom2SubProfile.begin();
2805 for(; anIter != theGeom2SubProfile.end(); anIter++){
2806 VISU::EGeometry aEGeom = anIter->first;
2807 VISU::PMEDSubProfile aSubProfile(anIter->second);
2809 TInt aNbElem = aSubProfile->myNbCells;
2810 theField->myDataSize += aNbElem * aNbComp;
2812 if(aSubProfile->myStatus != VISU::eRemoveAll){
2813 TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
2816 "- aEGeom = "<<aEGeom<<
2817 "; aNbElem = "<<aNbElem<<
2818 "; aNbGauss = "<<aNbGauss<<
2821 VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
2822 typedef typename TimeStampValueType::TElement TElement;
2823 typedef VISU::TTMEDMeshValue<TElement> TVMeshValue;
2824 TVMeshValue* aMeshValue = new TVMeshValue();
2826 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2827 typedef typename TimeStampValueType::PTMeshValue PTMeshValue;
2828 PTMeshValue aMeshValuePtr = theTimeStampValue->GetMeshValuePtr(aMGeom);
2829 aMeshValue->Init(aNbElem, aNbGauss, aNbComp, aMeshValuePtr);
2830 aVMeshValue.reset(aMeshValue);
2835 //---------------------------------------------------------------
2837 LoadValForTime(const MED::PWrapper& theMed,
2838 VISU::PMEDMesh theMesh,
2839 VISU::PMEDMeshOnEntity theMeshOnEntity,
2840 VISU::PMEDField theField,
2841 VISU::PMEDValForTime theValForTime,
2845 VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
2846 INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
2848 //Check on loading already done
2853 const std::string& aMeshName = theMeshOnEntity->myMeshName;
2854 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2855 MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,
2858 MED::TGeom2Size aGeom2Size;
2859 MED::EEntiteMaillage aMEntity;
2860 theMed->GetNbTimeStamps(aFieldInfo,
2861 theMesh->myEntityInfo,
2865 MED::PTimeStampInfo aTimeStampInfo =
2866 theMed->GetPTimeStampInfo(aFieldInfo,
2869 theValForTime->myId);
2871 MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
2872 MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
2874 MED::PTimeStampValueBase aTimeStampValue =
2875 theMed->GetPTimeStampValue(aTimeStampInfo,
2879 InitGaussProfile(theMed,
2894 LoadGaussMesh(theMed,
2900 VISU::PMEDProfile aProfile = theValForTime->myProfile;
2901 VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2904 "- aMeshName = '"<<aMeshName<<"'"<<
2905 "; aFieldName = '"<<aFieldInfo->GetName()<<"'"<<
2906 "; aMEntity = "<<aMEntity<<
2907 "; aNbComp = "<<theField->myNbComp<<
2910 if(aFieldInfo->GetType() == MED::eFLOAT64)
2911 FillValForTime<MED::TFloatTimeStampValue>(CastToFloatTimeStampValue(aTimeStampValue),
2916 FillValForTime<MED::TIntTimeStampValue>(CastToIntTimeStampValue(aTimeStampValue),
2926 //---------------------------------------------------------------
2929 ::LoadValForTimeOnMesh(const MED::PWrapper& theMed,
2930 VISU::PMEDMesh theMesh,
2931 VISU::PMEDMeshOnEntity theMeshOnEntity,
2932 VISU::PMEDField theField,
2933 VISU::PMEDValForTime theValForTime)
2935 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
2936 return LoadValForTime(theMed,
2942 anUnstructuredGridIDMapper->myIsVTKDone);
2946 //---------------------------------------------------------------
2949 ::LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
2950 VISU::PMEDMesh theMesh,
2951 VISU::PMEDMeshOnEntity theMeshOnEntity,
2952 VISU::PMEDField theField,
2953 VISU::PMEDValForTime theValForTime)
2955 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
2956 return LoadValForTime(theMed,
2962 aGaussPtsIDFilter->myIsVTKDone);