From: apo Date: Mon, 31 Jan 2005 13:49:06 +0000 (+0000) Subject: Fix on [Bug PAL7927] REGRESSION: It is an incorrect import of the MED file and incorr... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=008e91cede0423e62beb548c7627ed777fba40aa;p=modules%2Fyacs.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/MEDWrapper/Base/MED_Algorithm.cxx b/src/MEDWrapper/Base/MED_Algorithm.cxx index 128dfa2ea..59dd4e54e 100644 --- a/src/MEDWrapper/Base/MED_Algorithm.cxx +++ b/src/MEDWrapper/Base/MED_Algorithm.cxx @@ -31,10 +31,8 @@ #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYVALUEDEBUG = 0; #else static int MYDEBUG = 0; -static int MYVALUEDEBUG = 0; #endif namespace MED{ @@ -49,31 +47,30 @@ namespace MED{ MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin(); for(; anIter != theEntityInfo.end(); anIter++){ const EEntiteMaillage& anEntity = anIter->first; - if(anEntity == eNOEUD) continue; const MED::TGeom& aGeom = anIter->second; - TElemSet& aElemSet = aGroup[anEntity]; + TElemMap& anElemMap = aGroup[anEntity]; + + if(anEntity == eNOEUD){ + anElemMap[ePOINT1] = theWrapper.GetPNodeInfo(theMeshInfo); + continue; + } + MED::TGeom::const_iterator anGeomIter = aGeom.begin(); for(; anGeomIter != aGeom.end(); anGeomIter++){ const EGeometrieElement& aGeo = anGeomIter->first; switch(aGeo){ - case ePOLYGONE: - { - PPolygoneInfo aPolygoneInfo = theWrapper.GetPPolygoneInfo(theMeshInfo,anEntity,aGeo); - aElemSet.insert(aPolygoneInfo); - break; - } - case ePOLYEDRE: - { - PPolyedreInfo aPolyedreInfo = theWrapper.GetPPolyedreInfo(theMeshInfo,anEntity,aGeo); - aElemSet.insert(aPolyedreInfo); - break; - } - default: - { - PCellInfo aCellInfo = theWrapper.GetPCellInfo(theMeshInfo,anEntity,aGeo); - aElemSet.insert(aCellInfo); - } + case ePOLYGONE: { + anElemMap[ePOLYGONE] = theWrapper.GetPPolygoneInfo(theMeshInfo,anEntity,aGeo); + break; } + case ePOLYEDRE: { + anElemMap[ePOLYEDRE] = theWrapper.GetPPolyedreInfo(theMeshInfo,anEntity,aGeo); + break; + } + default: { + anElemMap[aGeo] = theWrapper.GetPCellInfo(theMeshInfo,anEntity,aGeo); + }} + } } ADDMSG(MYDEBUG,"\n"); @@ -186,7 +183,6 @@ namespace MED{ TFamilyByEntity GetFamiliesByEntity(TWrapper& theWrapper, - const PNodeInfo& theNodeInfo, const TElemGroup& theElemGroup, const TFamilyGroup& theFamilyGroup) { @@ -206,24 +202,15 @@ namespace MED{ typedef map TFamilyIdByEntity; TFamilyIdByEntity aFamilyIdByEntity; - if(theNodeInfo!=0){ - if(TInt aNbElem = theNodeInfo->GetNbElem()){ - TFamilyIdSet& aFamilyIdSet = aFamilyIdByEntity[eNOEUD]; - for(TInt i = 0; i < aNbElem; i++){ - aFamilyIdSet.insert(theNodeInfo->GetFamNum(i)); - } - } - } - if(!theElemGroup.empty()){ TElemGroup::const_iterator anIter = theElemGroup.begin(); for(; anIter != theElemGroup.end(); anIter++){ const EEntiteMaillage& anEntity = anIter->first; TFamilyIdSet& aFamilyIdSet = aFamilyIdByEntity[anEntity]; - const TElemSet& aElemSet = anIter->second; - TElemSet::const_iterator anElemIter = aElemSet.begin(); - for(; anElemIter != aElemSet.end(); anElemIter++){ - const PElemInfo& aElemInfo = *anElemIter; + const TElemMap& anElemMap = anIter->second; + TElemMap::const_iterator anElemIter = anElemMap.begin(); + for(; anElemIter != anElemMap.end(); anElemIter++){ + const PElemInfo& aElemInfo = anElemIter->second; if(TInt aNbElem = aElemInfo->GetNbElem()){ for(TInt i = 0; i < aNbElem; i++){ aFamilyIdSet.insert(aElemInfo->GetFamNum(i)); @@ -246,10 +233,10 @@ namespace MED{ anFamilyByIdMapIter = aFamilyByIdMap.find(aFamilyId); if(anFamilyByIdMapIter != aFamilyByIdMap.end()){ const PFamilyInfo& aFamilyInfo = anFamilyByIdMapIter->second; - aFamilyByEntity[anEntity].insert(aFamilyInfo); - INITMSG(MYDEBUG, - "aFamilyName = '"<GetName()<< - "' anId = "<GetId()<<"\n"); + aFamilyByEntity[anEntity].insert(aFamilyInfo); + INITMSG(MYDEBUG, + "aFamilyName = '"<GetName()<< + "' anId = "<GetId()<<"\n"); } } } diff --git a/src/MEDWrapper/Base/MED_Algorithm.hxx b/src/MEDWrapper/Base/MED_Algorithm.hxx index e72917a74..d688f5135 100644 --- a/src/MEDWrapper/Base/MED_Algorithm.hxx +++ b/src/MEDWrapper/Base/MED_Algorithm.hxx @@ -36,8 +36,8 @@ namespace MED{ //--------------------------------------------------------------- - typedef std::set TElemSet; - typedef std::map TElemGroup; + typedef std::map TElemMap; + typedef std::map TElemGroup; TElemGroup GetElemsByEntity(TWrapper& theWrapper, const PMeshInfo& theMeshInfo, @@ -55,7 +55,6 @@ namespace MED{ typedef std::map TFamilyByEntity; TFamilyByEntity GetFamiliesByEntity(TWrapper& theWrapper, - const PNodeInfo& theNodeInfo, const TElemGroup& theElemGroup, const TFamilyGroup& theFamilyGroup); diff --git a/src/MEDWrapper/Base/MED_Common.hxx b/src/MEDWrapper/Base/MED_Common.hxx index b3b5d9fa8..c2ae42522 100644 --- a/src/MEDWrapper/Base/MED_Common.hxx +++ b/src/MEDWrapper/Base/MED_Common.hxx @@ -53,14 +53,36 @@ namespace MED{ SharedPtr() {} template - explicit SharedPtr(Y * p): boost::shared_ptr(p) {} + explicit SharedPtr(Y * p): + boost::shared_ptr(p) + {} template - SharedPtr(SharedPtr const & r): boost::shared_ptr(r) {} + SharedPtr(SharedPtr const & r): + boost::shared_ptr(r,boost::detail::polymorphic_cast_tag()) + {} - operator const T& () const { return *get();} + template + SharedPtr& operator=(SharedPtr const & r) + { + boost::shared_ptr(r,boost::detail::polymorphic_cast_tag()).swap(*this); + return *this; + } - operator T& () { return *get();} + template SharedPtr& operator()(Y * p) // Y must be complete + { + return operator=(SharedPtr(p)); + } + + operator const T& () const + { + return *get(); + } + + operator T& () + { + return *get(); + } }; diff --git a/src/MEDWrapper/Base/MED_Wrapper.cxx b/src/MEDWrapper/Base/MED_Wrapper.cxx index 38024b8b9..9f69a0cfd 100644 --- a/src/MEDWrapper/Base/MED_Wrapper.cxx +++ b/src/MEDWrapper/Base/MED_Wrapper.cxx @@ -40,9 +40,10 @@ namespace MED{ #ifdef _DEBUG_ string aName = anInfo->GetName(); - INITMSG(MYDEBUG, - "aFamilyName = '"<GetGroupName(iGroup); INITMSG(MYDEBUG,"aGroupName = '"<GetConnectivite(); TElemNum aIndex = anInfo->GetIndex(); @@ -117,12 +119,13 @@ namespace MED{ aIndex0 = aIndex[iElem]; } ADDMSG(MYDEBUG,endl); - ADDMSG(MYDEBUG," Indexes :"); + BEGMSG(MYDEBUG,"Indexes: "); for(TInt iElem = 0; iElem < aIndex.size(); iElem++){ ADDMSG(MYVALUEDEBUG,aIndex[iElem]<<","); } ADDMSG(MYDEBUG,endl); #endif + return anInfo; } @@ -138,6 +141,7 @@ namespace MED{ GetNbPolyedreConnF(*theMeshInfo,theConn,aNbFaces,aNbConn); PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo,aNbElem,aNbConn,aNbFaces,theEntity,theGeom,theConn); GetPolyedreInfo(*anInfo); + #ifdef _DEBUG_ TElemNum aConn = anInfo->GetConnectivite(); TElemNum aFacesIndex = anInfo->GetFacesIndex(); @@ -160,6 +164,7 @@ namespace MED{ } } #endif + return anInfo; } @@ -199,7 +204,6 @@ namespace MED{ } ADDMSG(MYDEBUG,endl); } - ADDMSG(MYDEBUG,endl); #endif @@ -215,6 +219,13 @@ namespace MED{ TInt aNbComp = GetNbComp(theId); PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp); GetFieldInfo(theId,*anInfo,theErr); + +#ifdef _DEBUG_ + INITMSG(MYDEBUG, + "GetPFieldInfo - aNbComp = "<GetNbGauss(); + PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo(); + TInt aNbComp = aFieldInfo->GetNbComp(); + INITMSG(MYDEBUG,"GetPTimeStampVal\n"); + TMeshValue& aMeshValue = anInfo->myMeshValue; + TMeshValue::const_iterator aMeshValueIter = aMeshValue.begin(); + for(; aMeshValueIter != aMeshValue.end(); aMeshValueIter++){ + const EGeometrieElement& aGeom = aMeshValueIter->first; + const TValue& aValue = aMeshValueIter->second; + TInt iElemEnd = aValue.size() / aNbComp / aNbGauss; + INITMSG(MYDEBUG,"aGeom = "<GetPNodeInfo(aMeshInfo); - TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); - TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aElemGroup,aFamilyGroup); + TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup); TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); TTimeStampGroup aTimeStampGroup = GetFieldsByEntity(aMed,aMeshInfo,aEntityInfo); TFieldGroup aFieldGroup = GetFieldsByEntity(aTimeStampGroup); + + TFieldGroup::const_iterator aFieldGroupIter = aFieldGroup.begin(); + for(; aFieldGroupIter != aFieldGroup.end(); aFieldGroupIter++){ + const TTimeStampGroup& aTTimeStampGroup = aFieldGroupIter->second; + TTimeStampGroup::const_iterator aTTimeStampGroupIter = aTTimeStampGroup.begin(); + for(; aTTimeStampGroupIter != aTTimeStampGroup.end(); aTTimeStampGroupIter++){ + PFieldInfo aFieldInfo = aTTimeStampGroupIter->first; + const TTimeStampSet& aTimeStampSet = aTTimeStampGroupIter->second; + TTimeStampSet::const_iterator aTTimeStampSetIter = aTimeStampSet.begin(); + for(; aTTimeStampSetIter != aTimeStampSet.end(); aTTimeStampSetIter++){ + PTimeStampInfo aTimeStampInfo = *aTTimeStampSetIter; + TErr anErr; + PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,&anErr); + } + } + } + } } MSG(MYDEBUG,"OK"); diff --git a/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx b/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx index c68a9aed7..9dc64affc 100644 --- a/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx +++ b/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx @@ -673,12 +673,11 @@ namespace MED{ TFileWrapper aFileWrapper(myFile,eLECT,theErr); if(theErr){ - *theErr &= !theEntityInfo.empty(); - if(!*theErr) + if(theEntityInfo.empty()) + *theErr = -1; + if(*theErr < 0) return -1; - } - - if(theEntityInfo.empty()) + }else if(theEntityInfo.empty()) EXCEPTION(runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh"); theGeom.clear(); @@ -713,12 +712,11 @@ namespace MED{ TGeom& aTGeom = theInfo.myGeom; if(theErr){ - *theErr &= !aTGeom.empty(); - if(!*theErr) + if(aTGeom.empty()) + *theErr = -1; + if(*theErr < 0) return; - } - - if(aTGeom.empty()) + }else if(aTGeom.empty()) EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell"); MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; @@ -740,13 +738,14 @@ namespace MED{ &theInfo.myUnitDt[0], &theInfo.myDt, &theInfo.myNumOrd); + if(theErr) *theErr = aRet; else if(aRet < 0) EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)"); static TInt MAX_NB_GAUSS_POINTS = 32; - if(theInfo.myNbGauss > MAX_NB_GAUSS_POINTS) + if(theInfo.myNbGauss <= 0 || theInfo.myNbGauss > MAX_NB_GAUSS_POINTS) theInfo.myNbGauss = 1; } @@ -792,7 +791,12 @@ namespace MED{ *theErr = -1; return; } - EXCEPTION(runtime_error,"GetTimeStampInfo - iEnd == "< MAX_NB_GAUSS_POINTS) + if(theInfo.myNbGauss <= 0 || theInfo.myNbGauss > MAX_NB_GAUSS_POINTS) theInfo.myNbGauss = 1; } @@ -1278,7 +1276,7 @@ namespace MED{ aPflMode); if(aNbVal <= 0){ if(theErr){ - *theErr = MED_FAUX; + *theErr = -1; return; } EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<