From 5e1a522fa0bb8f1a570f9ee3973a23b5eadd2984 Mon Sep 17 00:00:00 2001 From: enk Date: Thu, 27 Jan 2005 11:52:38 +0000 Subject: [PATCH] CEA DEN - PAL/SALOME 2005 - L1.4.1 - Polyhedral elements --- src/MEDWrapper/Base/MED_Algorithm.cxx | 23 +- src/MEDWrapper/Base/MED_Structures.cxx | 12 + src/MEDWrapper/Base/MED_Structures.hxx | 1 + src/MEDWrapper/Base/MED_Wrapper.cxx | 41 ++++ src/MEDWrapper/Base/MED_Wrapper.hxx | 51 ++++ src/MEDWrapper/Factory/MED_Test.cxx | 4 +- src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx | 12 +- src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx | 288 ++++++++++++++++++++--- src/MEDWrapper/V2_2/MED_V2_2_Wrapper.hxx | 65 +++++ 9 files changed, 435 insertions(+), 62 deletions(-) diff --git a/src/MEDWrapper/Base/MED_Algorithm.cxx b/src/MEDWrapper/Base/MED_Algorithm.cxx index a1a42ed96..128dfa2ea 100644 --- a/src/MEDWrapper/Base/MED_Algorithm.cxx +++ b/src/MEDWrapper/Base/MED_Algorithm.cxx @@ -60,23 +60,12 @@ namespace MED{ { PPolygoneInfo aPolygoneInfo = theWrapper.GetPPolygoneInfo(theMeshInfo,anEntity,aGeo); aElemSet.insert(aPolygoneInfo); - TElemNum aConn = aPolygoneInfo->GetConnectivite(); - TElemNum aIndex = aPolygoneInfo->GetIndex(); - TInt aNbIndex = aIndex.size(); - TInt aIndex0 = aIndex[0]; - INITMSG(MYDEBUG,"aGeo = "<GetConnectivite(); + TElemNum aIndex = anInfo->GetIndex(); + TInt aNbIndex = aIndex.size(); + TInt aIndex0 = aIndex[0]; + INITMSG(MYDEBUG,"theGeom = "<GetConnectivite(); + TElemNum aFacesIndex = anInfo->GetFacesIndex(); + TElemNum aIndex = anInfo->GetIndex(); + + TInt aNbIndex = aIndex.size(); + + for (int aNp = 0; aNp < aNbIndex-1;aNp++){ + if (anInfo->IsElemNames()) + ADDMSG(MYDEBUG,anInfo->GetElemName(aNp)<(theTEntity); + med_geometrie_element& aGeom = static_cast(theTGeom); + + TErr aRet = MEDnomLire(myFile->Id(), + &aMeshInfo.myName[0], + &theInfo.myElemNames[0], + nb, + anEntity, + aGeom); + + theInfo.myIsElemNames = (theInfo.myElemNames).empty()? EBooleen(0) : EBooleen(1) ; + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetNames - MEDnomLire(...)"); + } + + void TVWrapper::GetNumeration(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + med_entite_maillage& anEntity = static_cast(theTEntity); + med_geometrie_element& aGeom = static_cast(theTGeom); + + TErr aRet = MEDnumLire(myFile->Id(), + &aMeshInfo.myName[0], + &theInfo.myElemNum[0], + nb, + anEntity, + aGeom); + + theInfo.myIsElemNum = (theInfo.myElemNum).empty()? EBooleen(0) : EBooleen(1) ; + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetNumeration - MEDnumLire(...)"); + } + + void TVWrapper::GetFamilies(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + med_entite_maillage& anEntity = static_cast(theTEntity); + med_geometrie_element& aGeom = static_cast(theTGeom); + + TErr aRet = MEDfamLire(myFile->Id(), + &aMeshInfo.myName[0], + &theInfo.myFamNum[0], + nb, + anEntity, + aGeom); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetFamilies - MEDfamLire(...)"); + } + + void TVWrapper::SetNames(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + SetNames(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr); + } + + void TVWrapper::SetNames(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); + med_entite_maillage& anEntity = static_cast(theTEntity); + med_geometrie_element& aGeom = static_cast(theTGeom); + + TErr aRet = 0; + if (anIsElemNames){ + aRet = MEDnomEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNames[0], + anInfo.myElemNames.size(), + anEntity, + aGeom); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetNames - MEDnomEcr(...)"); + } + } + + void TVWrapper::SetNumeration(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + SetNumeration(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr); + } + + void TVWrapper::SetNumeration(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_entite_maillage& anEntity = static_cast(theTEntity); + med_geometrie_element& aGeom = static_cast(theTGeom); + + TErr aRet = 0; + if (anIsElemNum){ + aRet = MEDnumEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNum[0], + anInfo.myElemNum.size(), + anEntity, + aGeom); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetNumeration - MEDnumEcr(...)"); + } + } + + void TVWrapper::SetFamilies(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + SetFamilies(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr); + } + + void TVWrapper::SetFamilies(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_entite_maillage& anEntity = static_cast(theTEntity); + med_geometrie_element& aGeom = static_cast(theTGeom); + + TErr aRet = MEDfamEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myFamNum[0], + anInfo.myFamNum.size(), + anEntity, + aGeom); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetFamilies - MEDfamEcr(...)"); + } + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TInt TVWrapper::GetNbNodes(const MED::TMeshInfo& theMeshInfo, TErr* theErr) { @@ -452,6 +664,19 @@ namespace MED{ *theErr = aRet; else if(aRet < 0) EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)"); + + + GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; } void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, @@ -472,8 +697,6 @@ namespace MED{ MED::TPolygoneInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); med_connectivite& aConn = static_cast(theInfo.myTConn); @@ -490,43 +713,17 @@ namespace MED{ else if(aRet < 0) EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)"); - if (anIsElemNames){ - aRet = MEDnomEcr(myFile->Id(), - &aMeshInfo.myName[0], - &anInfo.myElemNames[0], - anInfo.myElemNames.size(), - anEntity, - MED_POLYGONE); - if(theErr) - *theErr = aRet; - else if(aRet < 0) - EXCEPTION(runtime_error,"SetPolygoneInfo - MEDnomEcr(...)"); - } - - if (anIsElemNum){ - aRet = MEDnumEcr(myFile->Id(), - &aMeshInfo.myName[0], - &anInfo.myElemNum[0], - anInfo.myElemNum.size(), - anEntity, - MED_POLYGONE); - if(theErr) - *theErr = aRet; - else if(aRet < 0) - EXCEPTION(runtime_error,"SetPolygoneInfo - MEDnumEcr(...)"); - } + SetNames(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; - aRet = MEDfamEcr(myFile->Id(), - &aMeshInfo.myName[0], - &anInfo.myFamNum[0], - anInfo.myFamNum.size(), - anEntity, - MED_POLYGONE); + SetNumeration(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + SetFamilies(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet); if(theErr) *theErr = aRet; - else if(aRet < 0) - EXCEPTION(runtime_error,"SetPolygoneInfo - MEDfamEcr(...)"); } TInt TVWrapper::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, @@ -598,6 +795,18 @@ namespace MED{ *theErr = aRet; else if(aRet < 0) EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)"); + + GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + + GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + + GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; } void TVWrapper::SetPolyedreInfo(const TPolyedreInfo& theInfo, @@ -948,8 +1157,9 @@ namespace MED{ TGeom& theGeom, TErr* theErr) { + theEntity = EEntiteMaillage(-1); TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); - + if(theErr){ *theErr &= !theEntityInfo.empty(); if(!*theErr) @@ -971,9 +1181,12 @@ namespace MED{ const med_geometrie_element& aGeom = static_cast(anGeomIter->first); TInt aTmp = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); aNbTimeStamps = max(aTmp,aNbTimeStamps); + if (aNbTimeStamps<1) + continue; BEGMSG(MYDEBUG,"GetNbTimeStamps aNbTimeStamps="<second; } } @@ -1102,8 +1315,9 @@ namespace MED{ if(aRet >= 0) for(TInt i = 0; i < iEnd; i++) { aValue[i] = anArray[i]; - MSG(MYDEBUG," "<