#include "MED_Factory.hxx"
#include "MED_Algorithm.hxx"
+#include "MED_GaussUtils.hxx"
#include "MED_Utilities.hxx"
-#include <vtkCellType.h>
+#include "CASCatch.hxx"
-#define _EDF_NODE_IDS_
+#include <vtkCellType.h>
using namespace std;
-using namespace MED;
using namespace VISU;
+using MED::TInt;
+using MED::TFloat;
+using MED::EBooleen;
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+static int MY_FAMILY_DEBUG = 0;
+static int MY_GROUP_DEBUG = 0;
+//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+static int MY_FAMILY_DEBUG = 0;
+static int MY_GROUP_DEBUG = 0;
#endif
+#define _LOAD_FAMILIES_
+#define _EDF_NODE_IDS_
-namespace{
-
- using namespace MED;
- using namespace VISU;
-
- int MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
+namespace
+{
+ //---------------------------------------------------------------
+ vtkIdType
+ MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
{
return theMEDGeomType % 100;
}
- int MEDGeomToVTK(MED::EGeometrieElement theMEDGeomType)
- {
- switch(theMEDGeomType){
- case ePOINT1: return VTK_VERTEX;
- case eSEG2: return VTK_LINE;
- case eSEG3: return VTK_LINE;
- case eTRIA3: return VTK_TRIANGLE;
- case eTRIA6: return VTK_TRIANGLE;
- case eQUAD4: return VTK_QUAD;
- case eQUAD8: return VTK_QUAD;
- case eTETRA4: return VTK_TETRA;
- case eTETRA10: return VTK_TETRA;
- case eHEXA8: return VTK_HEXAHEDRON;
- case eHEXA20: return VTK_HEXAHEDRON;
- case ePENTA6: return VTK_WEDGE;
- case ePENTA15: return VTK_WEDGE;
- case ePYRA5: return VTK_PYRAMID;
- case ePYRA13: return VTK_PYRAMID;
- case ePOLYGONE: return VTK_POLYGON;
- case ePOLYEDRE: return VTK_CONVEX_POINT_SET;
- }
- return -1;
- }
- int VTKGeom2NbNodes(int theVTKGeomType)
+ //---------------------------------------------------------------
+ VISU::EGeometry
+ MEDGeom2VISU(MED::EGeometrieElement theGeom)
{
- switch(theVTKGeomType){
- case VTK_VERTEX: return 1;
- case VTK_LINE: return 2;
- case VTK_TRIANGLE: return 3;
- case VTK_QUAD: return 4;
- case VTK_TETRA: return 4;
- case VTK_HEXAHEDRON: return 8;
- case VTK_WEDGE: return 6;
- case VTK_PYRAMID: return 5;
+ switch(theGeom){
+ case MED::ePOINT1: return VISU::ePOINT1;
+ case MED::eSEG2: return VISU::eSEG2;
+ case MED::eTRIA3: return VISU::eTRIA3;
+ case MED::eQUAD4: return VISU::eQUAD4;
+ case MED::eTETRA4: return VISU::eTETRA4;
+ case MED::eHEXA8: return VISU::eHEXA8;
+ case MED::ePENTA6: return VISU::ePENTA6;
+ case MED::ePYRA5: return VISU::ePYRA5;
+
+ case MED::eSEG3: return VISU::eSEG3;
+ case MED::eTRIA6: return VISU::eTRIA6;
+ case MED::eQUAD8: return VISU::eQUAD8;
+ case MED::eTETRA10: return VISU::eTETRA10;
+ case MED::eHEXA20: return VISU::eHEXA20;
+ case MED::ePENTA15: return VISU::ePENTA15;
+ case MED::ePYRA13: return VISU::ePYRA13;
+
+ case MED::ePOLYGONE: return VISU::ePOLYGONE;
+ case MED::ePOLYEDRE: return VISU::ePOLYEDRE;
}
- return -1;
+ return VISU::eNONE;
}
- MED::EGeometrieElement VTKGeomToMED(int theVTKGeomType)
+
+ //---------------------------------------------------------------
+ MED::EGeometrieElement
+ VISUGeom2MED(int theGeom)
{
- switch(theVTKGeomType){
- case VTK_VERTEX: return ePOINT1;
- case VTK_LINE: return eSEG2;
- case VTK_TRIANGLE: return eTRIA3;
- case VTK_QUAD: return eQUAD4;
- case VTK_TETRA: return eTETRA4;
- case VTK_HEXAHEDRON: return eHEXA8;
- case VTK_WEDGE: return ePENTA6;
- case VTK_PYRAMID: return ePYRA5;
- case VTK_POLYGON: return ePOLYGONE;
- case VTK_CONVEX_POINT_SET: return ePOLYEDRE;
+ switch(theGeom){
+ case VISU::ePOINT1: return MED::ePOINT1;
+ case VISU::eSEG2: return MED::eSEG2;
+ case VISU::eTRIA3: return MED::eTRIA3;
+ case VISU::eQUAD4: return MED::eQUAD4;
+ case VISU::eTETRA4: return MED::eTETRA4;
+ case VISU::eHEXA8: return MED::eHEXA8;
+ case VISU::ePENTA6: return MED::ePENTA6;
+ case VISU::ePYRA5: return MED::ePYRA5;
+
+ case VISU::eSEG3: return MED::eSEG3;
+ case VISU::eTRIA6: return MED::eTRIA6;
+ case VISU::eQUAD8: return MED::eQUAD8;
+ case VISU::eTETRA10: return MED::eTETRA10;
+ case VISU::eHEXA20: return MED::eHEXA20;
+ case VISU::ePENTA15: return MED::ePENTA15;
+ case VISU::ePYRA13: return MED::ePYRA13;
+
+ case VISU::ePOLYGONE: return MED::ePOLYGONE;
+ case VISU::ePOLYEDRE: return MED::ePOLYEDRE;
}
- return EGeometrieElement(-1);
+ return MED::EGeometrieElement(-1);
}
- TEntity MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
+
+ //---------------------------------------------------------------
+ VISU::TEntity
+ MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
{
switch(theMEDEntity){
- case eNOEUD: return NODE_ENTITY;
- case eARETE: return EDGE_ENTITY;
- case eFACE: return FACE_ENTITY;
- case eMAILLE: return CELL_ENTITY;
+ case MED::eNOEUD: return NODE_ENTITY;
+ case MED::eARETE: return EDGE_ENTITY;
+ case MED::eFACE: return FACE_ENTITY;
+ case MED::eMAILLE: return CELL_ENTITY;
}
- return TEntity(-1);
+ return VISU::TEntity(-1);
}
- MED::EEntiteMaillage VTKEntityToMED(TEntity theVTKEntity)
+
+ //---------------------------------------------------------------
+ MED::EEntiteMaillage
+ VTKEntityToMED(TEntity theVTKEntity)
{
switch(theVTKEntity){
- case NODE_ENTITY: return eNOEUD;
- case EDGE_ENTITY: return eARETE;
- case FACE_ENTITY: return eFACE;
- case CELL_ENTITY: return eMAILLE;
+ case NODE_ENTITY: return MED::eNOEUD;
+ case EDGE_ENTITY: return MED::eARETE;
+ case FACE_ENTITY: return MED::eFACE;
+ case CELL_ENTITY: return MED::eMAILLE;
}
return MED::EEntiteMaillage(-1);
}
-}
-
-extern "C"
-VISU_Convertor* CreateConvertor(const string& theFileName)
-{
- return new VISU_MedConvertor(theFileName);
-}
-
-VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) {
- myFileInfo.setFile(QString(theFileName.c_str()));
- myName = myFileInfo.baseName().latin1();
-}
-VISU_Convertor* VISU_MedConvertor::Build() {
- PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1());
- TInt aNbMeshes = aMed->GetNbMeshes();
- TMeshMap& aMeshMap = myMeshMap;
+ //---------------------------------------------------------------
+ PMEDSubProfile
+ CrSubProfile(const MED::PWrapper& theMEDWrapper,
+ const MED::PMeshInfo& theMeshInfo,
+ MED::EEntiteMaillage theMEntity,
+ MED::EGeometrieElement theMGeom,
+ const MED::TGeom2Size& theGeom2Size,
+ const MED::TGeom2Profile& theGeom2Profile)
+ {
+ VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
+ vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
+
+ PMEDSubProfile aSubProfile(new TMEDSubProfile());
+ aSubProfile->myGeom = aEGeom;
+ aSubProfile->myMGeom = theMGeom;
+ aSubProfile->myStatus = eAddAll;
+
+ MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom);
+ if(aTimeStampIter == theGeom2Size.end())
+ aSubProfile->myStatus = eRemoveAll;
+ else{
+ MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom);
+ if(aProfileIter != theGeom2Profile.end()){
+ MED::PProfileInfo aProfileInfo = aProfileIter->second;
+
+ aSubProfile->myName = aProfileInfo->GetName();
+ aSubProfile->myStatus = eAddPart;
+
+ const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
+ TInt aNbElem = anElemNum.size();
+ aSubProfile->myNbCells = aNbElem;
+ switch(theMGeom){
+ case MED::ePOLYGONE: {
+ MED::PPolygoneInfo aPolygoneInfo =
+ theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
+ for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
+ TInt aNbConn = aPolygoneInfo->GetNbConn(anElemNum[anElemId]);
+ aSubProfile->myCellsSize += aNbConn;
+ }
+ break;
+ }
+ case MED::ePOLYEDRE: {
+ MED::PPolyedreInfo aPolyedreInfo =
+ theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
+ for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
+ MED::TCConnSliceArr aConnSliceArr =
+ aPolyedreInfo->GetConnSliceArr(anElemNum[anElemId]);
+ TInt aNbFaces = aConnSliceArr.size();
+ TInt aCellSize = 0;
+ for(TInt iFace = 0; iFace < aNbFaces; iFace++){
+ MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
+ TInt aNbConn = aConnSlice.size();
+ aCellSize += aNbConn;
+ }
+ aSubProfile->myCellsSize += aCellSize;
+ }
+ break;
+ }
+ default: {
+ aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
+ }}
+ }else{
+ TInt aNbElem = aTimeStampIter->second;
+ aSubProfile->myNbCells = aNbElem;
+ switch(theMGeom){
+ case MED::ePOLYGONE: {
+ MED::PPolygoneInfo aPolygoneInfo =
+ theMEDWrapper->GetPPolygoneInfo(theMeshInfo,theMEntity,theMGeom);
+ for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
+ TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
+ aSubProfile->myCellsSize += aNbConn;
+ }
+ break;
+ }
+ case MED::ePOLYEDRE: {
+ MED::PPolyedreInfo aPolyedreInfo =
+ theMEDWrapper->GetPPolyedreInfo(theMeshInfo,theMEntity,theMGeom);
+ for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
+ MED::TCConnSliceArr aConnSliceArr =
+ aPolyedreInfo->GetConnSliceArr(anElemId);
+ TInt aNbFaces = aConnSliceArr.size();
+ TInt aCellSize = 0;
+ for(TInt iFace = 0; iFace < aNbFaces; iFace++){
+ MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
+ TInt aNbConn = aConnSlice.size();
+ aCellSize += aNbConn;
+ }
+ aSubProfile->myCellsSize += aCellSize;
+ }
+ break;
+ }
+ default: {
+ aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
+ }}
+ }
+ }
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<theMGeom<<
+ "; aEGeom = "<<aEGeom<<
+ "; aName = '"<<aSubProfile->myName<<"'"<<
+ "; aStatus = "<<aSubProfile->myStatus<<
+ "; aNbCells = "<<aSubProfile->myNbCells<<
+ "; aCellsSize = "<<aSubProfile->myCellsSize<<
+ endl);
+
+ return aSubProfile;
+ }
- MSG(MYDEBUG,"VISU_MedConvertor::Build()");
- INITMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<"\n");
- for (TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++) {
- try {
- PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ //---------------------------------------------------------------
+ TProfileKey
+ GetProfileKey(const MED::PWrapper& theMEDWrapper,
+ const MED::PMeshInfo& theMeshInfo,
+ const MED::TTimeStampVal& theTimeStampVal,
+ const VISU::TMEDMeshOnEntity& theMeshOnEntity,
+ MED::EEntiteMaillage theMEntity,
+ const MED::TGeom2Size& theGeom2Size)
+ {
+ INITMSG(MYDEBUG,"GetProfileKey"<<endl);
+
+ TProfileKey aProfileKey;
+ const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
+
+ const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
+ MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
+ for(; anIter != aGeom2Size.end(); anIter++){
+ MED::EGeometrieElement aMGeom = anIter->first;
+ PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
+ theMeshInfo,
+ theMEntity,
+ aMGeom,
+ theGeom2Size,
+ aGeom2Profile);
+ aProfileKey.insert(aSubProfile);
+ }
+
+ return aProfileKey;
+ }
+
- PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
+ //---------------------------------------------------------------
+ void
+ InitProfile(const MED::PWrapper& theMEDWrapper,
+ const MED::PMeshInfo& theMeshInfo,
+ MED::TTimeStampVal& theTimeStampVal,
+ VISU::TMEDMeshOnEntity& theMeshOnEntity,
+ MED::EEntiteMaillage theMEntity,
+ const MED::TGeom2Size& theGeom2Size,
+ VISU::TMEDValForTime& theValForTime)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"InitProfile");
+ INITMSG(MYDEBUG,"InitProfile"<<endl);
- MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+ TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
- TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo);
+ TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
+ theMeshInfo,
+ theTimeStampVal,
+ theMeshOnEntity,
+ theMEntity,
+ theGeom2Size);
+
+ TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
+ if(anIter != aProfileMap.end()){
+ theValForTime.myProfile = anIter->second;
+ INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<<endl);
+ }else{
+ PMEDProfile aProfile(new TMEDProfile());
+ TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+
+ TProfileKey::const_iterator anIter = aProfileKey.begin();
+ for(; anIter != aProfileKey.end(); anIter++){
+ PMEDSubProfile aSubProfile(*anIter);
+
+ if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
+ aProfile->myIsAll = false;
- TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo);
+ VISU::EGeometry aEGeom = aSubProfile->myGeom;
+ aGeom2SubProfile[aEGeom] = aSubProfile;
+ }
+
+ aProfileMap[aProfileKey] = aProfile;
+ theValForTime.myProfile = aProfile;
+ }
+ }
- TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup);
- TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup);
+ //---------------------------------------------------------------
+ TGaussKey
+ GetGaussKey(const MED::TTimeStampVal& theTimeStampVal,
+ const VISU::TMEDMeshOnEntity& theMeshOnEntity,
+ const MED::TGeom2Size& theGeom2Size,
+ VISU::TMEDValForTime& theValForTime)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
+ INITMSG(MYDEBUG,"GetGaussKey"<<endl);
- // creating TMesh structure and TMeshOnEntityMap
- typedef map<TInt,TInt> TFamilyCounterMap;
- TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap;
+ TGaussKey aGaussKey;
+ PMEDProfile aProfile = theValForTime.myProfile;
+ TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TInt aDim = aMeshInfo->GetDim();
- const string& aMeshName = aMeshInfo->GetName();
-
- PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
- aMesh->myDim = aDim;
- aMesh->myName = aMeshName;
- aMesh->myNbPoints = aNodeInfo->GetNbElem();
- aMesh->myMeshInfo = aMeshInfo;
- aMesh->myEntityInfo = aEntityInfo;
-
- INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
- "'; myNbPoints = "<<aMesh->myNbPoints<<
- "; aDim = "<<aDim<<"\n");
+ const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
+ const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
+
+ const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
+ MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
+ for(; anIter != aGeom2Size.end(); anIter++){
+ MED::EGeometrieElement aMGeom = anIter->first;
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+
+ TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
+ if(anIter2 == aGeom2SubProfile.end()){
+ INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
+ continue;
+ }
+ PMEDSubProfile aSubProfile = anIter2->second;
+
+ MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
+ if(aTimeStampIter != theGeom2Size.end()){
+ TInt aNbCells = aTimeStampIter->second;
+ if(aSubProfile->myStatus == eAddPart)
+ aNbCells = aSubProfile->myNbCells;
+
+ PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
+ aGaussSubMesh->mySubProfile = aSubProfile;
+ aGaussSubMesh->myStatus = aSubProfile->myStatus;
+
+ PMEDGauss aGauss(new TMEDGauss());
+ aGaussSubMesh->myGauss = aGauss;
+ aGauss->myGeom = aEGeom;
+ aGauss->myNbPoints = 1;
+
+ MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
+ if(aGaussIter != aGeom2Gauss.end()){
+ MED::PGaussInfo aGaussInfo = aGaussIter->second;
+ aGauss->myGaussInfo = aGaussInfo;
+ aGauss->myName = aGaussInfo->GetName();
+ aGauss->myNbPoints = aGaussInfo->GetNbGauss();
+ }
+
+ aGaussSubMesh->myNbCells = aNbCells*aGauss->myNbPoints;
+ aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2;
+
+ aGaussKey.insert(aGaussSubMesh);
+
+ INITMSGA(MYDEBUG,0,
+ "- aEGeom = "<<aGauss->myGeom<<
+ "; aName = '"<<aGauss->myName<<"'"<<
+ "; aNbGauss = "<<aGauss->myNbPoints<<
+ "; aStatus = "<<aGaussSubMesh->myStatus<<
+ "; aNbCells = "<<aGaussSubMesh->myNbCells<<
+ "; aCellsSize = "<<aGaussSubMesh->myCellsSize<<
+ endl);
+ }
+ }
+
+ return aGaussKey;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ InitGaussMesh(MED::TTimeStampVal& theTimeStampVal,
+ VISU::TMEDMeshOnEntity& theMeshOnEntity,
+ const MED::TGeom2Size& theGeom2Size,
+ VISU::TMEDValForTime& theValForTime)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
+ INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
+
+ if(theMeshOnEntity.myEntity == NODE_ENTITY)
+ return;
+
+ TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
- BEGMSG(MYDEBUG,"aEntityInfo.size() = "<<aEntityInfo.size()<<"\n");
+ TGaussKey aGaussKey = GetGaussKey(theTimeStampVal,
+ theMeshOnEntity,
+ theGeom2Size,
+ theValForTime);
+
+ TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
+ if(anIter != aGaussMeshMap.end()){
+ theValForTime.myGaussMesh = anIter->second;
+ INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<<endl);
+ }else{
+ PMEDGaussMesh aGaussMesh(new TMEDGaussMesh());
+ TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ {
+ TGaussKey::const_iterator anIter = aGaussKey.begin();
+ for(; anIter != aGaussKey.end(); anIter++){
+ PMEDGaussSubMesh aGaussSubMesh(*anIter);
+ PMEDGauss aGauss = aGaussSubMesh->myGauss;
+ VISU::EGeometry aEGeom = aGauss->myGeom;
+ aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh;
+ }
+ }
+ {
+ TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
+ aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size());
+ TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){
+ const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
+ aGaussSubMeshArr[anID] = aGaussSubMesh;
+ }
+ }
+ INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<endl);
+ aGaussMeshMap[aGaussKey] = aGaussMesh;
+ theValForTime.myGaussMesh = aGaussMesh;
+ }
+ }
+
- TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
- for(; anEntityIter != aEntityInfo.end(); anEntityIter++){
- const EEntiteMaillage& aMEntity = anEntityIter->first;
- const MED::TGeom& aTGeom = anEntityIter->second;
+ //---------------------------------------------------------------
+ void
+ InitGaussProfile(const MED::PWrapper& theMEDWrapper,
+ const MED::PMeshInfo& theMeshInfo,
+ MED::TTimeStampVal& theTimeStampVal,
+ VISU::TMEDMeshOnEntity& theMeshOnEntity,
+ MED::EEntiteMaillage theMEntity,
+ const MED::TGeom2Size& theGeom2Size,
+ VISU::TMEDValForTime& theValForTime)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile");
+ INITMSG(MYDEBUG,"InitGaussProfile"<<endl);
+
+ // The order of the function calls is important
+ InitProfile(theMEDWrapper,
+ theMeshInfo,
+ theTimeStampVal,
+ theMeshOnEntity,
+ theMEntity,
+ theGeom2Size,
+ theValForTime);
+
+ InitGaussMesh(theTimeStampVal,
+ theMeshOnEntity,
+ theGeom2Size,
+ theValForTime);
+ }
+
+ //---------------------------------------------------------------
+ void
+ BuildMeshOnEntityMap(PMEDMesh theMesh,
+ const MED::TEntityInfo& theEntityInfo,
+ const MED::PNodeInfo& theNodeInfo,
+ const MED::PWrapper& theMEDWrapper)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
+ INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
+
+ MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
+ const std::string& aMeshName = theMesh->myName;
+ TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
+ for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
+ const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
+ const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
+
TEntity aVEntity = MEDEntityToVTK(aMEntity);
PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity());
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myMeshName = aMeshName;
- aMeshOnEntity->myGeom = aTGeom;
-
- INITMSG(MYDEBUG,"aMEntity = "<<aMEntity<<"; aVEntity = "<<aVEntity<<"\n");
+ aMeshOnEntity->myGeom2Size = aGeom2Size;
+ TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
- if(aMEntity == eNOEUD){
- aMeshOnEntity->myNbCells = aMesh->myNbPoints;
- aMeshOnEntity->myCellsSize = 2*aMesh->myNbPoints;
+ INITMSG(MYDEBUG,
+ "- aMEntity = "<<aMEntity<<
+ "; aVEntity = "<<aVEntity<<
+ endl);
+
+ if(aMEntity == MED::eNOEUD){
+ aMeshOnEntity->myNbCells = theMesh->myNbPoints;
+ aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
- for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){
- TInt aFamId = aNodeInfo->GetFamNum(iElem);
- if(aFamId != 0){
- aFamilyNbCellsCounterMap[aFamId] += 1;
- aFamilyCellsSizeCounterMap[aFamId] += 2;
- }
+ for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
+ TInt aFamId = theNodeInfo->GetFamNum(iElem);
+ if(aFamId != 0)
+ aFamilyID2CellsSize[aFamId] += 2;
}
-
- INITMSG(MYDEBUG,"myNbCells = "<<aMeshOnEntity->myNbCells<<
- "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");;
-
+
+ INITMSG(MYDEBUG,
+ "- myNbCells = "<<aMeshOnEntity->myNbCells<<
+ "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
+ endl);;
+
}else{
- MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
+ MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
aMeshOnEntity->myNbCells = 0;
aMeshOnEntity->myCellsSize = 0;
- for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
- const EGeometrieElement& aGeom = anTGeomIter->first;
-
- switch(aGeom){
- case ePOLYGONE:
- {
- PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aPolygoneInfo->GetNbElem();
- TElemNum aConn = aPolygoneInfo->GetConnectivite();
- TElemNum aIndex = aPolygoneInfo->GetIndex();
- TInt aNbIndex = aIndex.size();
- TInt aNbConn = aConn.size();
-
- aMeshOnEntity->myNbCells += aNbElem;
-
- for (int ii = 0; ii<aNbElem ; ii++){
- int aNbConnii = aPolygoneInfo->GetNbConn(ii);
- aMeshOnEntity->myCellsSize += aNbConnii;
- }
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
- "; myNbPolygones = "<<aNbElem<<
- "; nbConn= "<<aNbConn<<"\n");
-
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TInt aFamId = aPolygoneInfo->GetFamNum(iElem);
- if(aFamId != 0){
- aFamilyNbCellsCounterMap[aFamId] += 1;
- ADDMSG(MYDEBUG,"aFamId="<<aFamId<<" ");
- aFamilyCellsSizeCounterMap[aFamId] += aPolygoneInfo->GetNbConn(iElem) + 1;
- }
- }
- ADDMSG(MYDEBUG,endl);
- break;
- }
- case ePOLYEDRE:
- {
- PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aPolyedreInfo->GetNbElem();
- TElemNum aConn = aPolyedreInfo->GetConnectivite();
- TElemNum aIndex = aPolyedreInfo->GetIndex();
- TInt aNbIndex = aIndex.size();
- TInt aNbConn = aConn.size();
-
- aMeshOnEntity->myNbCells += aNbElem;
-
- for (int ii = 0; ii<aNbElem ; ii++){
- int aNbConnii = aPolyedreInfo->GetNbConn(ii);
- aMeshOnEntity->myCellsSize += aNbConnii;
- }
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
- "; myNbPolyedres = "<<aNbElem<<
- "; nbConn= "<<aNbConn<<"\n");
-
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TInt aFamId = aPolyedreInfo->GetFamNum(iElem);
- std::string aName = aPolyedreInfo->GetElemName(iElem);
- if(aFamId != 0){
- aFamilyNbCellsCounterMap[aFamId] += 1;
- ADDMSG(MYDEBUG,"(aFamId="<<aFamId<<";Name='"<<aName<<"') ");
- aFamilyCellsSizeCounterMap[aFamId] += aPolyedreInfo->GetNbConn(iElem) + 1;
- }
- }
- ADDMSG(MYDEBUG,endl);
- break;
+ for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
+ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
+
+ switch(aMGeom){
+ case MED::ePOLYGONE: {
+ MED::PPolygoneInfo aPolygoneInfo = theMEDWrapper->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
+ TInt aNbElem = aPolygoneInfo->GetNbElem();
+
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<aMGeom<<
+ "; aNbElem = "<<aNbElem<<
+ endl);
+
+ aMeshOnEntity->myNbCells += aNbElem;
+ for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
+ TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
+ aMeshOnEntity->myCellsSize += aNbConn;
+ TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
+ if(aFamId != 0)
+ aFamilyID2CellsSize[aFamId] += aNbConn + 1;
}
- default:
- {
- int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom));
- PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aCellInfo->GetNbElem();
- aMeshOnEntity->myNbCells += aNbElem;
- aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
- "; myNbCells = "<<aMeshOnEntity->myNbCells<<
- "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");
-
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TInt aFamId = aCellInfo->GetFamNum(iElem);
- if(aFamId != 0){
- aFamilyNbCellsCounterMap[aFamId] += 1;
- ADDMSG(MYDEBUG,"aFamId = "<<aFamId<<" ");
- aFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1;
- }
+ break;
+ }
+ case MED::ePOLYEDRE: {
+ MED::PPolyedreInfo aPolyedreInfo = theMEDWrapper->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
+ TInt aNbElem = aPolyedreInfo->GetNbElem();
+
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<aMGeom<<
+ "; aNbElem = "<<aNbElem<<
+ endl);
+
+ aMeshOnEntity->myNbCells += aNbElem;
+ for(TInt anElemId = 0; anElemId < aNbElem ; anElemId++){
+ MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(anElemId);
+ TInt aNbFaces = aConnSliceArr.size();
+ TInt aCellSize = 0;
+ for(TInt iFace = 0; iFace < aNbFaces; iFace++){
+ MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
+ TInt aNbConn = aConnSlice.size();
+ aCellSize += aNbConn;
}
- ADDMSG(MYDEBUG,endl);
+ aMeshOnEntity->myCellsSize += aCellSize;
+ TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
+ if(aFamId != 0)
+ aFamilyID2CellsSize[aFamId] += aCellSize + 1;
+ }
+ break;
+ }
+ default: {
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
+ MED::PCellInfo aCellInfo = theMEDWrapper->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
+ TInt aNbElem = aCellInfo->GetNbElem();
+ aMeshOnEntity->myNbCells += aNbElem;
+ aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
+
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<aMGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; myNbCells = "<<aMeshOnEntity->myNbCells<<
+ "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
+ endl);
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ TInt aFamId = aCellInfo->GetFamNum(iElem);
+ if(aFamId != 0)
+ aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
}
- } // end switch(...)
+ }} // end switch(...)
}
}
}
-
- TFamilyByEntity::const_iterator aFamilyByEntityIter = aFamilyByEntity.begin();
- BEGMSG(MYDEBUG,"TFamilyByEntity:\n");
- for(; aFamilyByEntityIter != aFamilyByEntity.end(); aFamilyByEntityIter++){
- const EEntiteMaillage& aMEntity = aFamilyByEntityIter->first;
- const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second;
+ }
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
- VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+
+ //---------------------------------------------------------------
+ void
+ BuildFieldMap(PMEDMesh theMesh,
+ const MED::TEntityInfo& theEntityInfo,
+ MED::PWrapper theMEDWrapper)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
+ TInt aNbFields = theMEDWrapper->GetNbFields();
+ MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
+ const std::string& aMeshName = theMesh->myName;
+ INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
+ for(TInt iField = 1; iField <= aNbFields; iField++){
+ TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
+ MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
+ TInt aNbComp = aFieldInfo->GetNbComp();
+ std::string aFieldName = aFieldInfo->GetName();
- if(aFamilyGroup.empty())
+ MED::TGeom2Size aGeom2Size;
+ MED::EEntiteMaillage aMEntity;
+ TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
+ theEntityInfo,
+ aMEntity,
+ aGeom2Size);
+ if(aNbTimeStamps < 1)
continue;
+
+ TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ PMEDField aField = aFieldMap[aFieldName](new TMEDField());
+ aField->myId = iField;
+ aField->InitArrays(aNbComp);
+ aField->myEntity = aVEntity;
+ aField->myName = aFieldName;
+ aField->myMeshName = aMeshName;
+ aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
+
+ INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
+ "; myId = "<<aField->myId<<
+ "; myEntity = "<<aField->myEntity<<
+ "; myDataSize = "<<aField->myDataSize<<
+ "; myNbComp = "<<aField->myNbComp<<"\n");
+
+ for(TInt iComp = 0; iComp < aNbComp; iComp++){
+ aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp);
+ aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp);
+ }
+
+ for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
+ TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
+ MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
+ aMEntity,
+ aGeom2Size,
+ iTimeStamp);
+ TFloat aDt = aTimeStampInfo->GetDt();
+ std::string anUnitDt = aTimeStampInfo->GetUnitDt();
+
+ TValField& aValField = aField->myValField;
+ PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
+ aValForTime->myId = iTimeStamp;
+ aValForTime->myFieldName = aField->myName;
+ aValForTime->myEntity = aField->myEntity;
+ aValForTime->myMeshName = aField->myMeshName;
+ aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
+ INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
+
+ TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
+ const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss;
+ MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
+ for(; anIter != aMGeom2NbGauss.end(); anIter++){
+ const MED::EGeometrieElement& aMGeom = anIter->first;
+ EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ TInt aNbGauss = anIter->second;
+ aVGeom2NbGauss[aEGeom] = aNbGauss;
+ }
+ }
+ }
+ }
+
- INITMSG(MYDEBUG,"aMEntity = "<<aMEntity<<"; aVEntity = "<<aVEntity<<"\n");
- TFamilyGroup::const_iterator aFamilyGroupIter = aFamilyGroup.begin();
- for(; aFamilyGroupIter != aFamilyGroup.end(); aFamilyGroupIter++){
- const PFamilyInfo& aFamilyInfo = *aFamilyGroupIter;
- if (aFamilyInfo->GetId() == 0)
+ //---------------------------------------------------------------
+ void
+ BuildFamilyMap(PMEDMesh theMesh,
+ const MED::TEntityInfo& theEntityInfo,
+ const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
+ const MED::TFamilyInfoSet& theFamilyInfoSet,
+ MED::PWrapper theMEDWrapper)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
+ INITMSG(MYDEBUG,"BuildFamilyMap\n");
+
+ MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
+ MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
+ MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
+ for(; aEntity2FamilySetIter != aEntity2FamilySet.end(); aEntity2FamilySetIter++){
+ const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
+ const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
+
+ TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+ TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+
+ if(aFamilyTSizeSet.empty())
+ continue;
+
+ INITMSG(MY_FAMILY_DEBUG,
+ "- aMEntity = "<<aMEntity<<
+ "; aVEntity = "<<aVEntity<<
+ endl);
+
+ MED::TFamilyTSizeSet::const_iterator aFamilyTSizeSetIter = aFamilyTSizeSet.begin();
+ for(; aFamilyTSizeSetIter != aFamilyTSizeSet.end(); aFamilyTSizeSetIter++){
+ const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
+ const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
+ TInt aSize = boost::get<1>(aFamilyTSize);
+ TInt anId = aFamilyInfo->GetId();
+ if(anId == 0)
continue;
+
+ std::string aFamilyName = aFamilyInfo->GetName();
- const std::string& aFamilyName = aFamilyInfo->GetName();
PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
-
- aFamily->myId = aFamilyInfo->GetId();
- aFamily->myName = aFamilyInfo->GetName();
+ aFamily->myId = anId;
aFamily->myEntity = aVEntity;
- aFamily->myNbCells = aFamilyNbCellsCounterMap[aFamily->myId];
- aFamily->myCellsSize = aFamilyCellsSizeCounterMap[aFamily->myId];
+ aFamily->myName = aFamilyName;
+ aFamily->myNbCells = aSize;
+
+ aFamily->myCellsSize = 0;
+ TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
+ if(anIter != aFamilyID2CellsSize.end())
+ aFamily->myCellsSize = anIter->second;
- INITMSG(MYDEBUG,"aFamilyName = '"<<aFamily->myName<<
- "'; myId = "<<aFamily->myId<<"; "<<
+ INITMSG(MY_FAMILY_DEBUG,
+ "- aFamilyName = '"<<aFamilyName<<"'"<<
+ "; myId = "<<aFamily->myId<<"; "<<
"; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
"; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
- "; myEntity = "<<aFamily->myEntity<<
+ "; aVEntity = "<<aVEntity<<
"; myNbCells = "<<aFamily->myNbCells<<
- "; myCellsSize = "<<aFamily->myCellsSize<<"\n");
-
- VISU::TBindGroups& aBindGroups = aFamily->myGroups;
+ "; myCellsSize = "<<aFamily->myCellsSize<<
+ endl);
+#ifdef _DEBUG_
const TInt aNbGroup = aFamilyInfo->GetNbGroup();
for(TInt i = 0; i < aNbGroup; i++){
- const string& aGroupName = aFamilyInfo->GetGroupName(i);
- aBindGroups.insert(aGroupName);
- INITMSG(MYDEBUG,"aGroupName = '"<<aGroupName<<"'\n");
+ std::string aGroupName = aFamilyInfo->GetGroupName(i);
+ INITMSG(MY_FAMILY_DEBUG,"- aGroupName = '"<<aGroupName<<"'\n");
}
+#endif
+
}
}
-
- BEGMSG(MYDEBUG,"VISU::TGroup:\n");
+ }
- VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
- TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
- for(;aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
- const string& aGroupName = aGroupInfoIter->first;
- const TFamilyGroup& aFamilyGroup = aGroupInfoIter->second;
- PMEDGroup aGroup(new TMEDGroup());
- aGroup->myName = aGroupName;
- aGroup->myMeshName = aMesh->myName;
- INITMSG(MYDEBUG,"aGroup->myName = '"<<aGroup->myName<<"'\n");
+ //---------------------------------------------------------------
+ void
+ BuildGroupMap(PMEDMesh theMesh,
+ const MED::TFamilyInfoSet& theFamilyInfoSet)
+ {
+ TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
+ INITMSG(MYDEBUG,"BuildGroupMap\n");
+
+ TGroupMap& aGroupMap = theMesh->myGroupMap;
+ MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
+ MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
+ for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
+ const std::string& aGroupName = aGroupInfoIter->first;
+ INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
- TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin();
- for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){
- const PFamilyInfo& aFamilyInfo = *aFamilyIter;
- const string& aFamilyName = aFamilyInfo->GetName();
+ PMEDGroup aGroup(new TMEDGroup());
+ TFamilySet& aFamilySet = aGroup->myFamilySet;
+ const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
+ MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
+ for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
+ const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
+ std::string aFamilyName = aFamilyInfo->GetName();
+
TEntity aVEntity = TEntity(-1);
- PFamily aFamily;
-
+ PMEDFamily aFamily;
+
// Find aVisuEntity
- const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
- for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
- const string& aName = aFamilyMapIter->first;
+ for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+ const std::string& aName = aFamilyMapIter->first;
aFamily = aFamilyMapIter->second;
if(aName == aFamilyName){
aVEntity = aFamily->myEntity;
goto exit_lable;
}
}
- }
+ }
exit_lable:
if(aFamily && aVEntity >= 0){
- aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity));
- INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyName<<"'; '"<<aFamily->myName<<"'; aVEntity = "<<aVEntity<<"\n");
-
- aGroup->myNbCells += aFamily->myNbCells;
- aGroup->myCellsSize += aFamily->myCellsSize;
+ aFamilySet.insert(aFamily);
+ INITMSG(MY_GROUP_DEBUG,
+ "- aFamilyName = '"<<aFamilyName<<"'"<<
+ "; aVEntity = "<<aVEntity<<
+ "\n");
}
}
- if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){
- BEGMSG(MYDEBUG,"myNbCells = "<<aGroup->myNbCells<<
- "; myCellsSize = "<<aGroup->myCellsSize<<"\n\n");
+ if(!aFamilySet.empty())
aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
- }
}
-
- TInt aNbFields = aMed->GetNbFields();
- BEGMSG(MYDEBUG,"VISU::TField: NbFields="<<aNbFields<<"\n");
- for(TInt iField = 1; iField <= aNbFields; iField++){
- PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
- TInt aNbComp = aFieldInfo->GetNbComp();
- const string& aFieldName = aFieldInfo->GetName();
+ }
- MED::TErr anErr;
- MED::TGeom aTGeom;
- EEntiteMaillage aMEntity;
- TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom,&anErr);
- if (anErr < 0 || aNbTimeStamps < 1)
- continue;
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- VISU::PMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- PMEDField aField = aFieldMap[aFieldName](new TMEDField());
- aField->myId = iField;
- aField->myNbComp = aNbComp;
- aField->myEntity = aVEntity;
- aField->myName = aFieldName;
- aField->myMeshName = aMeshName;
- aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
- aField->myCompNames.resize(aNbComp);
- aField->myUnitNames.resize(aNbComp);
+ //---------------------------------------------------------------
+ void
+ TMEDNamedPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const MED::PNodeInfo& theNodeInfo)
+ {
+ if(theNodeInfo->IsElemNum())
+ TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
+ else
+ TNamedPointCoords::Init(theNbPoints,theDim);
+ if(theNodeInfo->IsElemNames())
+ myNodeInfo = theNodeInfo;
+ }
- INITMSG(MYDEBUG,"myName = '"<<aField->myName<<
- "'; myId = "<<aField->myId<<
- "; myEntity = "<<aField->myEntity<<
- "; myDataSize = "<<aField->myDataSize<<
- "; myNbComp = "<<aField->myNbComp<<"\n");
+ std::string
+ TMEDNamedPointCoords
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ if(myNodeInfo)
+ return myNodeInfo->GetElemName(theObjID);
+ return TNamedPointCoords::GetNodeName(theObjID);
+ }
- for(TInt iComp = 0; iComp < aNbComp; iComp++){
- aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp);
- aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp);
- }
- for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
- PTimeStampInfo aTimeStamp = aMed->GetPTimeStampInfo(aFieldInfo,
- aMEntity,
- aTGeom,
- iTimeStamp,
- &anErr);
- if (anErr < 0)
- continue;
-
- TFloat aDt = aTimeStamp->GetDt();
- const string& anUnitDt = aTimeStamp->GetUnitDt();
- PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp,&anErr);
- TValField& aValField = aField->myValField;
- PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
- aValForTime->myId = iTimeStamp;
- aValForTime->myFieldName = aField->myName;
- aValForTime->myEntity = aField->myEntity;
- aValForTime->myMeshName = aField->myMeshName;
- aValForTime->myNbComp = aField->myNbComp;
- aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
- INITMSG(MYDEBUG,"aDt = "<<aDt<<", "<<anUnitDt<<"\n");
+ //---------------------------------------------------------------
+ vtkIdType
+ TMEDSubProfile
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ if(myIsElemNum)
+ return myElemNum[theID];
+ else
+ return theID;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TMEDGauss
+ ::LessThan(const PGaussImpl& theGauss,
+ bool& theResult) const
+ {
+ TGaussImpl::LessThan(theGauss,theResult);
+ if(myGaussInfo){
+ if(PMEDGauss aGauss = theGauss){
+ const MED::TGaussInfo& aLeft = myGaussInfo;
+ const MED::TGaussInfo& aReight = aGauss->myGaussInfo;
+ theResult = MED::TGaussInfo::TLess()(aLeft,aReight);
}
}
- } catch (std::runtime_error& exc){
- MSG(MYDEBUG,"Follow exception wqs occured in:\n"<<exc.what());
- } catch(...){
- EXCEPTION(runtime_error,"Unknown exception !!!");
}
+
+
+ //---------------------------------------------------------------
+ TGaussPointID
+ TMEDGaussSubMesh
+ ::GetObjID(vtkIdType theID,
+ vtkIdType theStartID) const
+ {
+ TCellID aCellID = theID / myGauss->myNbPoints;
+ TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
+
+ if(myIsElemNum)
+ aCellID = myElemNum[aCellID];
+ else
+ aCellID += theStartID;
+
+ return TGaussPointID(aCellID,aLocalPntID);
}
+
- return this;
-}
+ //---------------------------------------------------------------
+ void
+ TMEDSubMesh
+ ::Init(const MED::PElemInfo& theElemInfo)
+ {
+ myIsElemNum = theElemInfo->IsElemNum();
-int VISU_MedConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
- const string& theFamilyName)
-{
- PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1());
- const string& aMeshName = theMeshOnEntity->myMeshName;
- const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
- PMeshImpl aMesh = myMeshMap[aMeshName];
- int isPointsUpdated;
- if(anEntity == VISU::NODE_ENTITY)
- isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName);
- else
- isPointsUpdated = LoadPoints(aMed,aMesh);
- int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,aMesh,theMeshOnEntity,theFamilyName);
+ if(myIsElemNum)
+ myElemNum = theElemInfo->myElemNum;
- return (isPointsUpdated || isCellsOnEntityUpdated);
-}
+ if(theElemInfo->IsElemNames())
+ myElemInfo = theElemInfo;
+ }
-int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
- const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
-{
- PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1());
- int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
- VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
- for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
- const string& aFamilyName = aFamilyAndEntitySetIter->first;
- const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second;
- const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
- if(anEntity == VISU::NODE_ENTITY){
- isPointsUpdated += LoadPoints(aMed,theMesh,aFamilyName);
- isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity);
- }else{
- isPointsUpdated += LoadPoints(aMed,theMesh);
- isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity,aFamilyName);
- }
+ vtkIdType
+ TMEDSubMesh
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ if(myIsElemNum)
+ return myElemNum[theID];
+ else
+ return TSubMeshImpl::GetElemObjID(theID);
}
- return (isPointsUpdated || isCellsOnEntityUpdated);
+ std::string
+ TMEDSubMesh
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ if(myElemInfo)
+ return myElemInfo->GetElemName(theObjID);
+ return TSubMeshImpl::GetElemName(theObjID);
+ }
+
+ struct TSetIsDone
+ {
+ bool& myIsDone;
+ TSetIsDone(bool& theIsDone):
+ myIsDone(theIsDone)
+ {}
+
+ ~TSetIsDone()
+ {
+ myIsDone = true;
+ }
+
+ };
}
-int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh,
- VISU::PMeshOnEntityImpl theMeshOnEntity,
- VISU::PFieldImpl theField,
- VISU::PValForTimeImpl theValForTime)
+
+//---------------------------------------------------------------
+extern "C"
+VISU_Convertor*
+CreateConvertor(const string& theFileName)
{
- PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1());
- int isPointsUpdated = LoadPoints(aMed,theMesh);
- int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
- int isFieldUpdated = LoadField(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
-
- return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
+ if(MED::PWrapper aMed = MED::CrWrapper(theFileName,true))
+ return new VISU_MedConvertor(theFileName);
+ return NULL;
}
-
-int
-VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed,
- VISU::PMEDMesh theMesh,
- const string& theFamilyName)
+VISU_MedConvertor
+::VISU_MedConvertor(const string& theFileName):
+ myIsEntitiesDone(false),
+ myIsFieldsDone(false),
+ myIsGroupsDone(false),
+ myIsMinMaxDone(false)
{
- try{
- //Check on existing family
- VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
- aMeshOnEntity->myEntity = VISU::NODE_ENTITY;
- aMeshOnEntity->myMeshName = theMesh->myName;
- PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName);
- //Check on loading already done
- bool isPointsLoaded = !theMesh->myPointsCoord.empty();
- if(isPointsLoaded)
- if(!aFamily)
- return 0;
- else if(!aFamily->mySubMesh.empty())
- return 0;
+ myFileInfo.setFile(QString(theFileName.c_str()));
+ myName = myFileInfo.baseName().latin1();
+}
- INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'\n");
- //Main part of code
- PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
- TInt aNbElem = aNodeInfo->GetNbElem();
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildEntities()
+{
+ if(myIsEntitiesDone)
+ return this;
+
+ TSetIsDone aSetIsDone(myIsEntitiesDone);
+ TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
- if(!isPointsLoaded){
- VISU::TMeshImpl::TPointsDim& aPointsDim = theMesh->myPointsDim;
- aPointsDim.resize(theMesh->myDim);
- for(int iDim = 0; iDim < theMesh->myDim; iDim++)
- aPointsDim[iDim] = aNodeInfo->GetCoordName(iDim);
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+ TInt aDim = aMeshInfo->GetDim();
+
+ MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
+
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
- VISU::TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
- aPointsCoord.resize(aNbElem*theMesh->myDim);
- for (int iElem = 0; iElem < aNbElem; iElem++)
- for(int iDim = 0, iElem2Dim = iElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iElem2Dim++)
- aPointsCoord[iElem2Dim] = aNodeInfo->GetNodeCoord(iElem,iDim);
+ // creating TMesh structure and TMeshOnEntityMap
+ PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
+ aMesh->myDim = aDim;
+ aMesh->myName = aMeshName;
+ aMesh->myNbPoints = aNodeInfo->GetNbElem();
+ aMesh->myMeshInfo = aMeshInfo;
+ aMesh->myEntityInfo = anEntityInfo;
+ aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
+
+ INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
+ "'; myNbPoints = "<<aMesh->myNbPoints<<
+ "; aDim = "<<aDim<<"\n");
+
+#ifndef _DEXCEPT_
+ try{
+#endif
+ BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
+
+ BuildMeshOnEntityMap(aMesh,
+ anEntityInfo,
+ aNodeInfo,
+ aMed);
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildFields()
+{
+ if(myIsFieldsDone)
+ return this;
+
+ TSetIsDone aSetIsDone(myIsFieldsDone);
+ TTimerLog aTimerLog(MYDEBUG,"BuildFields");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+
+ TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ if(anIter == aMeshMap.end())
+ continue;
+ PMEDMesh aMesh = anIter->second;
+
+ INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
+#ifndef _DEXCEPT_
+ try{
+#endif
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
+ BuildFieldMap(aMesh,
+ anEntityInfo,
+ aMed);
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildMinMax()
+{
+ if(myIsMinMaxDone)
+ return this;
+
+ TSetIsDone aSetIsDone(myIsMinMaxDone);
+ TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
+ MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
- VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX];
- aConnForCellType.resize(aNbElem);
- for (int iElem = 0; iElem < aNbElem; iElem++)
- aConnForCellType[iElem] = VISU::TMeshOnEntityImpl::TConnect(1,iElem);
+ TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ if(anIter == aMeshMap.end())
+ continue;
+ PMEDMesh aMesh = anIter->second;
+
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TInt aNbFields = aMed->GetNbFields();
+
+ INITMSG(MYDEBUG,
+ "- aMeshName = '"<<aMeshName<<"'"<<
+ "; aNbFields = "<<aNbFields<<"\n");
+
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
+ for(TInt iField = 1; iField <= aNbFields; iField++){
+ TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
+ MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
+ std::string aFieldName = aFieldInfo->GetName();
+ INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
+
+ MED::TGeom2Size aGeom2Size;
+ MED::EEntiteMaillage aMEntity;
+ TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,
+ anEntityInfo,
+ aMEntity,
+ aGeom2Size);
+ if(aNbTimeStamps < 1)
+ continue;
+
+ TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
+ TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ PMEDField aField = aFieldMap[aFieldName];
+
+ TInt aNbComp = aField->myNbComp;
+ int aNbComp2 = aNbComp;
+ if(aNbComp == 2 || aNbComp == 4)
+ aNbComp2 = 2;
+ else if(aNbComp > 4)
+ aNbComp2 = 3;
+
+ TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
+ TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
+ for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
+ TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
+ INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
+
+#ifndef _DEXCEPT_
+ CASCatch_TRY{
+ try{
+#endif
+ MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
+ aMEntity,
+ aGeom2Size,
+ iTimeStamp);
+
+ MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
+ aMKey2Profile,
+ aKey2Gauss);
+
+ const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
+
+ const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
+
+ const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
+ MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const MED::TMeshValue& aMMeshValue = anIter->second;
+ MED::EGeometrieElement aMGeom = anIter->first;
+
+ TInt aNbElem = aMMeshValue.myNbElem;
+ TInt aNbGauss = aMMeshValue.myNbGauss;
+
+ MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
+ if(aGaussIter == aGeom2Gauss.end())
+ aNbGauss = 1;
+
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<aMGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ // To calculate min/max per components
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+ for(TInt iComp = 0; iComp < aNbComp; iComp++){
+ const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
+ TMinMax& aMinMax = aMinMaxArr[iComp+1];
+ float& aMin = aMinMax.first;
+ float& aMax = aMinMax.second;
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const float& aVal = aMValueSlice[iGauss];
+ aMin = min(aMin,aVal);
+ aMax = max(aMax,aVal);
+ }
+ }
+ }
+
+ // To calculate min/max per vector modulus
+ TMinMax& aMinMax = aMinMaxArr[0];
+ float& aMin = aMinMax.first;
+ float& aMax = aMinMax.second;
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+ float aValue = 0.0;
+ for(TInt iComp = 0; iComp < aNbComp2; iComp++){
+ float aVal = aMValueSlice[iComp];
+ aValue += aVal*aVal;
+ }
+ aValue = sqrt(aValue);
+ aMin = min(aMin,aValue);
+ aMax = max(aMax,aValue);
+ }
+ }
+ }
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+ }CASCatch_CATCH(Standard_Failure){
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
+ }
+#endif
+ }
+ for(TInt iComp = 0; iComp <= aNbComp; iComp++){
+ VISU::TMinMax aMinMax = aField->GetMinMax(iComp);
+ INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
+ }
+ }
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
}
- if(aFamily && aNbElem > 0){
- VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX];
- for (int iElem = 0; iElem < aNbElem; iElem++)
- if(aNodeInfo->GetFamNum(iElem) == aFamily->myId)
- aSubMeshOnCellType.insert(iElem);
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildGroups()
+{
+ if(myIsGroupsDone)
+ return this;
+
+ TSetIsDone aSetIsDone(myIsGroupsDone);
+ TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+
+ TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ if(anIter == aMeshMap.end())
+ continue;
+ PMEDMesh aMesh = anIter->second;
+
+ INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
+
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
+ MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
+ MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo);
+
+#ifndef _DEXCEPT_
+ try{
+#endif
+ MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo);
+
+ BuildFamilyMap(aMesh,
+ anEntityInfo,
+ anEntity2TGeom2ElemInfo,
+ aFamilyInfoSet,
+ aMed);
+
+ BuildGroupMap(aMesh,
+ aFamilyInfoSet);
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
+ INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
+
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+ const TEntity& anEntity = theMeshOnEntity->myEntity;
+
+ int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
+ if(anEntity == NODE_ENTITY){
+ isPointsUpdated += LoadPoints(aMed,theMesh);
+ }else{
+ isPointsUpdated += LoadPoints(aMed,theMesh);
+ isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
+ }
+
+ return (isPointsUpdated || isCellsOnEntityUpdated);
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFamilyImpl theFamily)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
+ INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
+
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+ const TEntity& anEntity = theMeshOnEntity->myEntity;
+
+ int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
+ if(anEntity == NODE_ENTITY){
+ isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily);
+ }else{
+ isPointsUpdated += LoadPoints(aMed,theMesh);
+ isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,theMeshOnEntity,theFamily);
+ }
+
+ return (isPointsUpdated || isCellsOnEntityUpdated);
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
+ const VISU::TFamilySet& theFamilySet)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
+ INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
+
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+ int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
+ TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
+ for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
+ PMEDFamily aFamily = *aFamilyIter;
+ const TEntity& anEntity = aFamily->myEntity;
+ const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
+ if(anEntity == NODE_ENTITY){
+ isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily);
+ }else{
+ isPointsUpdated += LoadPoints(aMed,theMesh);
+ isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily);
+ }
+ }
+
+ return (isPointsUpdated || isCellsOnEntityUpdated);
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFieldImpl theField,
+ VISU::PValForTimeImpl theValForTime)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
+ INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
+
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ const TEntity& anEntity = theMeshOnEntity->myEntity;
+ int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
+ isPointsUpdated += LoadPoints(aMed,theMesh);
+ if(anEntity != NODE_ENTITY)
+ isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
+ int isFieldUpdated = LoadValForTimeOnMesh(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
+
+ return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFieldImpl theField,
+ VISU::PValForTimeImpl theValForTime)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
+ INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
+
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ const TEntity& anEntity = theMeshOnEntity->myEntity;
+ int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
+ if(anEntity != NODE_ENTITY)
+ isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
+ int isFieldUpdated = LoadValForTimeOnGaussPts(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
+
+ return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadPoints(const MED::PWrapper& theMed,
+ VISU::PMEDMesh theMesh)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
+ try{
+ //Check on existing family
+ PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
+ aMeshOnEntity->myMeshName = theMesh->myName;
+ aMeshOnEntity->myEntity = NODE_ENTITY;
+
+ INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<<theMesh->myIsDone<<"'\n");
+
+ //Check on loading already done
+ if(theMesh->myIsDone)
+ return 0;
+
+ //Main part of code
+ MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
+ TInt aNbElem = aNodeInfo->GetNbElem();
+ TInt aDim = theMesh->myDim;
+
+ PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
+ TMEDNamedPointCoords& aCoords = aNamedPointCoords;
+ aCoords.Init(aNbElem,aDim,aNodeInfo);
+
+ for(int iDim = 0; iDim < aDim; iDim++)
+ aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
+
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem);
+ MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem);
+ for(int iDim = 0; iDim < aDim; iDim++)
+ aVCoordSlice[iDim] = aMCoordSlice[iDim];
}
+
+ TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh());
+
+ aSubMesh->Init(aNodeInfo);
+ aSubMesh->myNbCells = theMesh->myNbPoints;
+ aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
+
+ TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ aCell2Connect.resize(aNbElem);
+ for (int iElem = 0; iElem < aNbElem; iElem++)
+ aCell2Connect[iElem] = VISU::TConnect(1,iElem);
+
+ theMesh->myIsDone = true;
+
return 1;
- }catch(std::runtime_error& exc){
- theMesh->myPointsCoord.clear();
+
+ }catch(std::exception& exc){
throw;
}catch(...){
- theMesh->myPointsCoord.clear();
EXCEPTION(runtime_error,"Unknown exception !!!");
}
+
return 0;
}
+//---------------------------------------------------------------
int
-VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed,
- VISU::PMEDMesh theMesh,
- VISU::PMEDMeshOnEntity theMeshOnEntity,
- const string& theFamilyName)
+VISU_MedConvertor
+::LoadPointsOnFamily(const MED::PWrapper& theMed,
+ const VISU::PMEDMesh theMesh,
+ const VISU::PMEDFamily theFamily)
{
+ TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
try{
- //Check on existing family
- PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
- //Check on loading already done
- bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty();
- if(isCellsLoaded)
- if(!aFamily)
- return 0;
- else if(!aFamily->mySubMesh.empty())
- return 0;
+ if(theFamily->myIsDone)
+ return 0;
- INITMSG(MYDEBUG,"LoadCellsOnEntity - theFamilyName = '"<<theFamilyName<<"'\n");
- BEGMSG(MYDEBUG,"LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<bool(aFamily)<<endl);
+ //Main part of code
+ MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
+ TInt aNbElem = aNodeInfo->GetNbElem();
- const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
- const EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
+ if(aNbElem > 0){
+ TInt anId = theFamily->myId;
+ TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
+ for(TInt iElem = 0; iElem < aNbElem; iElem++)
+ if(aNodeInfo->GetFamNum(iElem) == anId)
+ aSubMeshID.push_back(iElem);
+ }
+
+ theFamily->myIsDone = true;
+
+ return 1;
+
+ }catch(std::exception& exc){
+ throw;
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+
+ return 0;
+}
- const PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
- PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadCellsOnEntity(const MED::PWrapper& theMed,
+ const VISU::PMEDMesh theMesh,
+ const VISU::PMEDMeshOnEntity theMeshOnEntity)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
+#ifndef _DEXCEPT_
+ try{
+#endif
+ const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
+
+ INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<<aVEntity<<"\n");
+
+ if(theMeshOnEntity->myIsDone)
+ return 0;
+
+ const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+ MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
TInt aNbPoints = aNodeInfo->GetNbElem();
std::map<TInt,TInt> aNodeIdMap;
#ifdef _EDF_NODE_IDS_
- EBooleen anIsNodeNum = eFAUX;
+ EBooleen anIsNodeNum = MED::eFAUX;
#else
EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
if(anIsNodeNum){
}
#endif
- const MED::TGeom& aTGeom = theMeshOnEntity->myGeom;
- MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
- TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn;
-
- for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
- const EGeometrieElement& aGeom = anTGeomIter->first;
- int aVTKGeomType = MEDGeomToVTK(aGeom);
- ADDMSG(MYDEBUG,"LoadCellsOnEntity aGeom="<<aGeom<<"\n");
- switch(aGeom){
- case ePOLYGONE:
- {
- PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aPolygoneInfo->GetNbElem();
+ const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
+ MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
+ TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
+
+ for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
+ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"; aEGeom = "<<aEGeom<<"\n");
+ switch(aMGeom){
+ case MED::ePOLYGONE: {
+ MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
+ TInt aNbElem = aPolygoneInfo->GetNbElem();
+ if(aNbElem > 0){
+ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
- if(!isCellsLoaded){
- VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType];
- aConnForPolygoneType.resize(aNbElem);
-
- int aMNbNodes = aPolygoneInfo->GetConnDim();
-
- vector<TInt> aConnect(aMNbNodes);
- vector<TInt> aIndex = aPolygoneInfo->GetIndex();
-
- for (int iElem = 0; iElem < aNbElem; iElem++) {
- VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolygoneType[iElem];
- int aNbConn = aPolygoneInfo->GetNbConn(iElem);
-
- anArray.resize(aNbConn);
-
- aConnect = aPolygoneInfo->GetConnectivite();
-
- for (int i=0;i<aNbConn;i++){
- anArray[i] = aConnect[aIndex[iElem]-1+i]-1;
- }
- }
- }
- if(aFamily){
- VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId)
- aSubMeshOnCellType.insert(iElem);
+ aSubMesh->Init(aPolygoneInfo);
+ aSubMesh->myNbCells = aNbElem;
+
+ TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ aCell2Connect.resize(aNbElem);
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++) {
+ MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
+ TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
+ aSubMesh->myCellsSize += aNbConn;
+ TConnect& anArray = aCell2Connect[iElem];
+ anArray.resize(aNbConn);
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ anArray[iConn] = aConnSlice[iConn] - 1;
}
- break;
}
- case ePOLYEDRE:
- {
- PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aPolyedreInfo->GetNbElem();
-
- int aMNbNodes = aPolyedreInfo->GetNbConn();
- vector<TInt> aConnect(aMNbNodes);
- aConnect = aPolyedreInfo->GetConnectivite();
+ break;
+ }
+ case MED::ePOLYEDRE: {
+ MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
+ TInt aNbElem = aPolyedreInfo->GetNbElem();
+
+ if(aNbElem > 0){
+ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
- if(!isCellsLoaded){
- VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolyedreType = aCellsConn[aVTKGeomType];
- aConnForPolyedreType.resize(aNbElem);
-
- vector<TInt> aFacesIndex = aPolyedreInfo->GetFacesIndex();
- vector<TInt> aIndex = aPolyedreInfo->GetIndex();
-
- for (int iElem = 0; iElem < aNbElem; iElem++) {
- set<TInt> aArrayNew;
- VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolyedreType[iElem];
-
- int aInd1 = aIndex[iElem]-1;
- int aInd2 = aIndex[iElem+1]-2;
-
- for (int i=aInd1;i<=aInd2;i++){
- for (int j=aFacesIndex[i]-1;j<aFacesIndex[i+1]-1;j++){
- aArrayNew.insert(aConnect[j]);
- }
- }
-
- int aNbConnNew = aArrayNew.size();
- anArray.resize(aNbConnNew);
- set<TInt>::iterator aIter = aArrayNew.begin();
- for (int i=0; aIter!=aArrayNew.end();aIter++, i++)
- anArray[i] = (*aIter)-1;
+ aSubMesh->Init(aPolyedreInfo);
+ aSubMesh->myNbCells = aNbElem;
+ TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ aCell2Connect.resize(aNbElem);
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
+ TConnect& anArray = aCell2Connect[iElem];
+ typedef std::set<TInt> TConnectSet;
+ TConnectSet aConnectSet;
+ TInt aNbFaces = aConnSliceArr.size();
+ for(TInt iFace = 0; iFace < aNbFaces; iFace++){
+ MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
+ TInt aNbConn = aConnSlice.size();
+ aSubMesh->myCellsSize += aNbConn;
+ for(TInt iConn = 0; iConn < aNbConn; iConn++){
+ aConnectSet.insert(aConnSlice[iConn]);
+ }
+ }
+
+ int aNbConn = aConnectSet.size();
+ anArray.resize(aNbConn);
+ TConnectSet::iterator anIter = aConnectSet.begin();
+ for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){
+ TInt anId = *anIter;
+ anArray[i] = anId - 1;
}
}
- if(aFamily){
- VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aPolyedreInfo->GetFamNum(iElem) == aFamily->myId)
- aSubMeshOnCellType.insert(iElem);
- }
- break;
}
- default:
- {
- int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType);
-
- PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aCellInfo->GetNbElem();
+
+ break;
+ }
+ default: {
+ vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
+ INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
+
+ MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
+ TInt aNbElem = aCellInfo->GetNbElem();
+
+ if(aNbElem > 0){
+ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
- if(!isCellsLoaded){
- VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType];
- aConnForCellType.resize(aNbElem);
+ aSubMesh->Init(aCellInfo);
+ aSubMesh->myNbCells = aNbElem;
+ aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
+
+ TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ aCell2Connect.resize(aNbElem);
+
+ TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
+ TVector<TInt> aConnect(aMNbNodes);
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++) {
+ MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
+ TConnect& anArray = aCell2Connect[iElem];
+ anArray.resize(aVNbNodes);
- int aMNbNodes = MEDGeom2NbNodes(aGeom);
- vector<TInt> aConnect(aMNbNodes);
-
- for (int iElem = 0; iElem < aNbElem; iElem++) {
- VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem];
- anArray.resize(aVNbNodes);
-
- if(anIsNodeNum){
- for(int i = 0; i < aMNbNodes; i++){
- aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1];
- }
- }else{
- for(int i = 0; i < aMNbNodes; i++){
- aConnect[i] = aCellInfo->GetConn(iElem,i)-1;
- }
+ if(anIsNodeNum){
+ for(TInt iConn = 0; iConn < aMNbNodes; iConn++){
+ aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1];
}
-
- switch(aGeom){
- case eTETRA4:
- case eTETRA10:
- anArray[0] = aConnect[0];
- anArray[1] = aConnect[1];
- anArray[2] = aConnect[3];
- anArray[3] = aConnect[2];
- break;
- case ePYRA5:
- case ePYRA13:
- anArray[0] = aConnect[0];
- anArray[1] = aConnect[3];
- anArray[2] = aConnect[2];
- anArray[3] = aConnect[1];
- anArray[4] = aConnect[4];
- break;
- default:
- for(int iNode = 0; iNode < aVNbNodes; iNode++)
- anArray[iNode] = aConnect[iNode];
+ }else{
+ for(int iConn = 0; iConn < aMNbNodes; iConn++){
+ aConnect[iConn] = aConnSlice[iConn] - 1;
}
+ }
+
+ switch(aMGeom){
+#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case MED::eSEG3:
+ anArray[0] = aConnect[0];
+ anArray[2] = aConnect[1];
+
+ anArray[1] = aConnect[2];
+ break;
+#endif
+#if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case MED::eTRIA6:
+ anArray[0] = aConnect[0];
+ anArray[2] = aConnect[1];
+ anArray[4] = aConnect[2];
+
+ anArray[1] = aConnect[3];
+ anArray[3] = aConnect[4];
+ anArray[5] = aConnect[5];
+ break;
+#endif
+#if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case MED::eQUAD8:
+ anArray[0] = aConnect[0];
+ anArray[2] = aConnect[1];
+ anArray[4] = aConnect[2];
+ anArray[6] = aConnect[3];
+
+ anArray[1] = aConnect[4];
+ anArray[3] = aConnect[5];
+ anArray[5] = aConnect[6];
+ anArray[7] = aConnect[7];
+ break;
+#endif
+#if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case MED::eTETRA10:
+ anArray[0] = aConnect[0];
+ anArray[1] = aConnect[2];
+ anArray[2] = aConnect[1];
+ anArray[3] = aConnect[3];
+
+ anArray[4] = aConnect[6];
+ anArray[5] = aConnect[5];
+ anArray[6] = aConnect[4];
+
+ anArray[7] = aConnect[7];
+ anArray[8] = aConnect[9];
+ anArray[9] = aConnect[8];
+ break;
+#endif
+ case MED::eTETRA4:
+ anArray[0] = aConnect[0];
+ anArray[1] = aConnect[2];
+ anArray[2] = aConnect[1];
+ anArray[3] = aConnect[3];
+ break;
+#if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case MED::ePYRA13:
+ anArray[0] = aConnect[0];
+ anArray[1] = aConnect[3];
+ anArray[2] = aConnect[2];
+ anArray[3] = aConnect[1];
+ anArray[4] = aConnect[4];
+
+ anArray[5] = aConnect[5];
+ anArray[6] = aConnect[8];
+ anArray[7] = aConnect[7];
+ anArray[8] = aConnect[6];
+
+ anArray[9] = aConnect[9];
+ anArray[10] = aConnect[12];
+ anArray[11] = aConnect[11];
+ anArray[12] = aConnect[10];
+ break;
+#endif
+ case MED::ePYRA5:
+ anArray[0] = aConnect[0];
+ anArray[1] = aConnect[3];
+ anArray[2] = aConnect[2];
+ anArray[3] = aConnect[1];
+ anArray[4] = aConnect[4];
+ break;
+ default:
for(int iNode = 0; iNode < aVNbNodes; iNode++)
- if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
- EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<<aNbPoints<<") "<<
- "<= anArray["<<iElem<<"]"<<
- "["<<iNode<<"]"<<
- "("<<anArray[iNode]<<") < 0");
+ anArray[iNode] = aConnect[iNode];
}
+ for(int iNode = 0; iNode < aVNbNodes; iNode++)
+ if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
+ EXCEPTION(runtime_error,"LoadCellsOnEntity - "<<
+ " aNbPoints("<<aNbPoints<<") "<<
+ "<= anArray["<<iElem<<"]"<<
+ "["<<iNode<<"]"<<
+ "("<<anArray[iNode]<<") < 0");
}
- //Filling aFamily SubMesh
- if(aFamily){
- VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aCellInfo->GetFamNum(iElem) == aFamily->myId)
- aSubMeshOnCellType.insert(iElem);
+ }
+ }}
+ }
+
+ theMeshOnEntity->myIsDone = true;
+
+ return 1;
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ throw;
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+
+ return 0;
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadCellsOnFamily(const MED::PWrapper& theMed,
+ const VISU::PMEDMesh theMesh,
+ const VISU::PMEDMeshOnEntity theMeshOnEntity,
+ const VISU::PMEDFamily theFamily)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
+#ifndef _DEXCEPT_
+ try{
+#endif
+ const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
+
+ INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<<aVEntity<<"\n");
+
+ if(theFamily->myIsDone)
+ return 0;
+
+ TInt anId = theFamily->myId;
+
+ const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+ TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
+
+ const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
+ MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
+ for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
+ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
+ MED::PElemInfo anElemInfo;
+ switch(aMGeom){
+ case MED::ePOLYGONE: {
+ anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
+ }
+ case MED::ePOLYEDRE: {
+ anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
+ }
+ default: {
+ anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
+ }}
+ if(anElemInfo){
+ if(TInt aNbElem = anElemInfo->GetNbElem()){
+ TSubMeshID aSubMeshID;
+ for(TInt iElem = 0; iElem < aNbElem; iElem++)
+ if(anElemInfo->GetFamNum(iElem) == anId)
+ aSubMeshID.push_back(iElem);
+ if(!aSubMeshID.empty()){
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
+ aGeom2SubMeshID.insert(TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
}
}
}
}
+
+ theFamily->myIsDone = true;
+
return 1;
- }catch(std::runtime_error& exc){
- theMeshOnEntity->myCellsConn.clear();
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
throw;
}catch(...){
- theMeshOnEntity->myCellsConn.clear();
EXCEPTION(runtime_error,"Unknown exception !!!");
}
+#endif
+
return 0;
}
+//---------------------------------------------------------------
+void
+LoadProfile(const MED::PWrapper& theMed,
+ VISU::PMEDMesh theMesh,
+ MED::TTimeStampVal& theTimeStampVal,
+ VISU::TMEDValForTime& theValForTime,
+ VISU::TMEDMeshOnEntity& theMeshOnEntity)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
+ INITMSG(MYDEBUG,"LoadProfile"<<endl);
+
+ PMEDProfile aProfile = theValForTime.myProfile;
+ if(aProfile->myIsDone)
+ return;
+
+ const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
+ MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin();
+ for(; anIter != aGeom2Profile.end(); anIter++){
+ MED::PProfileInfo aProfileInfo = anIter->second;
+ MED::EGeometrieElement aMGeom = anIter->first;
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+
+ TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
+ if(anIter2 != aGeom2SubProfile.end()){
+ PMEDSubProfile aSubProfile = anIter2->second;
+
+ MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
+ if(!anElemNum.empty()){
+ TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
+ TInt aSize = anElemNum.size();
+ aSubMeshID.resize(aSize);
+ for(TInt anId = 0; anId < aSize; anId++)
+ aSubMeshID[anId] = anElemNum[anId] - 1;
+ }
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
+ endl);
+ }
+ }
+ {
+ const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+
+ TEntity aVEntity = theMeshOnEntity.myEntity;
+ MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
+
+ const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ for(; anIter != aGeom2SubProfile.end(); anIter++){
+ const PMEDSubProfile& aSubProfile = anIter->second;
+ MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
+ MED::PElemInfo anElemInfo;
+ if(aMEntity == MED::eNOEUD)
+ anElemInfo = theMed->GetPNodeInfo(aMeshInfo);
+ else{
+ switch(aMGeom){
+ case MED::ePOLYGONE: {
+ anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
+ }
+ case MED::ePOLYEDRE: {
+ anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
+ }
+ default: {
+ anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
+ }}
+ }
+ aSubProfile->myIsElemNum = anElemInfo->IsElemNum();
+ aSubProfile->myElemNum = anElemInfo->myElemNum;
+ }
+ }
+
+ aProfile->myIsDone = true;
+}
+
+
+//---------------------------------------------------------------
+void
+LoadGaussMesh(const MED::PWrapper& theMed,
+ VISU::PMEDMesh theMesh,
+ MED::TTimeStampVal& theTimeStampVal,
+ VISU::TMEDValForTime& theValForTime,
+ VISU::TMEDMeshOnEntity& theMeshOnEntity)
+{
+ TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
+ INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
+
+ PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
+ if(!aGaussMesh || aGaussMesh->myIsDone)
+ return;
+
+ const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+ MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
+
+ TEntity aVEntity = theMeshOnEntity.myEntity;
+ MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
+
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
+ const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
+
+ TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
+ for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){
+ PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
+ VISU::EGeometry aEGeom = aSubMeshIter->first;
+
+ if(aGaussSubMesh->myIsDone)
+ continue;
+
+ PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
+ const TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
+ MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
+
+ MED::PPolygoneInfo aPolygoneInfo;
+ MED::PPolyedreInfo aPolyedreInfo;
+ MED::PCellInfo aCellInfo;
+ MED::PElemInfo anElemInfo;
+
+ switch(aMGeom){
+ case MED::ePOLYGONE:
+ aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,
+ aMEntity,
+ aMGeom);
+ anElemInfo = aPolygoneInfo;
+ break;
+ case MED::ePOLYEDRE:
+ aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,
+ aMEntity,
+ aMGeom);
+ anElemInfo = aPolyedreInfo;
+ break;
+ default:
+ aCellInfo = theMed->GetPCellInfo(aMeshInfo,
+ aMEntity,
+ aMGeom);
+ anElemInfo = aCellInfo;
+ }
+ aGaussSubMesh->myIsElemNum = anElemInfo->IsElemNum();
+ aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
+
+ std::string aName;
+ MED::TGaussCoord aGaussCoord;
+ bool anIsGaussCoord3D = false;
+
+ MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
+ if(aGaussIter != aGeom2Gauss.end()){
+ PMEDGauss aGauss = aGaussSubMesh->myGauss;
+ MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo;
+ if(aGaussInfo){
+ aName = aGaussInfo->GetName();
+ if(!aSubMeshID.empty()){
+ const std::string& aProfileName = aSubProfile->myName;
+ MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
+ aProfileName);
+ if(aProfileInfo){
+ const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
+ anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
+ aCellInfo,
+ aNodeInfo,
+ aGaussCoord,
+ anElemNum);
+ }
+ }else
+ anIsGaussCoord3D = MED::GetGaussCoord3D(aGaussInfo,
+ aCellInfo,
+ aNodeInfo,
+ aGaussCoord);
+ }
+ }else{
+ if(!aSubMeshID.empty()){
+ const std::string& aProfileName = aSubProfile->myName;
+ MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
+ aProfileName);
+ if(aProfileInfo){
+ const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
+ switch(aMGeom){
+ case MED::ePOLYGONE:
+ anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
+ aNodeInfo,
+ aGaussCoord,
+ anElemNum);
+ break;
+ case MED::ePOLYEDRE:
+ anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
+ aNodeInfo,
+ aGaussCoord,
+ anElemNum);
+ break;
+ default:
+ anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
+ aNodeInfo,
+ aGaussCoord,
+ anElemNum);
+ }
+ }
+ }else
+ switch(aMGeom){
+ case MED::ePOLYGONE:
+ anIsGaussCoord3D = MED::GetBaryCenter(aPolygoneInfo,
+ aNodeInfo,
+ aGaussCoord);
+ break;
+ case MED::ePOLYEDRE:
+ anIsGaussCoord3D = MED::GetBaryCenter(aPolyedreInfo,
+ aNodeInfo,
+ aGaussCoord);
+ break;
+ default:
+ anIsGaussCoord3D = MED::GetBaryCenter(aCellInfo,
+ aNodeInfo,
+ aGaussCoord);
+ }
+ }
+
+ if(anIsGaussCoord3D){
+ TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
+ TInt aNbGauss = aGaussCoord.GetNbGauss();
+ TInt aNbElem = aGaussCoord.GetNbElem();
+ TInt aDim = aGaussCoord.GetDim();
+ vtkIdType aNbCells = aNbElem*aNbGauss;
+ aCoords.Init(aNbCells,aDim);
+ for(TInt anElemId = 0, aNodeId = 0; anElemId < aNbElem; anElemId++){
+ MED::TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId);
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aNodeId++){
+ MED::TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
+ TCoordSlice aSlice = aCoords.GetCoordSlice(aNodeId);
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++)
+ aSlice[aDimId] = aCoordSlice[aDimId];
+ }
+ }
+
+ aGaussSubMesh->myIsDone = true;;
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aName = '"<<aName<<"'"<<
+ "; aStatus = "<<aGaussSubMesh->myStatus<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aNbCells = "<<aNbCells<<
+ endl);
+ }else
+ EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
+ }
+
+ aGaussMesh->myIsDone = true;
+}
+
+
+//---------------------------------------------------------------
int
-VISU_MedConvertor::LoadField(const MED::PWrapper& theMed,
- VISU::PMEDMesh theMesh,
- VISU::PMEDMeshOnEntity theMeshOnEntity,
- VISU::PMEDField theField,
- VISU::PMEDValForTime theValForTime)
+LoadValForTime(const MED::PWrapper& theMed,
+ VISU::PMEDMesh theMesh,
+ VISU::PMEDMeshOnEntity theMeshOnEntity,
+ VISU::PMEDField theField,
+ VISU::PMEDValForTime theValForTime,
+ bool theIsGauss,
+ bool& theIsDone)
{
+ TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
+ INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
+
//Check on loading already done
- if(!theValForTime->myValForCells.empty()) return 0;
+ if(theIsDone)
+ return 0;
//Main part of code
const std::string& aMeshName = theMeshOnEntity->myMeshName;
- const PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
- PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,theField->myId);
-
- MED::TGeom aTGeom;
- EEntiteMaillage aMEntity;
- theMed->GetNbTimeStamps(aFieldInfo,theMesh->myEntityInfo,aMEntity,aTGeom);
-
- PTimeStampInfo aTimeStampInfo = theMed->GetPTimeStampInfo(aFieldInfo,
- aMEntity,
- aTGeom,
- theValForTime->myId);
- TInt aNbGauss = aTimeStampInfo->GetNbGauss();
+ const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+ MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,
+ theField->myId);
+
+ MED::TGeom2Size aGeom2Size;
+ MED::EEntiteMaillage aMEntity;
+ theMed->GetNbTimeStamps(aFieldInfo,
+ theMesh->myEntityInfo,
+ aMEntity,
+ aGeom2Size);
+
+ MED::PTimeStampInfo aTimeStampInfo =
+ theMed->GetPTimeStampInfo(aFieldInfo,
+ aMEntity,
+ aGeom2Size,
+ theValForTime->myId);
+
+ MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
+ MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
+
+ MED::PTimeStampVal aTimeStampVal =
+ theMed->GetPTimeStampVal(aTimeStampInfo,
+ aMKey2Profile,
+ aKey2Gauss);
+
+ InitGaussProfile(theMed,
+ aMeshInfo,
+ aTimeStampVal,
+ theMeshOnEntity,
+ aMEntity,
+ aGeom2Size,
+ theValForTime);
+
+ LoadProfile(theMed,
+ theMesh,
+ aTimeStampVal,
+ theValForTime,
+ theMeshOnEntity);
+
+ if(theIsGauss)
+ LoadGaussMesh(theMed,
+ theMesh,
+ aTimeStampVal,
+ theValForTime,
+ theMeshOnEntity);
+
+ PMEDProfile aProfile = theValForTime->myProfile;
+ TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+
TInt aNbComp = theField->myNbComp;
- PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo);
- bool anIsTrimmed = theField->myIsTrimmed;
- INITMSG(MYDEBUG,"LoadField - aMeshName = '"<<aMeshName<<
- "'; aFieldName = '"<<aFieldInfo->GetName()<<
- "'; aMEntity = "<<aMEntity<<
- "; anId = "<<theValForTime->myId<<endl);
- BEGMSG(MYDEBUG,"LoadField - aNbComp = "<<aNbComp<<
- "; aNbGauss = "<<aNbGauss<<endl);
-
- const MED::TGeom& anEntityTGeom = theMeshOnEntity->myGeom;
- MED::TGeom::const_iterator aTGeomIter = anEntityTGeom.begin();
- for(; aTGeomIter != anEntityTGeom.end(); aTGeomIter++){
- const EGeometrieElement& aGeom = aTGeomIter->first;
- const TInt& aNbElem = aTGeomIter->second;
-
- INITMSG(MYDEBUG,"LoadField - aGeom = "<<aGeom<<"; aNbElem = '"<<aNbElem<<endl);
-
- if(aTGeom.find(aGeom) == aTGeom.end()){
- if(!theField->myIsTrimmed){
- theField->myDataSize -= aNbElem*theField->myNbComp;
- anIsTrimmed = true;
- }
- }else{
- int aVTKGeomType = MEDGeomToVTK(aGeom);
- VISU::TValForTimeImpl::TValForCellsWithType& anArray = theValForTime->myValForCells[aVTKGeomType];
- anArray.resize(aNbComp*aNbElem);
- for(TInt iElem = 0, anId = 0; iElem < aNbElem; iElem++){
- for(TInt iComp = 0; iComp < aNbComp; iComp++, anId++){
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- anArray[anId] += aTimeStampVal->GetVal(aGeom,iElem,iComp,iGauss);
+ INITMSGA(MYDEBUG,0,
+ "- aMeshName = '"<<aMeshName<<"'"<<
+ "; aFieldName = '"<<aFieldInfo->GetName()<<"'"<<
+ "; aMEntity = "<<aMEntity<<
+ "; aNbComp = "<<aNbComp<<
+ endl);
+
+ theField->myDataSize = 0;
+
+ const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
+ TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ for(; anIter != aGeom2SubProfile.end(); anIter++){
+ VISU::EGeometry aEGeom = anIter->first;
+ PMEDSubProfile aSubProfile(anIter->second);
+
+ TInt aNbElem = aSubProfile->myNbCells;
+ theField->myDataSize += aNbElem*aNbComp;
+
+ if(aSubProfile->myStatus != eRemoveAll){
+ TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ TMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
+ aVMeshValue.Init(aNbElem,aNbGauss,aNbComp);
+
+ MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
+ const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ TValueSliceArr aVValueSliceArr = aVMeshValue.GetGaussValueSliceArr(iElem);
+ MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
+ ADDMSG(MYVALUEDEBUG,"{");
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ TValueSlice& aVValueSlice = aVValueSliceArr[iGauss];
+ const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+ for(TInt iComp = 0; iComp < aNbComp; iComp++){
+ aVValueSlice[iComp] = aMValueSlice[iComp];
+ ADDMSG(MYVALUEDEBUG,aVValueSlice[iComp]<<" ");
}
- anArray[anId] /= aNbGauss;
+ ADDMSG(MYVALUEDEBUG,"| ");
}
+ ADDMSG(MYVALUEDEBUG,"} ");
}
+ ADDMSG(MYDEBUG,"\n");
}
}
- theField->myIsTrimmed = anIsTrimmed;
+
+ theIsDone = true;
+
return 1;
}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadValForTimeOnMesh(const MED::PWrapper& theMed,
+ VISU::PMEDMesh theMesh,
+ VISU::PMEDMeshOnEntity theMeshOnEntity,
+ VISU::PMEDField theField,
+ VISU::PMEDValForTime theValForTime)
+{
+ PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
+ return LoadValForTime(theMed,
+ theMesh,
+ theMeshOnEntity,
+ theField,
+ theValForTime,
+ false,
+ anIDMapperFilter->myIsVTKDone);
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_MedConvertor
+::LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
+ VISU::PMEDMesh theMesh,
+ VISU::PMEDMeshOnEntity theMeshOnEntity,
+ VISU::PMEDField theField,
+ VISU::PMEDValForTime theValForTime)
+{
+ PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
+ return LoadValForTime(theMed,
+ theMesh,
+ theMeshOnEntity,
+ theField,
+ theValForTime,
+ true,
+ aGaussPtsIDFilter->myIsVTKDone);
+}