From: apo Date: Mon, 31 Jan 2005 13:49:31 +0000 (+0000) Subject: Fix on [Bug PAL7927] REGRESSION: It is an incorrect import of the MED file and incorr... X-Git-Tag: V2_2_0b2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=014b9566e39cb1833cf8ffb1600ebc1e1e21376d;p=modules%2Fvisu.git Fix on [Bug PAL7927] REGRESSION: It is an incorrect import of the MED file and incorrect coloring of the scalar map. --- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 16e0ac4b..a0434a30 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -149,312 +149,322 @@ VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) { } VISU_Convertor* VISU_MedConvertor::Build() { - PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); - TInt aNbMeshes = aMed->GetNbMeshes(); - TMeshMap& aMeshMap = myMeshMap; + MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); + MED::TInt aNbMeshes = aMed->GetNbMeshes(); MSG(MYDEBUG,"VISU_MedConvertor::Build()"); INITMSG(MYDEBUG,"GetNbMeshes() = "<GetPMeshInfo(iMesh); - - PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); - - MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); - - TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); + MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh); + + MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); + + MED::TElemGroup anElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); - TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); + // Find PNodeInfo + MED::TElemGroup::const_iterator anElemGroupIter = anElemGroup.find(MED::eNOEUD); + if(anElemGroupIter == anElemGroup.end()) + continue; - TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aElemGroup,aFamilyGroup); + const MED::TElemMap& anElemMap = anElemGroupIter->second; + MED::TElemMap::const_iterator anElemMapIter = anElemMap.find(MED::ePOINT1); + if(anElemMapIter == anElemMap.end()) + continue; - TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); + MED::PNodeInfo aNodeInfo(anElemMapIter->second); - // creating TMesh structure and TMeshOnEntityMap - typedef map TFamilyCounterMap; - TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; - TFamilyCounterMap aFamilyNbPolygonesCounterMap, aFamilyPolygonesSizeCounterMap; + // creating TMesh structure and TMeshOnEntityMap + typedef std::map TFamilyCounterMap; + TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; + TFamilyCounterMap aFamilyNbPolygonesCounterMap, aFamilyPolygonesSizeCounterMap; - TInt aDim = aMeshInfo->GetDim(); - const string& aMeshName = aMeshInfo->GetName(); + MED::TInt aDim = aMeshInfo->GetDim(); + std::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 = '"<myMeshOnEntityMap; - MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin(); - for(; anEntityIter != aEntityInfo.end(); anEntityIter++){ - const EEntiteMaillage& aMEntity = anEntityIter->first; - const MED::TGeom& aTGeom = anEntityIter->second; - - TEntity aVEntity = MEDEntityToVTK(aMEntity); - PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); - aMeshOnEntity->myEntity = aVEntity; - aMeshOnEntity->myMeshName = aMeshName; - aMeshOnEntity->myGeom = aTGeom; - - INITMSG(MYDEBUG,"aMEntity = "<myNbCells = aMesh->myNbPoints; - aMeshOnEntity->myCellsSize = 2*aMesh->myNbPoints; - - for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){ - TInt aFamId = aNodeInfo->GetFamNum(iElem); - if(aFamId != 0){ - aFamilyNbCellsCounterMap[aFamId] += 1; - aFamilyCellsSizeCounterMap[aFamId] += 2; + VISU::PMEDMesh aMesh = myMeshMap[aMeshName](new VISU::TMEDMesh()); + aMesh->myDim = aDim; + aMesh->myName = aMeshName; + aMesh->myNbPoints = aNodeInfo->GetNbElem(); + aMesh->myMeshInfo = aMeshInfo; + aMesh->myEntityInfo = aEntityInfo; + + INITMSG(MYDEBUG,"aMeshName = '"<myMeshOnEntityMap; + anElemGroupIter = anElemGroup.begin(); + for(; anElemGroupIter != anElemGroup.end(); anElemGroupIter++){ + const MED::EEntiteMaillage& aMEntity = anElemGroupIter->first; + const MED::TElemMap& anElemMap = anElemGroupIter->second; + + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = + aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity()); + aMeshOnEntity->myEntity = aVEntity; + aMeshOnEntity->myMeshName = aMeshName; + aMeshOnEntity->myGeom = aEntityInfo[aMEntity]; + + INITMSG(MYDEBUG,"aMEntity = "<myNbCells = aMesh->myNbPoints; + aMeshOnEntity->myCellsSize = 2*aMesh->myNbPoints; + + for(MED::TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){ + MED::TInt aFamId = aNodeInfo->GetFamNum(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + aFamilyCellsSizeCounterMap[aFamId] += 2; + } } - } - INITMSG(MYDEBUG,"myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<<"\n");; - - }else{ - MED::TGeom::const_iterator anTGeomIter = aTGeom.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; + INITMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n");; + + }else{ + aMeshOnEntity->myNbCells = 0; + aMeshOnEntity->myCellsSize = 0; + anElemMapIter = anElemMap.begin(); + for(; anElemMapIter != anElemMap.end(); anElemMapIter++){ + const MED::EGeometrieElement& aGeom = anElemMapIter->first; + MED::PElemInfo anElemInfo = anElemMapIter->second; + + switch(aGeom){ + case MED::ePOLYGONE: { + MED::PPolygoneInfo aPolygoneInfo(anElemInfo); + MED::TInt aNbElem = aPolygoneInfo->GetNbElem(); + MED::TElemNum aConn = aPolygoneInfo->GetConnectivite(); + MED::TElemNum aIndex = aPolygoneInfo->GetIndex(); + MED::TInt aNbConn = aConn.size(); + + aMeshOnEntity->myNbCells += aNbElem; - for (int ii = 0; iiGetNbConn(ii); - aMeshOnEntity->myCellsSize += aNbConnii; - } + aMeshOnEntity->myCellsSize += aNbConnii; + } + INITMSG(MYDEBUG,"aGeom = "<GetFamNum(iElem); - if(aFamId != 0){ - aFamilyNbCellsCounterMap[aFamId] += 1; - ADDMSG(MYDEBUG,"aFamId = "<GetNbConn(iElem) + 1; - } - } - ADDMSG(MYDEBUG,endl); + for(MED::TInt iElem = 0; iElem < aNbElem; iElem++){ + MED::TInt aFamId = aPolygoneInfo->GetFamNum(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + aFamilyCellsSizeCounterMap[aFamId] += aPolygoneInfo->GetNbConn(iElem) + 1; + } + } break; } - default: - { + default: { int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom)); - PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); - TInt aNbElem = aCellInfo->GetNbElem(); + MED::PCellInfo aCellInfo(anElemInfo); + MED::TInt aNbElem = aCellInfo->GetNbElem(); aMeshOnEntity->myNbCells += aNbElem; aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1); INITMSG(MYDEBUG,"aGeom = "<GetFamNum(iElem); + + for(MED::TInt iElem = 0; iElem < aNbElem; iElem++){ + MED::TInt aFamId = aCellInfo->GetFamNum(iElem); if(aFamId != 0){ aFamilyNbCellsCounterMap[aFamId] += 1; - ADDMSG(MYDEBUG,"aFamId = "<first; - const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; - - TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; - VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - - if(aFamilyGroup.empty()) - continue; - INITMSG(MYDEBUG,"aMEntity = "<GetId() == 0) - continue; + BEGMSG(MYDEBUG,"TFamilyByEntity:\n"); + + MED::TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); + + MED::TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); + + MED::TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,anElemGroup,aFamilyGroup); - const std::string& aFamilyName = aFamilyInfo->GetName(); - PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + MED::TFamilyByEntity::const_iterator aFamilyByEntityIter = aFamilyByEntity.begin(); + for(; aFamilyByEntityIter != aFamilyByEntity.end(); aFamilyByEntityIter++){ + const MED::EEntiteMaillage& aMEntity = aFamilyByEntityIter->first; + const MED::TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; - aFamily->myId = aFamilyInfo->GetId(); - aFamily->myName = aFamilyInfo->GetName(); - aFamily->myEntity = aVEntity; - aFamily->myNbCells = aFamilyNbCellsCounterMap[aFamily->myId]; - aFamily->myCellsSize = aFamilyCellsSizeCounterMap[aFamily->myId]; + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + + if(aFamilyGroup.empty()) + continue; - INITMSG(MYDEBUG,"aFamilyName = '"<myName<< - "'; myId = "<myId<<"; "<< - "; aNbAttr = "<GetNbAttr()<< - "; aNbGroup = "<GetNbGroup()<< - "; myEntity = "<myEntity<< - "; myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<<"\n"); - - VISU::TBindGroups& aBindGroups = aFamily->myGroups; - const TInt aNbGroup = aFamilyInfo->GetNbGroup(); - for(TInt i = 0; i < aNbGroup; i++){ - const string& aGroupName = aFamilyInfo->GetGroupName(i); - aBindGroups.insert(aGroupName); - INITMSG(MYDEBUG,"aGroupName = '"<GetId() == 0) + continue; + + std::string aFamilyName = aFamilyInfo->GetName(); + VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + + aFamily->myId = aFamilyInfo->GetId(); + aFamily->myName = aFamilyInfo->GetName(); + aFamily->myEntity = aVEntity; + aFamily->myNbCells = aFamilyNbCellsCounterMap[aFamily->myId]; + aFamily->myCellsSize = aFamilyCellsSizeCounterMap[aFamily->myId]; + + INITMSG(MYDEBUG,"aFamilyName = '"<myName<< + "'; myId = "<myId<<"; "<< + "; aNbGroup = "<GetNbGroup()<< + "; myEntity = "<myEntity<< + "; myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n"); + + VISU::TBindGroups& aBindGroups = aFamily->myGroups; + MED::TInt aNbGroup = aFamilyInfo->GetNbGroup(); + for(MED::TInt i = 0; i < aNbGroup; i++){ + std::string aGroupName = aFamilyInfo->GetGroupName(i); + aBindGroups.insert(aGroupName); + INITMSG(MYDEBUG,"aGroupName = '"<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 = '"<myName<<"'\n"); - - TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin(); - for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){ - const PFamilyInfo& aFamilyInfo = *aFamilyIter; - const string& aFamilyName = aFamilyInfo->GetName(); - - TEntity aVEntity = TEntity(-1); - PFamily aFamily; - - // Find aVisuEntity - const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->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; - aFamily = aFamilyMapIter->second; - if(aName == aFamilyName){ - aVEntity = aFamily->myEntity; - goto exit_lable; + + BEGMSG(MYDEBUG,"VISU::TGroup:\n"); + + VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; + MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); + for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){ + const std::string& aGroupName = aGroupInfoIter->first; + const MED::TFamilyGroup& aFamilyGroup = aGroupInfoIter->second; + VISU::PMEDGroup aGroup(new TMEDGroup()); + aGroup->myName = aGroupName; + aGroup->myMeshName = aMesh->myName; + + INITMSG(MYDEBUG,"aGroup->myName = '"<myName<<"'\n"); + + MED::TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin(); + for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){ + MED::PFamilyInfo aFamilyInfo = *aFamilyIter; + std::string aFamilyName = aFamilyInfo->GetName(); + + VISU::TEntity aVEntity = TEntity(-1); + VISU::PFamily aFamily; + + // Find aVisuEntity + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){ + const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + 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 = '"<myName<<"'; aVEntity = "<myNbCells += aFamily->myNbCells; + aGroup->myCellsSize += aFamily->myCellsSize; + } } - exit_lable: - if(aFamily && aVEntity >= 0){ - aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity)); - INITMSG(MYDEBUG,"aFamilyName = '"<myName<<"'; aVEntity = "<myNbCells += aFamily->myNbCells; - aGroup->myCellsSize += aFamily->myCellsSize; + if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){ + BEGMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n\n"); + aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); } } - if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){ - BEGMSG(MYDEBUG,"myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<<"\n\n"); - aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); - } - } - - TInt aNbFields = aMed->GetNbFields(); - BEGMSG(MYDEBUG,"VISU::TField: NbFields="<GetPFieldInfo(aMeshInfo,iField); - TInt aNbComp = aFieldInfo->GetNbComp(); - const string& aFieldName = aFieldInfo->GetName(); - - MED::TGeom aTGeom; - EEntiteMaillage aMEntity; - TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom); - 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); - - INITMSG(MYDEBUG,"myName = '"<myName<< - "'; myId = "<myId<< - "; myEntity = "<myEntity<< - "; myDataSize = "<myDataSize<< - "; myNbComp = "<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++){ - PTimeStampInfo aTimeStamp = aMed->GetPTimeStampInfo(aFieldInfo, - aMEntity, - aTGeom, - iTimeStamp); - TFloat aDt = aTimeStamp->GetDt(); - const string& anUnitDt = aTimeStamp->GetUnitDt(); - PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp); - 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 = "<GetNbFields(); + BEGMSG(MYDEBUG,"VISU::TField aNbFields = "<GetPFieldInfo(aMeshInfo,iField); + MED::TInt aNbComp = aFieldInfo->GetNbComp(); + std::string aFieldName = aFieldInfo->GetName(); + + MED::TGeom aTGeom; + MED::EEntiteMaillage aMEntity; + MED::TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom); + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::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); + + INITMSG(MYDEBUG,"myName = '"<myName<< + "'; myId = "<myId<< + "; myEntity = "<myEntity<< + "; myDataSize = "<myDataSize<< + "; myNbComp = "<myNbComp<<"\n"); + + for(MED::TInt iComp = 0; iComp < aNbComp; iComp++){ + aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp); + aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp); + } + + for(MED::TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ + MED::TErr anErr; + MED::PTimeStampInfo aTimeStamp = aMed->GetPTimeStampInfo(aFieldInfo, + aMEntity, + aTGeom, + iTimeStamp, + &anErr); + if(anErr < 0) + continue; + + MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp,&anErr); + + MED::TFloat aDt = aTimeStamp->GetDt(); + std::string anUnitDt = aTimeStamp->GetUnitDt(); + VISU::TValField& aValField = aField->myValField; + VISU::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 = "<myMeshName; + MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); + const std::string& aMeshName = theMeshOnEntity->myMeshName; const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; - PMeshImpl aMesh = myMeshMap[aMeshName]; + VISU::PMeshImpl aMesh = myMeshMap[aMeshName]; int isPointsUpdated; if(anEntity == VISU::NODE_ENTITY) isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName); @@ -468,11 +478,11 @@ int VISU_MedConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { - PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + MED::PWrapper aMed = MED::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 std::string& aFamilyName = aFamilyAndEntitySetIter->first; const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second; const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; if(anEntity == VISU::NODE_ENTITY){ @@ -492,7 +502,7 @@ int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, VISU::PFieldImpl theField, VISU::PValForTimeImpl theValForTime) { - PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); int isPointsUpdated = LoadPoints(aMed,theMesh); int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); int isFieldUpdated = LoadField(aMed,theMesh,theMeshOnEntity,theField,theValForTime); @@ -511,7 +521,7 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; aMeshOnEntity->myEntity = VISU::NODE_ENTITY; aMeshOnEntity->myMeshName = theMesh->myName; - PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName); + VISU::PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName); //Check on loading already done bool isPointsLoaded = !theMesh->myPointsCoord.empty(); if(isPointsLoaded) @@ -521,10 +531,10 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, return 0; INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<GetPNodeInfo(theMesh->myMeshInfo); - TInt aNbElem = aNodeInfo->GetNbElem(); + MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); + MED::TInt aNbElem = aNodeInfo->GetNbElem(); if(!isPointsLoaded){ VISU::TMeshImpl::TPointsDim& aPointsDim = theMesh->myPointsDim; @@ -534,14 +544,14 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, VISU::TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord; aPointsCoord.resize(aNbElem*theMesh->myDim); - for (int iElem = 0; iElem < aNbElem; iElem++) + 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); 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); + aConnForCellType[iElem] = TMeshOnEntityImpl::TConnect(1,iElem); } if(aFamily && aNbElem > 0){ VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; @@ -550,7 +560,8 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, aSubMeshOnCellType.insert(iElem); } return 1; - }catch(std::runtime_error& exc){ + }catch(std::exception& exc){ + MSG(MYDEBUG,"Follow exception was occured :\n"<myPointsCoord.clear(); throw; }catch(...){ @@ -569,7 +580,7 @@ VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, { try{ //Check on existing family - PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); + VISU::PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); if(isCellsLoaded) @@ -582,19 +593,19 @@ VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, BEGMSG(MYDEBUG,"LoadCellsOnEntity - isCellsLoaded = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom); - TInt aNbElem = aPolygoneInfo->GetNbElem(); + case MED::ePOLYGONE: { + MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom); + MED::TInt aNbElem = aPolygoneInfo->GetNbElem(); + + if(!isCellsLoaded){ + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType]; + aConnForPolygoneType.resize(aNbElem); + + int aMNbNodes = aPolygoneInfo->GetConnDim(); - if(!isCellsLoaded){ - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType]; - aConnForPolygoneType.resize(aNbElem); + vector aConnect(aMNbNodes); + vector aIndex = aPolygoneInfo->GetIndex(); + + for(int iElem = 0; iElem < aNbElem; iElem++){ + VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolygoneType[iElem]; + int aNbConn = aPolygoneInfo->GetNbConn(iElem); - int aMNbNodes = aPolygoneInfo->GetConnDim(); + anArray.resize(aNbConn); - vector aConnect(aMNbNodes); - vector 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;iGetConnectivite(); + + 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); - } - break; } - default: - { - int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType); + 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); + } + break; + } + default: { + int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType); + + MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); + MED::TInt aNbElem = aCellInfo->GetNbElem(); + + if(!isCellsLoaded){ + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType]; + aConnForCellType.resize(aNbElem); - PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); - TInt aNbElem = aCellInfo->GetNbElem(); + int aMNbNodes = MEDGeom2NbNodes(aGeom); + vector aConnect(aMNbNodes); - if(!isCellsLoaded){ - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType]; - aConnForCellType.resize(aNbElem); + for(int iElem = 0; iElem < aNbElem; iElem++) { + TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem]; + anArray.resize(aVNbNodes); - int aMNbNodes = MEDGeom2NbNodes(aGeom); - vector 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(int i = 0; i < aMNbNodes; i++){ + aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-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 i = 0; i < aMNbNodes; i++){ + aConnect[i] = aCellInfo->GetConn(iElem,i)-1; } + } + + switch(aGeom){ + case MED::eTETRA4: + case MED::eTETRA10: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[1]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[2]; + break; + case MED::ePYRA5: + case MED::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++) - if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) - EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<mySubMesh[aVTKGeomType]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aCellInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshOnCellType.insert(iElem); + for(int iNode = 0; iNode < aVNbNodes; iNode++) + if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) + EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<mySubMesh[aVTKGeomType]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aCellInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshOnCellType.insert(iElem); + } + }} } return 1; - }catch(std::runtime_error& exc){ + }catch(std::exception& exc){ theMeshOnEntity->myCellsConn.clear(); throw; }catch(...){ @@ -733,35 +740,29 @@ VISU_MedConvertor::LoadField(const MED::PWrapper& theMed, if(!theValForTime->myValForCells.empty()) 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::PMeshInfo aMeshInfo = theMesh->myMeshInfo; + MED::TInt anId = theField->myId; + MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,anId); MED::TGeom aTGeom; - EEntiteMaillage aMEntity; - theMed->GetNbTimeStamps(aFieldInfo,theMesh->myEntityInfo,aMEntity,aTGeom); + MED::EEntiteMaillage aMEntity; + const MED::TEntityInfo& anEntityInfo = theMesh->myEntityInfo; + theMed->GetNbTimeStamps(aFieldInfo,anEntityInfo,aMEntity,aTGeom); - PTimeStampInfo aTimeStampInfo = theMed->GetPTimeStampInfo(aFieldInfo, - aMEntity, - aTGeom, - theValForTime->myId); - TInt aNbGauss = aTimeStampInfo->GetNbGauss(); - TInt aNbComp = theField->myNbComp; + anId = theValForTime->myId; + MED::PTimeStampInfo aTimeStampInfo = + theMed->GetPTimeStampInfo(aFieldInfo,aMEntity,aTGeom,anId); - PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); + MED::PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); - INITMSG(MYDEBUG,"LoadField - aMeshName = '"<