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 "CASCatch.hxx"
39 #include <vtkCellType.h>
49 static int MYDEBUG = 0;
50 static int MYVALUEDEBUG = 0;
51 static int MY_FAMILY_DEBUG = 0;
52 static int MY_GROUP_DEBUG = 0;
55 static int MYDEBUG = 0;
56 static int MYVALUEDEBUG = 0;
57 static int MY_FAMILY_DEBUG = 0;
58 static int MY_GROUP_DEBUG = 0;
61 #define _LOAD_FAMILIES_
62 #define _EDF_NODE_IDS_
66 //---------------------------------------------------------------
68 MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
70 return theMEDGeomType % 100;
74 //---------------------------------------------------------------
76 MEDGeom2VISU(MED::EGeometrieElement theGeom)
79 case MED::ePOINT1: return VISU::ePOINT1;
80 case MED::eSEG2: return VISU::eSEG2;
81 case MED::eTRIA3: return VISU::eTRIA3;
82 case MED::eQUAD4: return VISU::eQUAD4;
83 case MED::eTETRA4: return VISU::eTETRA4;
84 case MED::eHEXA8: return VISU::eHEXA8;
85 case MED::ePENTA6: return VISU::ePENTA6;
86 case MED::ePYRA5: return VISU::ePYRA5;
88 case MED::eSEG3: return VISU::eSEG3;
89 case MED::eTRIA6: return VISU::eTRIA6;
90 case MED::eQUAD8: return VISU::eQUAD8;
91 case MED::eTETRA10: return VISU::eTETRA10;
92 case MED::eHEXA20: return VISU::eHEXA20;
93 case MED::ePENTA15: return VISU::ePENTA15;
94 case MED::ePYRA13: return VISU::ePYRA13;
96 case MED::ePOLYGONE: return VISU::ePOLYGONE;
97 case MED::ePOLYEDRE: return VISU::ePOLYEDRE;
103 //---------------------------------------------------------------
104 MED::EGeometrieElement
105 VISUGeom2MED(int theGeom)
108 case VISU::ePOINT1: return MED::ePOINT1;
109 case VISU::eSEG2: return MED::eSEG2;
110 case VISU::eTRIA3: return MED::eTRIA3;
111 case VISU::eQUAD4: return MED::eQUAD4;
112 case VISU::eTETRA4: return MED::eTETRA4;
113 case VISU::eHEXA8: return MED::eHEXA8;
114 case VISU::ePENTA6: return MED::ePENTA6;
115 case VISU::ePYRA5: return MED::ePYRA5;
117 case VISU::eSEG3: return MED::eSEG3;
118 case VISU::eTRIA6: return MED::eTRIA6;
119 case VISU::eQUAD8: return MED::eQUAD8;
120 case VISU::eTETRA10: return MED::eTETRA10;
121 case VISU::eHEXA20: return MED::eHEXA20;
122 case VISU::ePENTA15: return MED::ePENTA15;
123 case VISU::ePYRA13: return MED::ePYRA13;
125 case VISU::ePOLYGONE: return MED::ePOLYGONE;
126 case VISU::ePOLYEDRE: return MED::ePOLYEDRE;
128 return MED::EGeometrieElement(-1);
132 //---------------------------------------------------------------
134 MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
136 switch(theMEDEntity){
137 case MED::eNOEUD: return NODE_ENTITY;
138 case MED::eARETE: return EDGE_ENTITY;
139 case MED::eFACE: return FACE_ENTITY;
140 case MED::eMAILLE: return CELL_ENTITY;
142 return VISU::TEntity(-1);
146 //---------------------------------------------------------------
148 VTKEntityToMED(TEntity theVTKEntity)
150 switch(theVTKEntity){
151 case NODE_ENTITY: return MED::eNOEUD;
152 case EDGE_ENTITY: return MED::eARETE;
153 case FACE_ENTITY: return MED::eFACE;
154 case CELL_ENTITY: return MED::eMAILLE;
156 return MED::EEntiteMaillage(-1);
160 //---------------------------------------------------------------
162 CrSubProfile(const MED::PWrapper& theMEDWrapper,
163 const MED::PMeshInfo& theMeshInfo,
164 MED::EEntiteMaillage theMEntity,
165 MED::EGeometrieElement theMGeom,
166 const MED::TGeom2Size& theGeom2Size,
167 const MED::TGeom2Profile& theGeom2Profile)
169 VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
170 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
172 PMEDSubProfile aSubProfile(new TMEDSubProfile());
173 aSubProfile->myGeom = aEGeom;
174 aSubProfile->myMGeom = theMGeom;
175 aSubProfile->myStatus = eAddAll;
177 MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom);
178 if(aTimeStampIter == theGeom2Size.end())
179 aSubProfile->myStatus = eRemoveAll;
181 MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom);
182 if(aProfileIter != theGeom2Profile.end()){
183 MED::PProfileInfo aProfileInfo = aProfileIter->second;
185 aSubProfile->myName = aProfileInfo->GetName();
186 aSubProfile->myStatus = eAddPart;
188 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
189 TInt aNbElem = anElemNum.size();
190 aSubProfile->myNbCells = aNbElem;
192 case MED::ePOLYGONE: {
193 MED::PPolygoneInfo aPolygoneInfo =
194 theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
195 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
196 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemNum[anElemId]);
197 aSubProfile->myCellsSize += aNbConn;
201 case MED::ePOLYEDRE: {
202 MED::PPolyedreInfo aPolyedreInfo =
203 theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
204 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
205 MED::TCConnSliceArr aConnSliceArr =
206 aPolyedreInfo->GetConnSliceArr(anElemNum[anElemId]);
207 TInt aNbFaces = aConnSliceArr.size();
209 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
210 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
211 TInt aNbConn = aConnSlice.size();
212 aCellSize += aNbConn;
214 aSubProfile->myCellsSize += aCellSize;
219 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
222 TInt aNbElem = aTimeStampIter->second;
223 aSubProfile->myNbCells = aNbElem;
225 case MED::ePOLYGONE: {
226 MED::PPolygoneInfo aPolygoneInfo =
227 theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
228 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
229 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
230 aSubProfile->myCellsSize += aNbConn;
234 case MED::ePOLYEDRE: {
235 MED::PPolyedreInfo aPolyedreInfo =
236 theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
237 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
238 MED::TCConnSliceArr aConnSliceArr =
239 aPolyedreInfo->GetConnSliceArr(anElemId);
240 TInt aNbFaces = aConnSliceArr.size();
242 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
243 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
244 TInt aNbConn = aConnSlice.size();
245 aCellSize += aNbConn;
247 aSubProfile->myCellsSize += aCellSize;
252 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
257 "- aMGeom = "<<theMGeom<<
258 "; aEGeom = "<<aEGeom<<
259 "; aName = '"<<aSubProfile->myName<<"'"<<
260 "; aStatus = "<<aSubProfile->myStatus<<
261 "; aNbCells = "<<aSubProfile->myNbCells<<
262 "; aCellsSize = "<<aSubProfile->myCellsSize<<
269 //---------------------------------------------------------------
271 GetProfileKey(const MED::PWrapper& theMEDWrapper,
272 const MED::PMeshInfo& theMeshInfo,
273 const MED::TTimeStampVal& theTimeStampVal,
274 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
275 MED::EEntiteMaillage theMEntity,
276 const MED::TGeom2Size& theGeom2Size)
278 INITMSG(MYDEBUG,"GetProfileKey"<<endl);
280 TProfileKey aProfileKey;
281 const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
283 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
284 MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
285 for(; anIter != aGeom2Size.end(); anIter++){
286 MED::EGeometrieElement aMGeom = anIter->first;
287 PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
293 aProfileKey.insert(aSubProfile);
300 //---------------------------------------------------------------
302 InitProfile(const MED::PWrapper& theMEDWrapper,
303 const MED::PMeshInfo& theMeshInfo,
304 MED::TTimeStampVal& theTimeStampVal,
305 VISU::TMEDMeshOnEntity& theMeshOnEntity,
306 MED::EEntiteMaillage theMEntity,
307 const MED::TGeom2Size& theGeom2Size,
308 VISU::TMEDValForTime& theValForTime)
310 TTimerLog aTimerLog(MYDEBUG,"InitProfile");
311 INITMSG(MYDEBUG,"InitProfile"<<endl);
313 TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
315 TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
322 TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
323 if(anIter != aProfileMap.end()){
324 theValForTime.myProfile = anIter->second;
325 INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<<endl);
327 PMEDProfile aProfile(new TMEDProfile());
328 TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
330 TProfileKey::const_iterator anIter = aProfileKey.begin();
331 for(; anIter != aProfileKey.end(); anIter++){
332 PMEDSubProfile aSubProfile(*anIter);
334 if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
335 aProfile->myIsAll = false;
337 VISU::EGeometry aEGeom = aSubProfile->myGeom;
338 aGeom2SubProfile[aEGeom] = aSubProfile;
341 aProfileMap[aProfileKey] = aProfile;
342 theValForTime.myProfile = aProfile;
347 //---------------------------------------------------------------
349 GetGaussKey(const MED::TTimeStampVal& theTimeStampVal,
350 const VISU::TMEDMeshOnEntity& theMeshOnEntity,
351 const MED::TGeom2Size& theGeom2Size,
352 VISU::TMEDValForTime& theValForTime)
354 TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
355 INITMSG(MYDEBUG,"GetGaussKey"<<endl);
358 PMEDProfile aProfile = theValForTime.myProfile;
359 TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
361 const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
362 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
364 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
365 MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
366 for(; anIter != aGeom2Size.end(); anIter++){
367 MED::EGeometrieElement aMGeom = anIter->first;
368 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
370 TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
371 if(anIter2 == aGeom2SubProfile.end()){
372 INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
375 PMEDSubProfile aSubProfile = anIter2->second;
377 MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
378 if(aTimeStampIter != theGeom2Size.end()){
379 TInt aNbCells = aTimeStampIter->second;
380 if(aSubProfile->myStatus == eAddPart)
381 aNbCells = aSubProfile->myNbCells;
383 PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
384 aGaussSubMesh->mySubProfile = aSubProfile;
385 aGaussSubMesh->myStatus = aSubProfile->myStatus;
387 PMEDGauss aGauss(new TMEDGauss());
388 aGaussSubMesh->myGauss = aGauss;
389 aGauss->myGeom = aEGeom;
390 aGauss->myNbPoints = 1;
392 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
393 if(aGaussIter != aGeom2Gauss.end()){
394 MED::PGaussInfo aGaussInfo = aGaussIter->second;
395 aGauss->myGaussInfo = aGaussInfo;
396 aGauss->myName = aGaussInfo->GetName();
397 aGauss->myNbPoints = aGaussInfo->GetNbGauss();
400 aGaussSubMesh->myNbCells = aNbCells*aGauss->myNbPoints;
401 aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2;
403 aGaussKey.insert(aGaussSubMesh);
406 "- aEGeom = "<<aGauss->myGeom<<
407 "; aName = '"<<aGauss->myName<<"'"<<
408 "; aNbGauss = "<<aGauss->myNbPoints<<
409 "; aStatus = "<<aGaussSubMesh->myStatus<<
410 "; aNbCells = "<<aGaussSubMesh->myNbCells<<
411 "; aCellsSize = "<<aGaussSubMesh->myCellsSize<<
420 //---------------------------------------------------------------
422 InitGaussMesh(MED::TTimeStampVal& theTimeStampVal,
423 VISU::TMEDMeshOnEntity& theMeshOnEntity,
424 const MED::TGeom2Size& theGeom2Size,
425 VISU::TMEDValForTime& theValForTime)
427 TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
428 INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
430 if(theMeshOnEntity.myEntity == NODE_ENTITY)
433 TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
435 TGaussKey aGaussKey = GetGaussKey(theTimeStampVal,
440 TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
441 if(anIter != aGaussMeshMap.end()){
442 theValForTime.myGaussMesh = anIter->second;
443 INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<<endl);
445 PMEDGaussMesh aGaussMesh(new TMEDGaussMesh());
446 TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
448 TGaussKey::const_iterator anIter = aGaussKey.begin();
449 for(; anIter != aGaussKey.end(); anIter++){
450 PMEDGaussSubMesh aGaussSubMesh(*anIter);
451 PMEDGauss aGauss = aGaussSubMesh->myGauss;
452 VISU::EGeometry aEGeom = aGauss->myGeom;
453 aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh;
457 TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
458 aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size());
459 TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
460 for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){
461 const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
462 aGaussSubMeshArr[anID] = aGaussSubMesh;
465 INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<endl);
466 aGaussMeshMap[aGaussKey] = aGaussMesh;
467 theValForTime.myGaussMesh = aGaussMesh;
472 //---------------------------------------------------------------
474 InitGaussProfile(const MED::PWrapper& theMEDWrapper,
475 const MED::PMeshInfo& theMeshInfo,
476 MED::TTimeStampVal& theTimeStampVal,
477 VISU::TMEDMeshOnEntity& theMeshOnEntity,
478 MED::EEntiteMaillage theMEntity,
479 const MED::TGeom2Size& theGeom2Size,
480 VISU::TMEDValForTime& theValForTime)
482 TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile");
483 INITMSG(MYDEBUG,"InitGaussProfile"<<endl);
485 // The order of the function calls is important
486 InitProfile(theMEDWrapper,
494 InitGaussMesh(theTimeStampVal,
501 //---------------------------------------------------------------
503 BuildMeshOnEntityMap(PMEDMesh theMesh,
504 const MED::TEntityInfo& theEntityInfo,
505 const MED::PNodeInfo& theNodeInfo,
506 const MED::PWrapper& theMEDWrapper)
508 TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
509 INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
511 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
512 const std::string& aMeshName = theMesh->myName;
513 TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
514 MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
515 for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
516 const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
517 const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
519 TEntity aVEntity = MEDEntityToVTK(aMEntity);
520 PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity());
521 aMeshOnEntity->myEntity = aVEntity;
522 aMeshOnEntity->myMeshName = aMeshName;
523 aMeshOnEntity->myGeom2Size = aGeom2Size;
524 TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
527 "- aMEntity = "<<aMEntity<<
528 "; aVEntity = "<<aVEntity<<
531 if(aMEntity == MED::eNOEUD){
532 aMeshOnEntity->myNbCells = theMesh->myNbPoints;
533 aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
535 for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
536 TInt aFamId = theNodeInfo->GetFamNum(iElem);
538 aFamilyID2CellsSize[aFamId] += 2;
542 "- myNbCells = "<<aMeshOnEntity->myNbCells<<
543 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
547 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
548 aMeshOnEntity->myNbCells = 0;
549 aMeshOnEntity->myCellsSize = 0;
550 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
551 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
554 case MED::ePOLYGONE: {
555 MED::PPolygoneInfo aPolygoneInfo = theMEDWrapper->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
556 TInt aNbElem = aPolygoneInfo->GetNbElem();
559 "- aMGeom = "<<aMGeom<<
560 "; aNbElem = "<<aNbElem<<
563 aMeshOnEntity->myNbCells += aNbElem;
564 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
565 TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
566 aMeshOnEntity->myCellsSize += aNbConn;
567 TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
569 aFamilyID2CellsSize[aFamId] += aNbConn + 1;
573 case MED::ePOLYEDRE: {
574 MED::PPolyedreInfo aPolyedreInfo = theMEDWrapper->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
575 TInt aNbElem = aPolyedreInfo->GetNbElem();
578 "- aMGeom = "<<aMGeom<<
579 "; aNbElem = "<<aNbElem<<
582 aMeshOnEntity->myNbCells += aNbElem;
583 for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
584 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(anElemId);
585 TInt aNbFaces = aConnSliceArr.size();
587 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
588 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
589 TInt aNbConn = aConnSlice.size();
590 aCellSize += aNbConn;
592 aMeshOnEntity->myCellsSize += aCellSize;
593 TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
595 aFamilyID2CellsSize[aFamId] += aCellSize + 1;
600 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
601 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
602 MED::PCellInfo aCellInfo = theMEDWrapper->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
603 TInt aNbElem = aCellInfo->GetNbElem();
604 aMeshOnEntity->myNbCells += aNbElem;
605 aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
608 "- aMGeom = "<<aMGeom<<
609 "; aNbElem = "<<aNbElem<<
610 "; myNbCells = "<<aMeshOnEntity->myNbCells<<
611 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
614 for(TInt iElem = 0; iElem < aNbElem; iElem++){
615 TInt aFamId = aCellInfo->GetFamNum(iElem);
617 aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
619 }} // end switch(...)
626 //---------------------------------------------------------------
628 BuildFieldMap(PMEDMesh theMesh,
629 const MED::TEntityInfo& theEntityInfo,
630 MED::PWrapper theMEDWrapper)
632 TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
633 TInt aNbFields = theMEDWrapper->GetNbFields();
634 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
635 const std::string& aMeshName = theMesh->myName;
636 INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
637 for(TInt iField = 1; iField <= aNbFields; iField++){
638 TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
639 MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
640 TInt aNbComp = aFieldInfo->GetNbComp();
641 std::string aFieldName = aFieldInfo->GetName();
643 MED::TGeom2Size aGeom2Size;
644 MED::EEntiteMaillage aMEntity;
645 TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
649 if(aNbTimeStamps < 1)
652 TEntity aVEntity = MEDEntityToVTK(aMEntity);
653 PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
654 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
655 PMEDField aField = aFieldMap[aFieldName](new TMEDField());
656 aField->myId = iField;
657 aField->InitArrays(aNbComp);
658 aField->myEntity = aVEntity;
659 aField->myName = aFieldName;
660 aField->myMeshName = aMeshName;
661 aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
663 INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
664 "; myId = "<<aField->myId<<
665 "; myEntity = "<<aField->myEntity<<
666 "; myDataSize = "<<aField->myDataSize<<
667 "; myNbComp = "<<aField->myNbComp<<"\n");
669 for(TInt iComp = 0; iComp < aNbComp; iComp++){
670 aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp);
671 aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp);
674 for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
675 TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
676 MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
680 TFloat aDt = aTimeStampInfo->GetDt();
681 std::string anUnitDt = aTimeStampInfo->GetUnitDt();
683 TValField& aValField = aField->myValField;
684 PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
685 aValForTime->myId = iTimeStamp;
686 aValForTime->myFieldName = aField->myName;
687 aValForTime->myEntity = aField->myEntity;
688 aValForTime->myMeshName = aField->myMeshName;
689 aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
690 INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
692 TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
693 const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss;
694 MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
695 for(; anIter != aMGeom2NbGauss.end(); anIter++){
696 const MED::EGeometrieElement& aMGeom = anIter->first;
697 EGeometry aEGeom = MEDGeom2VISU(aMGeom);
698 TInt aNbGauss = anIter->second;
699 aVGeom2NbGauss[aEGeom] = aNbGauss;
706 //---------------------------------------------------------------
708 BuildFamilyMap(PMEDMesh theMesh,
709 const MED::TEntityInfo& theEntityInfo,
710 const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
711 const MED::TFamilyInfoSet& theFamilyInfoSet,
712 MED::PWrapper theMEDWrapper)
714 TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
715 INITMSG(MYDEBUG,"BuildFamilyMap\n");
717 MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
718 MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
719 MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
720 for(; aEntity2FamilySetIter != aEntity2FamilySet.end(); aEntity2FamilySetIter++){
721 const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
722 const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
724 TEntity aVEntity = MEDEntityToVTK(aMEntity);
725 PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
726 const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
727 TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
729 if(aFamilyTSizeSet.empty())
732 INITMSG(MY_FAMILY_DEBUG,
733 "- aMEntity = "<<aMEntity<<
734 "; aVEntity = "<<aVEntity<<
737 MED::TFamilyTSizeSet::const_iterator aFamilyTSizeSetIter = aFamilyTSizeSet.begin();
738 for(; aFamilyTSizeSetIter != aFamilyTSizeSet.end(); aFamilyTSizeSetIter++){
739 const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
740 const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
741 TInt aSize = boost::get<1>(aFamilyTSize);
742 TInt anId = aFamilyInfo->GetId();
746 std::string aFamilyName = aFamilyInfo->GetName();
748 PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
749 aFamily->myId = anId;
750 aFamily->myEntity = aVEntity;
751 aFamily->myName = aFamilyName;
752 aFamily->myNbCells = aSize;
754 aFamily->myCellsSize = 0;
755 TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
756 if(anIter != aFamilyID2CellsSize.end())
757 aFamily->myCellsSize = anIter->second;
759 INITMSG(MY_FAMILY_DEBUG,
760 "- aFamilyName = '"<<aFamilyName<<"'"<<
761 "; myId = "<<aFamily->myId<<"; "<<
762 "; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
763 "; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
764 "; aVEntity = "<<aVEntity<<
765 "; myNbCells = "<<aFamily->myNbCells<<
766 "; myCellsSize = "<<aFamily->myCellsSize<<
769 const TInt aNbGroup = aFamilyInfo->GetNbGroup();
770 for(TInt i = 0; i < aNbGroup; i++){
771 std::string aGroupName = aFamilyInfo->GetGroupName(i);
772 INITMSG(MY_FAMILY_DEBUG,"- aGroupName = '"<<aGroupName<<"'\n");
781 //---------------------------------------------------------------
783 BuildGroupMap(PMEDMesh theMesh,
784 const MED::TFamilyInfoSet& theFamilyInfoSet)
786 TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
787 INITMSG(MYDEBUG,"BuildGroupMap\n");
789 TGroupMap& aGroupMap = theMesh->myGroupMap;
790 MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
791 MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
792 for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
793 const std::string& aGroupName = aGroupInfoIter->first;
794 INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
796 PMEDGroup aGroup(new TMEDGroup());
797 TFamilySet& aFamilySet = aGroup->myFamilySet;
799 const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
800 MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
801 for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
802 const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
803 std::string aFamilyName = aFamilyInfo->GetName();
805 TEntity aVEntity = TEntity(-1);
809 const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
810 TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
811 for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
812 const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
813 const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
814 TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
815 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
816 const std::string& aName = aFamilyMapIter->first;
817 aFamily = aFamilyMapIter->second;
818 if(aName == aFamilyName){
819 aVEntity = aFamily->myEntity;
825 if(aFamily && aVEntity >= 0){
826 aFamilySet.insert(aFamily);
827 INITMSG(MY_GROUP_DEBUG,
828 "- aFamilyName = '"<<aFamilyName<<"'"<<
829 "; aVEntity = "<<aVEntity<<
833 if(!aFamilySet.empty())
834 aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
839 //---------------------------------------------------------------
842 ::Init(vtkIdType theNbPoints,
844 const MED::PNodeInfo& theNodeInfo)
846 if(theNodeInfo->IsElemNum())
847 TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
849 TNamedPointCoords::Init(theNbPoints,theDim);
850 if(theNodeInfo->IsElemNames())
851 myNodeInfo = theNodeInfo;
856 ::GetNodeName(vtkIdType theObjID) const
859 return myNodeInfo->GetElemName(theObjID);
860 return TNamedPointCoords::GetNodeName(theObjID);
864 //---------------------------------------------------------------
867 ::GetElemObjID(vtkIdType theID) const
870 return myElemNum[theID];
876 //---------------------------------------------------------------
879 ::LessThan(const PGaussImpl& theGauss,
880 bool& theResult) const
882 TGaussImpl::LessThan(theGauss,theResult);
884 if(PMEDGauss aGauss = theGauss){
885 const MED::TGaussInfo& aLeft = myGaussInfo;
886 const MED::TGaussInfo& aReight = aGauss->myGaussInfo;
887 theResult = MED::TGaussInfo::TLess()(aLeft,aReight);
893 //---------------------------------------------------------------
896 ::GetObjID(vtkIdType theID,
897 vtkIdType theStartID) const
899 TCellID aCellID = theID / myGauss->myNbPoints;
900 TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
903 aCellID = myElemNum[aCellID];
905 aCellID += theStartID;
907 return TGaussPointID(aCellID,aLocalPntID);
911 //---------------------------------------------------------------
914 ::Init(const MED::PElemInfo& theElemInfo)
916 myIsElemNum = theElemInfo->IsElemNum();
919 myElemNum = theElemInfo->myElemNum;
921 if(theElemInfo->IsElemNames())
922 myElemInfo = theElemInfo;
927 ::GetElemObjID(vtkIdType theID) const
930 return myElemNum[theID];
932 return TSubMeshImpl::GetElemObjID(theID);
937 ::GetElemName(vtkIdType theObjID) const
940 return myElemInfo->GetElemName(theObjID);
941 return TSubMeshImpl::GetElemName(theObjID);
947 TSetIsDone(bool& theIsDone):
960 //---------------------------------------------------------------
963 CreateConvertor(const string& theFileName)
965 if(MED::PWrapper aMed = MED::CrWrapper(theFileName,true))
966 return new VISU_MedConvertor(theFileName);
971 ::VISU_MedConvertor(const string& theFileName):
972 myIsEntitiesDone(false),
973 myIsFieldsDone(false),
974 myIsGroupsDone(false),
975 myIsMinMaxDone(false)
977 myFileInfo.setFile(QString(theFileName.c_str()));
978 myName = myFileInfo.baseName().latin1();
982 //---------------------------------------------------------------
990 TSetIsDone aSetIsDone(myIsEntitiesDone);
991 TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
992 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
994 TInt aNbMeshes = aMed->GetNbMeshes();
995 TMeshMap& aMeshMap = myMeshMap;
997 INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
999 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1003 TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1005 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1006 std::string aMeshName = aMeshInfo->GetName();
1007 TInt aDim = aMeshInfo->GetDim();
1009 MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
1011 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1013 // creating TMesh structure and TMeshOnEntityMap
1014 PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
1015 aMesh->myDim = aDim;
1016 aMesh->myName = aMeshName;
1017 aMesh->myNbPoints = aNodeInfo->GetNbElem();
1018 aMesh->myMeshInfo = aMeshInfo;
1019 aMesh->myEntityInfo = anEntityInfo;
1020 aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
1022 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
1023 "'; myNbPoints = "<<aMesh->myNbPoints<<
1024 "; aDim = "<<aDim<<"\n");
1029 BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
1031 BuildMeshOnEntityMap(aMesh,
1037 }catch(std::exception& exc){
1038 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1040 MSG(MYDEBUG,"Unknown exception !!!");
1045 }catch(std::exception& exc){
1046 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1048 MSG(MYDEBUG,"Unknown exception !!!");
1057 //---------------------------------------------------------------
1065 TSetIsDone aSetIsDone(myIsFieldsDone);
1066 TTimerLog aTimerLog(MYDEBUG,"BuildFields");
1067 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1069 TInt aNbMeshes = aMed->GetNbMeshes();
1070 TMeshMap& aMeshMap = myMeshMap;
1072 INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
1074 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1078 TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1080 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1081 std::string aMeshName = aMeshInfo->GetName();
1083 TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1084 if(anIter == aMeshMap.end())
1086 PMEDMesh aMesh = anIter->second;
1088 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1092 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1094 BuildFieldMap(aMesh,
1098 }catch(std::exception& exc){
1099 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1101 MSG(MYDEBUG,"Unknown exception !!!");
1106 }catch(std::exception& exc){
1107 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1109 MSG(MYDEBUG,"Unknown exception !!!");
1118 //---------------------------------------------------------------
1126 TSetIsDone aSetIsDone(myIsMinMaxDone);
1127 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
1128 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1130 MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
1131 MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
1133 TInt aNbMeshes = aMed->GetNbMeshes();
1134 TMeshMap& aMeshMap = myMeshMap;
1136 INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
1138 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1142 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
1144 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1145 std::string aMeshName = aMeshInfo->GetName();
1147 TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1148 if(anIter == aMeshMap.end())
1150 PMEDMesh aMesh = anIter->second;
1155 TInt aNbFields = aMed->GetNbFields();
1158 "- aMeshName = '"<<aMeshName<<"'"<<
1159 "; aNbFields = "<<aNbFields<<"\n");
1161 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1163 for(TInt iField = 1; iField <= aNbFields; iField++){
1164 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
1165 MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
1166 std::string aFieldName = aFieldInfo->GetName();
1167 INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
1169 MED::TGeom2Size aGeom2Size;
1170 MED::EEntiteMaillage aMEntity;
1171 TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,
1175 if(aNbTimeStamps < 1)
1178 TEntity aVEntity = MEDEntityToVTK(aMEntity);
1179 PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
1180 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1181 PMEDField aField = aFieldMap[aFieldName];
1183 TInt aNbComp = aField->myNbComp;
1184 int aNbComp2 = aNbComp;
1185 if(aNbComp == 2 || aNbComp == 4)
1187 else if(aNbComp > 4)
1190 TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
1191 TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
1192 for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
1193 TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
1194 INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
1200 MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
1205 MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
1209 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
1211 const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
1213 const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
1214 MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
1215 for(; anIter != aGeom2Value.end(); anIter++){
1216 const MED::TMeshValue& aMMeshValue = anIter->second;
1217 MED::EGeometrieElement aMGeom = anIter->first;
1219 TInt aNbElem = aMMeshValue.myNbElem;
1220 TInt aNbGauss = aMMeshValue.myNbGauss;
1222 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
1223 if(aGaussIter == aGeom2Gauss.end())
1227 "- aMGeom = "<<aMGeom<<
1228 "; aNbElem = "<<aNbElem<<
1229 "; aNbGauss = "<<aNbGauss<<
1232 // To calculate min/max per components
1233 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1234 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
1235 for(TInt iComp = 0; iComp < aNbComp; iComp++){
1236 const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
1237 TMinMax& aMinMax = aMinMaxArr[iComp+1];
1238 float& aMin = aMinMax.first;
1239 float& aMax = aMinMax.second;
1240 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1241 const float& aVal = aMValueSlice[iGauss];
1242 aMin = min(aMin,aVal);
1243 aMax = max(aMax,aVal);
1248 // To calculate min/max per vector modulus
1249 TMinMax& aMinMax = aMinMaxArr[0];
1250 float& aMin = aMinMax.first;
1251 float& aMax = aMinMax.second;
1252 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1253 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
1254 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
1255 const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
1257 for(TInt iComp = 0; iComp < aNbComp2; iComp++){
1258 float aVal = aMValueSlice[iComp];
1259 aValue += aVal*aVal;
1261 aValue = sqrt(aValue);
1262 aMin = min(aMin,aValue);
1263 aMax = max(aMax,aValue);
1268 }catch(std::exception& exc){
1269 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1271 MSG(MYDEBUG,"Unknown exception !!!");
1273 }CASCatch_CATCH(Standard_Failure){
1274 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1275 MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
1279 for(TInt iComp = 0; iComp <= aNbComp; iComp++){
1280 VISU::TMinMax aMinMax = aField->GetMinMax(iComp);
1281 INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
1285 }catch(std::exception& exc){
1286 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1288 MSG(MYDEBUG,"Unknown exception !!!");
1293 }catch(std::exception& exc){
1294 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1296 MSG(MYDEBUG,"Unknown exception !!!");
1305 //---------------------------------------------------------------
1313 TSetIsDone aSetIsDone(myIsGroupsDone);
1314 TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
1315 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1317 TInt aNbMeshes = aMed->GetNbMeshes();
1318 TMeshMap& aMeshMap = myMeshMap;
1320 INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
1322 for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
1326 TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
1328 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
1329 std::string aMeshName = aMeshInfo->GetName();
1331 TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
1332 if(anIter == aMeshMap.end())
1334 PMEDMesh aMesh = anIter->second;
1336 INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
1338 MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
1340 MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
1341 MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo);
1346 MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo);
1348 BuildFamilyMap(aMesh,
1350 anEntity2TGeom2ElemInfo,
1354 BuildGroupMap(aMesh,
1357 }catch(std::exception& exc){
1358 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1360 MSG(MYDEBUG,"Unknown exception !!!");
1365 }catch(std::exception& exc){
1366 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
1368 MSG(MYDEBUG,"Unknown exception !!!");
1377 //---------------------------------------------------------------
1380 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
1381 VISU::PMeshOnEntityImpl theMeshOnEntity)
1383 TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
1384 INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
1386 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1387 const TEntity& anEntity = theMeshOnEntity->myEntity;
1389 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1390 if(anEntity == NODE_ENTITY){
1391 isPointsUpdated += LoadPoints(aMed,theMesh);
1393 isPointsUpdated += LoadPoints(aMed,theMesh);
1394 isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
1397 return (isPointsUpdated || isCellsOnEntityUpdated);
1401 //---------------------------------------------------------------
1404 ::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
1405 VISU::PMeshOnEntityImpl theMeshOnEntity,
1406 VISU::PFamilyImpl theFamily)
1408 TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
1409 INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
1411 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1412 const TEntity& anEntity = theMeshOnEntity->myEntity;
1414 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1415 if(anEntity == NODE_ENTITY){
1416 isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily);
1418 isPointsUpdated += LoadPoints(aMed,theMesh);
1419 isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,theMeshOnEntity,theFamily);
1422 return (isPointsUpdated || isCellsOnEntityUpdated);
1426 //---------------------------------------------------------------
1429 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
1430 const VISU::TFamilySet& theFamilySet)
1432 TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
1433 INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
1435 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1436 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1437 TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
1438 for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
1439 PMEDFamily aFamily = *aFamilyIter;
1440 const TEntity& anEntity = aFamily->myEntity;
1441 const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
1442 if(anEntity == NODE_ENTITY){
1443 isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily);
1445 isPointsUpdated += LoadPoints(aMed,theMesh);
1446 isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily);
1450 return (isPointsUpdated || isCellsOnEntityUpdated);
1454 //---------------------------------------------------------------
1457 ::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
1458 VISU::PMeshOnEntityImpl theMeshOnEntity,
1459 VISU::PFieldImpl theField,
1460 VISU::PValForTimeImpl theValForTime)
1462 TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
1463 INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
1465 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1467 const TEntity& anEntity = theMeshOnEntity->myEntity;
1468 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1469 isPointsUpdated += LoadPoints(aMed,theMesh);
1470 if(anEntity != NODE_ENTITY)
1471 isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
1472 int isFieldUpdated = LoadValForTimeOnMesh(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
1474 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
1478 //---------------------------------------------------------------
1481 ::LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
1482 VISU::PMeshOnEntityImpl theMeshOnEntity,
1483 VISU::PFieldImpl theField,
1484 VISU::PValForTimeImpl theValForTime)
1486 TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
1487 INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
1489 MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
1491 const TEntity& anEntity = theMeshOnEntity->myEntity;
1492 int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
1493 if(anEntity != NODE_ENTITY)
1494 isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
1495 int isFieldUpdated = LoadValForTimeOnGaussPts(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
1497 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
1501 //---------------------------------------------------------------
1504 ::LoadPoints(const MED::PWrapper& theMed,
1505 VISU::PMEDMesh theMesh)
1507 TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
1509 //Check on existing family
1510 PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1511 aMeshOnEntity->myMeshName = theMesh->myName;
1512 aMeshOnEntity->myEntity = NODE_ENTITY;
1514 INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<<theMesh->myIsDone<<"'\n");
1516 //Check on loading already done
1517 if(theMesh->myIsDone)
1521 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
1522 TInt aNbElem = aNodeInfo->GetNbElem();
1523 TInt aDim = theMesh->myDim;
1525 PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
1526 TMEDNamedPointCoords& aCoords = aNamedPointCoords;
1527 aCoords.Init(aNbElem,aDim,aNodeInfo);
1529 for(int iDim = 0; iDim < aDim; iDim++)
1530 aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
1532 for(int iElem = 0; iElem < aNbElem; iElem++){
1533 TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem);
1534 MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem);
1535 for(int iDim = 0; iDim < aDim; iDim++)
1536 aVCoordSlice[iDim] = aMCoordSlice[iDim];
1539 TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
1540 PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh());
1542 aSubMesh->Init(aNodeInfo);
1543 aSubMesh->myNbCells = theMesh->myNbPoints;
1544 aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
1546 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1547 aCell2Connect.resize(aNbElem);
1548 for (int iElem = 0; iElem < aNbElem; iElem++)
1549 aCell2Connect[iElem] = VISU::TConnect(1,iElem);
1551 theMesh->myIsDone = true;
1555 }catch(std::exception& exc){
1558 EXCEPTION(runtime_error,"Unknown exception !!!");
1565 //---------------------------------------------------------------
1568 ::LoadPointsOnFamily(const MED::PWrapper& theMed,
1569 const VISU::PMEDMesh theMesh,
1570 const VISU::PMEDFamily theFamily)
1572 TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
1574 if(theFamily->myIsDone)
1578 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
1579 TInt aNbElem = aNodeInfo->GetNbElem();
1582 TInt anId = theFamily->myId;
1583 TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
1584 for(TInt iElem = 0; iElem < aNbElem; iElem++)
1585 if(aNodeInfo->GetFamNum(iElem) == anId)
1586 aSubMeshID.push_back(iElem);
1589 theFamily->myIsDone = true;
1593 }catch(std::exception& exc){
1596 EXCEPTION(runtime_error,"Unknown exception !!!");
1603 //---------------------------------------------------------------
1606 ::LoadCellsOnEntity(const MED::PWrapper& theMed,
1607 const VISU::PMEDMesh theMesh,
1608 const VISU::PMEDMeshOnEntity theMeshOnEntity)
1610 TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
1614 const TEntity& aVEntity = theMeshOnEntity->myEntity;
1615 const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
1617 INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<<aVEntity<<"\n");
1619 if(theMeshOnEntity->myIsDone)
1622 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
1623 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
1624 TInt aNbPoints = aNodeInfo->GetNbElem();
1626 std::map<TInt,TInt> aNodeIdMap;
1627 #ifdef _EDF_NODE_IDS_
1628 EBooleen anIsNodeNum = MED::eFAUX;
1630 EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
1632 for(TInt i = 0; i < aNbPoints; i++){
1633 aNodeIdMap[aNodeInfo->GetElemNum(i)-1] = i;
1638 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
1639 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
1640 TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1642 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
1643 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
1644 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1645 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
1647 case MED::ePOLYGONE: {
1648 MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
1649 TInt aNbElem = aPolygoneInfo->GetNbElem();
1651 PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
1653 aSubMesh->Init(aPolygoneInfo);
1654 aSubMesh->myNbCells = aNbElem;
1656 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1657 aCell2Connect.resize(aNbElem);
1659 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
1660 MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
1661 TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
1662 aSubMesh->myCellsSize += aNbConn;
1663 TConnect& anArray = aCell2Connect[iElem];
1664 anArray.resize(aNbConn);
1665 for(TInt iConn = 0; iConn < aNbConn; iConn++)
1666 anArray[iConn] = aConnSlice[iConn] - 1;
1671 case MED::ePOLYEDRE: {
1672 MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
1673 TInt aNbElem = aPolyedreInfo->GetNbElem();
1676 PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
1678 aSubMesh->Init(aPolyedreInfo);
1679 aSubMesh->myNbCells = aNbElem;
1681 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1682 aCell2Connect.resize(aNbElem);
1684 for(TInt iElem = 0; iElem < aNbElem; iElem++){
1685 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
1686 TConnect& anArray = aCell2Connect[iElem];
1687 typedef std::set<TInt> TConnectSet;
1688 TConnectSet aConnectSet;
1689 TInt aNbFaces = aConnSliceArr.size();
1690 for(TInt iFace = 0; iFace < aNbFaces; iFace++){
1691 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
1692 TInt aNbConn = aConnSlice.size();
1693 aSubMesh->myCellsSize += aNbConn;
1694 for(TInt iConn = 0; iConn < aNbConn; iConn++){
1695 aConnectSet.insert(aConnSlice[iConn]);
1699 int aNbConn = aConnectSet.size();
1700 anArray.resize(aNbConn);
1701 TConnectSet::iterator anIter = aConnectSet.begin();
1702 for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){
1703 TInt anId = *anIter;
1704 anArray[i] = anId - 1;
1712 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
1713 INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
1715 MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
1716 TInt aNbElem = aCellInfo->GetNbElem();
1719 PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
1721 aSubMesh->Init(aCellInfo);
1722 aSubMesh->myNbCells = aNbElem;
1723 aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
1725 TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1726 aCell2Connect.resize(aNbElem);
1728 TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
1729 TVector<TInt> aConnect(aMNbNodes);
1731 for(TInt iElem = 0; iElem < aNbElem; iElem++) {
1732 MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
1733 TConnect& anArray = aCell2Connect[iElem];
1734 anArray.resize(aVNbNodes);
1737 for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
1738 aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1];
1741 for(int iConn = 0; iConn < aMNbNodes; iConn++){
1742 aConnect[iConn] = aConnSlice[iConn] - 1;
1747 #if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1749 anArray[0] = aConnect[0];
1750 anArray[2] = aConnect[1];
1752 anArray[1] = aConnect[2];
1755 #if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1757 anArray[0] = aConnect[0];
1758 anArray[2] = aConnect[1];
1759 anArray[4] = aConnect[2];
1761 anArray[1] = aConnect[3];
1762 anArray[3] = aConnect[4];
1763 anArray[5] = aConnect[5];
1766 #if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1768 anArray[0] = aConnect[0];
1769 anArray[2] = aConnect[1];
1770 anArray[4] = aConnect[2];
1771 anArray[6] = aConnect[3];
1773 anArray[1] = aConnect[4];
1774 anArray[3] = aConnect[5];
1775 anArray[5] = aConnect[6];
1776 anArray[7] = aConnect[7];
1779 #if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1781 anArray[0] = aConnect[0];
1782 anArray[1] = aConnect[2];
1783 anArray[2] = aConnect[1];
1784 anArray[3] = aConnect[3];
1786 anArray[4] = aConnect[6];
1787 anArray[5] = aConnect[5];
1788 anArray[6] = aConnect[4];
1790 anArray[7] = aConnect[7];
1791 anArray[8] = aConnect[9];
1792 anArray[9] = aConnect[8];
1796 anArray[0] = aConnect[0];
1797 anArray[1] = aConnect[2];
1798 anArray[2] = aConnect[1];
1799 anArray[3] = aConnect[3];
1801 #if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1803 anArray[0] = aConnect[0];
1804 anArray[1] = aConnect[3];
1805 anArray[2] = aConnect[2];
1806 anArray[3] = aConnect[1];
1807 anArray[4] = aConnect[4];
1809 anArray[5] = aConnect[5];
1810 anArray[6] = aConnect[8];
1811 anArray[7] = aConnect[7];
1812 anArray[8] = aConnect[6];
1814 anArray[9] = aConnect[9];
1815 anArray[10] = aConnect[12];
1816 anArray[11] = aConnect[11];
1817 anArray[12] = aConnect[10];
1821 anArray[0] = aConnect[0];
1822 anArray[1] = aConnect[3];
1823 anArray[2] = aConnect[2];
1824 anArray[3] = aConnect[1];
1825 anArray[4] = aConnect[4];
1828 for(int iNode = 0; iNode < aVNbNodes; iNode++)
1829 anArray[iNode] = aConnect[iNode];
1831 for(int iNode = 0; iNode < aVNbNodes; iNode++)
1832 if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
1833 EXCEPTION(runtime_error,"LoadCellsOnEntity - "<<
1834 " aNbPoints("<<aNbPoints<<") "<<
1835 "<= anArray["<<iElem<<"]"<<
1837 "("<<anArray[iNode]<<") < 0");
1843 theMeshOnEntity->myIsDone = true;
1848 }catch(std::exception& exc){
1851 EXCEPTION(runtime_error,"Unknown exception !!!");
1859 //---------------------------------------------------------------
1862 ::LoadCellsOnFamily(const MED::PWrapper& theMed,
1863 const VISU::PMEDMesh theMesh,
1864 const VISU::PMEDMeshOnEntity theMeshOnEntity,
1865 const VISU::PMEDFamily theFamily)
1867 TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
1871 const TEntity& aVEntity = theMeshOnEntity->myEntity;
1872 const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
1874 INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<<aVEntity<<"\n");
1876 if(theFamily->myIsDone)
1879 TInt anId = theFamily->myId;
1881 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
1882 TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
1884 const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
1885 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
1886 for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
1887 const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
1888 MED::PElemInfo anElemInfo;
1890 case MED::ePOLYGONE: {
1891 anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
1894 case MED::ePOLYEDRE: {
1895 anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
1899 anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
1903 if(TInt aNbElem = anElemInfo->GetNbElem()){
1904 TSubMeshID aSubMeshID;
1905 for(TInt iElem = 0; iElem < aNbElem; iElem++)
1906 if(anElemInfo->GetFamNum(iElem) == anId)
1907 aSubMeshID.push_back(iElem);
1908 if(!aSubMeshID.empty()){
1909 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1910 INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
1911 aGeom2SubMeshID.insert(TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
1917 theFamily->myIsDone = true;
1922 }catch(std::exception& exc){
1925 EXCEPTION(runtime_error,"Unknown exception !!!");
1933 //---------------------------------------------------------------
1935 LoadProfile(const MED::PWrapper& theMed,
1936 VISU::PMEDMesh theMesh,
1937 MED::TTimeStampVal& theTimeStampVal,
1938 VISU::TMEDValForTime& theValForTime,
1939 VISU::TMEDMeshOnEntity& theMeshOnEntity)
1941 TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
1942 INITMSG(MYDEBUG,"LoadProfile"<<endl);
1944 PMEDProfile aProfile = theValForTime.myProfile;
1945 if(aProfile->myIsDone)
1948 const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
1949 const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
1950 MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin();
1951 for(; anIter != aGeom2Profile.end(); anIter++){
1952 MED::PProfileInfo aProfileInfo = anIter->second;
1953 MED::EGeometrieElement aMGeom = anIter->first;
1954 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1956 TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
1957 if(anIter2 != aGeom2SubProfile.end()){
1958 PMEDSubProfile aSubProfile = anIter2->second;
1960 MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
1961 if(!anElemNum.empty()){
1962 TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
1963 TInt aSize = anElemNum.size();
1964 aSubMeshID.resize(aSize);
1965 for(TInt anId = 0; anId < aSize; anId++)
1966 aSubMeshID[anId] = anElemNum[anId] - 1;
1970 "- aEGeom = "<<aEGeom<<
1971 "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
1976 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
1978 TEntity aVEntity = theMeshOnEntity.myEntity;
1979 MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
1981 const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
1982 TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
1983 for(; anIter != aGeom2SubProfile.end(); anIter++){
1984 const PMEDSubProfile& aSubProfile = anIter->second;
1985 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
1986 MED::PElemInfo anElemInfo;
1987 if(aMEntity == MED::eNOEUD)
1988 anElemInfo = theMed->GetPNodeInfo(aMeshInfo);
1991 case MED::ePOLYGONE: {
1992 anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
1995 case MED::ePOLYEDRE: {
1996 anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
2000 anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
2004 aSubProfile->myIsElemNum = anElemInfo->IsElemNum();
2005 aSubProfile->myElemNum = anElemInfo->myElemNum;
2009 aProfile->myIsDone = true;
2013 //---------------------------------------------------------------
2015 LoadGaussMesh(const MED::PWrapper& theMed,
2016 VISU::PMEDMesh theMesh,
2017 MED::TTimeStampVal& theTimeStampVal,
2018 VISU::TMEDValForTime& theValForTime,
2019 VISU::TMEDMeshOnEntity& theMeshOnEntity)
2021 TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
2022 INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
2024 PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
2025 if(!aGaussMesh || aGaussMesh->myIsDone)
2028 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2029 MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
2031 TEntity aVEntity = theMeshOnEntity.myEntity;
2032 MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
2034 const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
2035 const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
2036 const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
2038 TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
2039 for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){
2040 PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
2041 VISU::EGeometry aEGeom = aSubMeshIter->first;
2043 if(aGaussSubMesh->myIsDone)
2046 PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
2047 const TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
2048 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2050 MED::PPolygoneInfo aPolygoneInfo;
2051 MED::PPolyedreInfo aPolyedreInfo;
2052 MED::PCellInfo aCellInfo;
2053 MED::PElemInfo anElemInfo;
2056 case MED::ePOLYGONE:
2057 aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,
2060 anElemInfo = aPolygoneInfo;
2062 case MED::ePOLYEDRE:
2063 aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,
2066 anElemInfo = aPolyedreInfo;
2069 aCellInfo = theMed->GetPCellInfo(aMeshInfo,
2072 anElemInfo = aCellInfo;
2074 aGaussSubMesh->myIsElemNum = anElemInfo->IsElemNum();
2075 aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
2078 MED::TGaussCoord aGaussCoord;
2079 bool anIsGaussCoord3D = false;
2081 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
2082 if(aGaussIter != aGeom2Gauss.end()){
2083 PMEDGauss aGauss = aGaussSubMesh->myGauss;
2084 MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo;
2086 aName = aGaussInfo->GetName();
2087 if(!aSubMeshID.empty()){
2088 const std::string& aProfileName = aSubProfile->myName;
2089 MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2092 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2093 anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2100 anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
2106 if(!aSubMeshID.empty()){
2107 const std::string& aProfileName = aSubProfile->myName;
2108 MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
2111 const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
2113 case MED::ePOLYGONE:
2114 anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2119 case MED::ePOLYEDRE:
2120 anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2126 anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2134 case MED::ePOLYGONE:
2135 anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
2139 case MED::ePOLYEDRE:
2140 anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
2145 anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
2151 if(anIsGaussCoord3D){
2152 TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
2153 TInt aNbGauss = aGaussCoord.GetNbGauss();
2154 TInt aNbElem = aGaussCoord.GetNbElem();
2155 TInt aDim = aGaussCoord.GetDim();
2156 vtkIdType aNbCells = aNbElem*aNbGauss;
2157 aCoords.Init(aNbCells,aDim);
2158 for(TInt anElemId = 0, aNodeId = 0; anElemId < aNbElem; anElemId++){
2159 MED::TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId);
2160 for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aNodeId++){
2161 MED::TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
2162 TCoordSlice aSlice = aCoords.GetCoordSlice(aNodeId);
2163 for(TInt aDimId = 0; aDimId < aDim; aDimId++)
2164 aSlice[aDimId] = aCoordSlice[aDimId];
2168 aGaussSubMesh->myIsDone = true;;
2171 "- aEGeom = "<<aEGeom<<
2172 "; aName = '"<<aName<<"'"<<
2173 "; aStatus = "<<aGaussSubMesh->myStatus<<
2174 "; aNbElem = "<<aNbElem<<
2175 "; aNbGauss = "<<aNbGauss<<
2176 "; aNbCells = "<<aNbCells<<
2179 EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
2182 aGaussMesh->myIsDone = true;
2186 //---------------------------------------------------------------
2188 LoadValForTime(const MED::PWrapper& theMed,
2189 VISU::PMEDMesh theMesh,
2190 VISU::PMEDMeshOnEntity theMeshOnEntity,
2191 VISU::PMEDField theField,
2192 VISU::PMEDValForTime theValForTime,
2196 TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
2197 INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
2199 //Check on loading already done
2204 const std::string& aMeshName = theMeshOnEntity->myMeshName;
2205 const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
2206 MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,
2209 MED::TGeom2Size aGeom2Size;
2210 MED::EEntiteMaillage aMEntity;
2211 theMed->GetNbTimeStamps(aFieldInfo,
2212 theMesh->myEntityInfo,
2216 MED::PTimeStampInfo aTimeStampInfo =
2217 theMed->GetPTimeStampInfo(aFieldInfo,
2220 theValForTime->myId);
2222 MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
2223 MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
2225 MED::PTimeStampVal aTimeStampVal =
2226 theMed->GetPTimeStampVal(aTimeStampInfo,
2230 InitGaussProfile(theMed,
2245 LoadGaussMesh(theMed,
2251 PMEDProfile aProfile = theValForTime->myProfile;
2252 TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
2254 TInt aNbComp = theField->myNbComp;
2257 "- aMeshName = '"<<aMeshName<<"'"<<
2258 "; aFieldName = '"<<aFieldInfo->GetName()<<"'"<<
2259 "; aMEntity = "<<aMEntity<<
2260 "; aNbComp = "<<aNbComp<<
2263 theField->myDataSize = 0;
2265 const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
2266 TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
2267 for(; anIter != aGeom2SubProfile.end(); anIter++){
2268 VISU::EGeometry aEGeom = anIter->first;
2269 PMEDSubProfile aSubProfile(anIter->second);
2271 TInt aNbElem = aSubProfile->myNbCells;
2272 theField->myDataSize += aNbElem*aNbComp;
2274 if(aSubProfile->myStatus != eRemoveAll){
2275 TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
2278 "- aEGeom = "<<aEGeom<<
2279 "; aNbElem = "<<aNbElem<<
2280 "; aNbGauss = "<<aNbGauss<<
2283 TMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
2284 aVMeshValue.Init(aNbElem,aNbGauss,aNbComp);
2286 MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
2287 const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
2288 for(TInt iElem = 0; iElem < aNbElem; iElem++){
2289 TValueSliceArr aVValueSliceArr = aVMeshValue.GetGaussValueSliceArr(iElem);
2290 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
2291 ADDMSG(MYVALUEDEBUG,"{");
2292 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
2293 TValueSlice& aVValueSlice = aVValueSliceArr[iGauss];
2294 const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
2295 for(TInt iComp = 0; iComp < aNbComp; iComp++){
2296 aVValueSlice[iComp] = aMValueSlice[iComp];
2297 ADDMSG(MYVALUEDEBUG,aVValueSlice[iComp]<<" ");
2299 ADDMSG(MYVALUEDEBUG,"| ");
2301 ADDMSG(MYVALUEDEBUG,"} ");
2303 ADDMSG(MYDEBUG,"\n");
2313 //---------------------------------------------------------------
2316 ::LoadValForTimeOnMesh(const MED::PWrapper& theMed,
2317 VISU::PMEDMesh theMesh,
2318 VISU::PMEDMeshOnEntity theMeshOnEntity,
2319 VISU::PMEDField theField,
2320 VISU::PMEDValForTime theValForTime)
2322 PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
2323 return LoadValForTime(theMed,
2329 anIDMapperFilter->myIsVTKDone);
2333 //---------------------------------------------------------------
2336 ::LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
2337 VISU::PMEDMesh theMesh,
2338 VISU::PMEDMeshOnEntity theMeshOnEntity,
2339 VISU::PMEDField theField,
2340 VISU::PMEDValForTime theValForTime)
2342 PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
2343 return LoadValForTime(theMed,
2349 aGaussPtsIDFilter->myIsVTKDone);