From a05f46d690a745314998fbad5683bf71069bc187 Mon Sep 17 00:00:00 2001 From: enk Date: Fri, 18 Feb 2005 07:44:22 +0000 Subject: [PATCH] Added support for polygones and polyhedres --- src/CONVERTOR/VISU_MedConvertor.cxx | 844 +++++++++++++++------------- 1 file changed, 461 insertions(+), 383 deletions(-) diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 3eabe088..72e5eb6a 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -77,7 +77,7 @@ namespace{ case ePYRA5: return VTK_PYRAMID; case ePYRA13: return VTK_PYRAMID; case ePOLYGONE: return VTK_POLYGON; -// case ePOLYEDRE: return VTK_POLYEDRE; + case ePOLYEDRE: return VTK_CONVEX_POINT_SET; } return -1; } @@ -109,6 +109,7 @@ namespace{ case VTK_WEDGE: return ePENTA6; case VTK_PYRAMID: return ePYRA5; case VTK_POLYGON: return ePOLYGONE; + case VTK_CONVEX_POINT_SET: return ePOLYEDRE; } return EGeometrieElement(-1); } @@ -149,320 +150,344 @@ VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) { } VISU_Convertor* VISU_MedConvertor::Build() { - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); - MED::TInt aNbMeshes = aMed->GetNbMeshes(); + PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + TInt aNbMeshes = aMed->GetNbMeshes(); + TMeshMap& aMeshMap = myMeshMap; MSG(MYDEBUG,"VISU_MedConvertor::Build()"); INITMSG(MYDEBUG,"GetNbMeshes() = "<GetPMeshInfo(iMesh); - - MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); - - MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); - - MED::TElemGroup anElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); + PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh); - MED::TInt aDim = aMeshInfo->GetDim(); - std::string aMeshName = aMeshInfo->GetName(); + PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); + + MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); + + TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); - VISU::PMEDMesh aMesh = myMeshMap[aMeshName](new VISU::TMEDMesh()); - aMesh->myDim = aDim; - aMesh->myName = aMeshName; - aMesh->myNbPoints = aNodeInfo->GetNbElem(); - aMesh->myMeshInfo = aMeshInfo; - aMesh->myEntityInfo = aEntityInfo; + TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); - INITMSG(MYDEBUG,"aMeshName = '"< TFamilyCounterMap; - TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; - TFamilyCounterMap aFamilyNbPolygonesCounterMap, aFamilyPolygonesSizeCounterMap; - - VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - MED::TElemGroup::const_iterator 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; - } + TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup); + + TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); + + // creating TMesh structure and TMeshOnEntityMap + typedef map TFamilyCounterMap; + TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; + + 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 = '"<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; } + } - INITMSG(MYDEBUG,"myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<<"\n");; - - }else{ - aMeshOnEntity->myNbCells = 0; - aMeshOnEntity->myCellsSize = 0; - MED::TElemMap::const_iterator 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 = - aMed->GetPPolygoneInfo(aMeshInfo,aMEntity,MED::ePOLYGONE); - MED::TInt aNbElem = aPolygoneInfo->GetNbElem(); - MED::TElemNum aConn = aPolygoneInfo->GetConnectivite(); - MED::TElemNum aIndex = aPolygoneInfo->GetIndex(); - MED::TInt aNbConn = aConn.size(); - - aMeshOnEntity->myNbCells += aNbElem; + 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; - for (int ii = 0; iiGetNbConn(ii); - aMeshOnEntity->myCellsSize += aNbConnii; - } - + aMeshOnEntity->myCellsSize += aNbConnii; + } INITMSG(MYDEBUG,"aGeom = "<GetFamNum(iElem); - if(aFamId != 0){ - aFamilyNbCellsCounterMap[aFamId] += 1; - aFamilyCellsSizeCounterMap[aFamId] += aPolygoneInfo->GetNbConn(iElem) + 1; - } - } + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + TInt aFamId = aPolygoneInfo->GetFamNum(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + ADDMSG(MYDEBUG,"aFamId="<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; iiGetNbConn(ii); + aMeshOnEntity->myCellsSize += aNbConnii; + } + INITMSG(MYDEBUG,"aGeom = "<GetFamNum(iElem); + std::string aName = aPolyedreInfo->GetElemName(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + ADDMSG(MYDEBUG,"(aFamId="<GetNbConn(iElem) + 1; + } + } + ADDMSG(MYDEBUG,endl); break; } - default: { + default: + { int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom)); - MED::PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); - MED::TInt aNbElem = aCellInfo->GetNbElem(); + PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); + TInt aNbElem = aCellInfo->GetNbElem(); aMeshOnEntity->myNbCells += aNbElem; aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1); INITMSG(MYDEBUG,"aGeom = "<GetFamNum(iElem); + + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + TInt aFamId = aCellInfo->GetFamNum(iElem); if(aFamId != 0){ aFamilyNbCellsCounterMap[aFamId] += 1; + ADDMSG(MYDEBUG,"aFamId = "<first; - const MED::TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; - - VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; - VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + } + + 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; - if(aFamilyGroup.empty()) + if(aFamilyGroup.empty()) + continue; + + INITMSG(MYDEBUG,"aMEntity = "<GetId() == 0) continue; + + const std::string& aFamilyName = aFamilyInfo->GetName(); + PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); - INITMSG(MYDEBUG,"aMEntity = "<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 = '"<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<<"; "<< + "; 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 = '"<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 = aMeshName; - - 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; - } + } + + 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 = '"<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; } } - 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)); + exit_lable: + if(aFamily && aVEntity >= 0){ + aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity)); + INITMSG(MYDEBUG,"aFamilyName = '"<myName<<"'; aVEntity = "<myNbCells += aFamily->myNbCells; + aGroup->myCellsSize += aFamily->myCellsSize; } } - - MED::TInt aNbFields = aMed->GetNbFields(); - BEGMSG(MYDEBUG,"VISU::TField aNbFields = "<GetPFieldInfo(aMeshInfo,iField); - MED::TInt aNbComp = aFieldInfo->GetNbComp(); - std::string aFieldName = aFieldInfo->GetName(); - - MED::TErr anErr; - MED::TGeom aTGeom; - MED::EEntiteMaillage aMEntity; - MED::TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo, - aEntityInfo, - aMEntity, - aTGeom, - &anErr); - if(anErr < 0) - continue; + 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); + if (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); + + 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); + } - 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::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 = "<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 = "<myMeshName; + PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + const string& aMeshName = theMeshOnEntity->myMeshName; const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; - VISU::PMeshImpl aMesh = myMeshMap[aMeshName]; + PMeshImpl aMesh = myMeshMap[aMeshName]; int isPointsUpdated; if(anEntity == VISU::NODE_ENTITY) isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName); @@ -476,11 +501,11 @@ int VISU_MedConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); + PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin(); for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ - const std::string& aFamilyName = aFamilyAndEntitySetIter->first; + const string& aFamilyName = aFamilyAndEntitySetIter->first; const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second; const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; if(anEntity == VISU::NODE_ENTITY){ @@ -500,7 +525,7 @@ int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, VISU::PFieldImpl theField, VISU::PValForTimeImpl theValForTime) { - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); + 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); @@ -519,7 +544,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; - VISU::PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName); + PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName); //Check on loading already done bool isPointsLoaded = !theMesh->myPointsCoord.empty(); if(isPointsLoaded) @@ -529,10 +554,10 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, return 0; INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<GetPNodeInfo(theMesh->myMeshInfo); - MED::TInt aNbElem = aNodeInfo->GetNbElem(); + PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); + TInt aNbElem = aNodeInfo->GetNbElem(); if(!isPointsLoaded){ VISU::TMeshImpl::TPointsDim& aPointsDim = theMesh->myPointsDim; @@ -542,14 +567,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] = TMeshOnEntityImpl::TConnect(1,iElem); + aConnForCellType[iElem] = VISU::TMeshOnEntityImpl::TConnect(1,iElem); } if(aFamily && aNbElem > 0){ VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; @@ -558,8 +583,7 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, aSubMeshOnCellType.insert(iElem); } return 1; - }catch(std::exception& exc){ - MSG(MYDEBUG,"Follow exception was occured :\n"<myPointsCoord.clear(); throw; }catch(...){ @@ -578,7 +602,7 @@ VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, { try{ //Check on existing family - VISU::PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); + PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); if(isCellsLoaded) @@ -591,19 +615,19 @@ VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, BEGMSG(MYDEBUG,"LoadCellsOnEntity - isCellsLoaded = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom); - MED::TInt aNbElem = aPolygoneInfo->GetNbElem(); - - if(!isCellsLoaded){ - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType]; - aConnForPolygoneType.resize(aNbElem); - - int aMNbNodes = aPolygoneInfo->GetConnDim(); + case ePOLYGONE: + { + PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom); + TInt aNbElem = aPolygoneInfo->GetNbElem(); - 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); + if(!isCellsLoaded){ + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType]; + aConnForPolygoneType.resize(aNbElem); - aConnect = aPolygoneInfo->GetConnectivite(); + int aMNbNodes = aPolygoneInfo->GetConnDim(); - for(int i = 0 ; i < aNbConn; i++){ - anArray[i] = aConnect[aIndex[iElem]-1+i]-1; + 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;imySubMesh[aVTKGeomType]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshOnCellType.insert(iElem); + } + break; } - 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); + case ePOLYEDRE: + { + PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aGeom); + TInt aNbElem = aPolyedreInfo->GetNbElem(); + + if(!isCellsLoaded){ + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolyedreType = aCellsConn[aVTKGeomType]; + aConnForPolyedreType.resize(aNbElem); + + int aMNbNodes = aPolyedreInfo->GetNbConn(); + + vector aConnect(aMNbNodes); + vector aFacesIndex = aPolyedreInfo->GetFacesIndex(); + vector aIndex = aPolyedreInfo->GetIndex(); + + for (int iElem = 0; iElem < aNbElem; iElem++) { + VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolyedreType[iElem]; + int aNbConn = aPolyedreInfo->GetNbConn(iElem); + + anArray.resize(aNbConn); + + aConnect = aPolyedreInfo->GetConnectivite(); + + int aInd1 = aIndex[iElem]-1; + int aInd2 = aIndex[iElem+1]-2; + + int k = 0; + for (int i=aInd1;i<=aInd2;i++){ + for (int j=aFacesIndex[i]-1;j> aNbPoints("<> aNbPoints("<mySubMesh[aVTKGeomType]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aCellInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshOnCellType.insert(iElem); } } - //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); - } - }} + } } return 1; - }catch(std::exception& exc){ + }catch(std::runtime_error& exc){ theMeshOnEntity->myCellsConn.clear(); throw; }catch(...){ @@ -738,29 +810,35 @@ VISU_MedConvertor::LoadField(const MED::PWrapper& theMed, if(!theValForTime->myValForCells.empty()) return 0; //Main part of code - MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo; - MED::TInt anId = theField->myId; - MED::PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,anId); + const std::string& aMeshName = theMeshOnEntity->myMeshName; + const PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,theField->myId); MED::TGeom aTGeom; - MED::EEntiteMaillage aMEntity; - const MED::TEntityInfo& anEntityInfo = theMesh->myEntityInfo; - theMed->GetNbTimeStamps(aFieldInfo,anEntityInfo,aMEntity,aTGeom); + EEntiteMaillage aMEntity; + theMed->GetNbTimeStamps(aFieldInfo,theMesh->myEntityInfo,aMEntity,aTGeom); - anId = theValForTime->myId; - MED::PTimeStampInfo aTimeStampInfo = - theMed->GetPTimeStampInfo(aFieldInfo,aMEntity,aTGeom,anId); + PTimeStampInfo aTimeStampInfo = theMed->GetPTimeStampInfo(aFieldInfo, + aMEntity, + aTGeom, + theValForTime->myId); + TInt aNbGauss = aTimeStampInfo->GetNbGauss(); + TInt aNbComp = theField->myNbComp; - MED::PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); + PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); - MED::TInt aNbGauss = aTimeStampInfo->GetNbGauss(); - MED::TInt aNbComp = theField->myNbComp; + INITMSG(MYDEBUG,"LoadField - aMeshName = '"<