]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix on [Bug PAL7927] REGRESSION: It is an incorrect import of the MED file and incorr...
authorapo <apo@opencascade.com>
Mon, 31 Jan 2005 13:49:06 +0000 (13:49 +0000)
committerapo <apo@opencascade.com>
Mon, 31 Jan 2005 13:49:06 +0000 (13:49 +0000)
src/MEDWrapper/Base/MED_Algorithm.cxx
src/MEDWrapper/Base/MED_Algorithm.hxx
src/MEDWrapper/Base/MED_Common.hxx
src/MEDWrapper/Base/MED_Wrapper.cxx
src/MEDWrapper/Factory/MED_Test.cxx
src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx
src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx

index 128dfa2eadf3501038b042acaa2a25d9f36cbc1f..59dd4e54ea6f284ef0c3972ae1c890acfecd2512 100644 (file)
  
 #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<EEntiteMaillage,TFamilyIdSet> 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 = '"<<aFamilyInfo->GetName()<<
-                   "' anId = "<<aFamilyInfo->GetId()<<"\n");
+             aFamilyByEntity[anEntity].insert(aFamilyInfo);
+             INITMSG(MYDEBUG,
+                     "aFamilyName = '"<<aFamilyInfo->GetName()<<
+                     "' anId = "<<aFamilyInfo->GetId()<<"\n");
            }
          }
        }
index e72917a743aa47259758a353d535bdb8450a9b14..d688f5135baa817405962203a68a4a0a067b2c8c 100644 (file)
@@ -36,8 +36,8 @@
 
 namespace MED{
   //---------------------------------------------------------------
-  typedef std::set<PElemInfo> TElemSet;
-  typedef std::map<EEntiteMaillage,TElemSet> TElemGroup;
+  typedef std::map<EGeometrieElement,PElemInfo> TElemMap;
+  typedef std::map<EEntiteMaillage,TElemMap> TElemGroup;
 
   TElemGroup GetElemsByEntity(TWrapper& theWrapper, 
                              const PMeshInfo& theMeshInfo,
@@ -55,7 +55,6 @@ namespace MED{
   typedef std::map<EEntiteMaillage,TFamilyGroup> TFamilyByEntity;
   
   TFamilyByEntity GetFamiliesByEntity(TWrapper& theWrapper, 
-                                     const PNodeInfo& theNodeInfo, 
                                      const TElemGroup& theElemGroup,
                                      const TFamilyGroup& theFamilyGroup);
 
index b3b5d9fa81a676318129d2e66a2c703b394d2cb2..c2ae4252289d9c4ff0ed64c209e35e1c4560b191 100644 (file)
@@ -53,14 +53,36 @@ namespace MED{
     SharedPtr() {}
 
     template<class Y>
-    explicit SharedPtr(Y * p): boost::shared_ptr<T>(p) {}
+    explicit SharedPtr(Y * p): 
+      boost::shared_ptr<T>(p) 
+    {}
 
     template<class Y>
-    SharedPtr(SharedPtr<Y> const & r): boost::shared_ptr<T>(r) {}
+    SharedPtr(SharedPtr<Y> const & r):
+      boost::shared_ptr<T>(r,boost::detail::polymorphic_cast_tag())
+    {}
 
-    operator const T& () const { return *get();}
+    template<class Y>
+    SharedPtr& operator=(SharedPtr<Y> const & r)
+    {
+      boost::shared_ptr<T>(r,boost::detail::polymorphic_cast_tag()).swap(*this);
+      return *this;
+    }
 
-    operator T& () { return *get();}
+    template<class Y> SharedPtr& operator()(Y * p) // Y must be complete
+    {
+      return operator=<Y>(SharedPtr<Y>(p));
+    }
+
+    operator const T& () const 
+    { 
+      return *get();
+    }
+
+    operator T& () 
+    { 
+      return *get();
+    }
   };
 
 
index 38024b8b9d23796ab526c78f70b448aaede02702..9f69a0cfdac844e2c06c6ff6c448295795c5618b 100644 (file)
@@ -40,9 +40,10 @@ namespace MED{
 
 #ifdef _DEBUG_
     string aName = anInfo->GetName();
-    INITMSG(MYDEBUG,
-           "aFamilyName = '"<<aName<<"'; andId = "<<anInfo->GetId()<<
-           "; aNbAttr = "<<aNbAttr<<"; aNbGroup = "<<aNbGroup<<"\n");
+    INITMSG(MYDEBUG,"GetPFamilyInfo - aFamilyName = '"<<aName<<
+           "'; andId = "<<anInfo->GetId()<<
+           "; aNbAttr = "<<aNbAttr<<
+           "; aNbGroup = "<<aNbGroup<<"\n");
     for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
       aName = anInfo->GetGroupName(iGroup);
       INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
@@ -104,6 +105,7 @@ namespace MED{
     TInt aNbConn = GetNbPolygoneConn(*theMeshInfo,theEntity,theGeom,theConn);
     PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo,aNbElem,aNbConn,theEntity,theGeom,theConn);
     GetPolygoneInfo(*anInfo);
+
 #ifdef _DEBUG_
     TElemNum aConn  = anInfo->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 = "<<aNbComp<<
+           "; aType = "<<anInfo->GetType()<<"\n");
+#endif
+    
     return anInfo;
   }
 
@@ -228,6 +239,13 @@ namespace MED{
   {
     PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo,theEntity,theGeom);
     GetTimeStampInfo(theId,*anInfo,theErr);
+
+#ifdef _DEBUG_
+    INITMSG(MYDEBUG,
+           "GetPTimeStampInfo - aNbGauss = "<<anInfo->GetNbGauss()<<
+           "; aNumDt = "<<anInfo->GetNumDt()<<"\n");
+#endif
+
     return anInfo;
   }
 
@@ -238,6 +256,33 @@ namespace MED{
   {
     PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
     GetTimeStampVal(*anInfo,theErr);
+
+#ifdef _DEBUG_
+    TInt aNbGauss = theTimeStampInfo->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 = "<<aGeom<<" - "<<iElemEnd<<": ");
+      for(TInt iElem = 0, anId = 0; iElem < iElemEnd; iElem++){
+       ADDMSG(MYVALUEDEBUG,"{");
+       for(TInt iComp = 0; iComp < aNbComp; iComp++){
+         for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+           ADDMSG(MYVALUEDEBUG,aValue[anId++]<<" ");
+         }
+         ADDMSG(MYVALUEDEBUG,"| ");
+       }
+       ADDMSG(MYVALUEDEBUG,"} ");
+      }
+      ADDMSG(MYDEBUG,"\n");
+    }
+#endif
+
     return anInfo;
   }
 }
index 39d0ed31667d7b869cfe818b1e30de61027bb6ac..80ce383ad32961660979cd99dae52ab65f606d9a 100644 (file)
@@ -38,7 +38,7 @@ static int MYDEBUG = 0;
 
 static int MYVALUEDEBUG = 0;
 
-static int MYWRITEDEBUG = 0;
+static int MYWRITEDEBUG = 1;
 
 using namespace MED;
 
@@ -57,21 +57,36 @@ void CheckMed(const std::string& theFileName)
 
       //continue;
 
-      PNodeInfo aNodeInfo = aMed->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");
index c68a9aed7e027c193db417ee8ad59981278cf67c..9dc64affcd2f80d6ddddbd82aa15a1fe2847d2c8 100644 (file)
@@ -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 == "<<iEnd<<" != aValue.size() == "<<aValue.size());
+         EXCEPTION(runtime_error,
+                   "GetTimeStampInfo - iEnd("<<iEnd<<
+                   ") != aValue.size()("<<aValue.size()<<
+                   "); aNbVal = "<<aNbVal<<
+                   "; anEntity = "<<anEntity<<
+                   "; aGeom = "<<aGeom);
        }
        
        TErr aRet;
index 6a923420212a96fc0645764f21135cecf84cce2d..e744c183f2db6c352f953975e40a2c8403b44629 100644 (file)
@@ -1161,12 +1161,11 @@ namespace MED{
       TFileWrapper aFileWrapper(myFile,eLECTURE,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();
@@ -1206,12 +1205,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;
@@ -1243,7 +1241,7 @@ namespace MED{
        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;
     }
     
@@ -1278,7 +1276,7 @@ namespace MED{
                              aPflMode);
        if(aNbVal <= 0){
          if(theErr){
-           *theErr = MED_FAUX;
+           *theErr = -1;
            return;
          }
          EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
@@ -1289,10 +1287,15 @@ namespace MED{
        
        if(iEnd != aValue.size()){
          if(theErr){
-           *theErr = MED_FAUX;
+           *theErr = -1;
            return;
          }
-         EXCEPTION(runtime_error,"GetTimeStampInfo - iEnd == "<<iEnd<<" != aValue.size() == "<<aValue.size());
+         EXCEPTION(runtime_error,
+                   "GetTimeStampInfo - iEnd("<<iEnd<<
+                   ") != aValue.size()("<<aValue.size()<<
+                   "); aNbVal = "<<aNbVal<<
+                   "; anEntity = "<<anEntity<<
+                   "; aGeom = "<<aGeom);
        }
        
        TErr aRet;
@@ -1313,11 +1316,8 @@ namespace MED{
                              aTimeStampInfo.myNumDt,
                              aTimeStampInfo.myNumOrd);
          if(aRet >= 0) 
-           for(TInt i = 0; i < iEnd; i++) {
+           for(TInt i = 0; i < iEnd; i++)
              aValue[i] = anArray[i];
-             ADDMSG(MYDEBUG," "<<anArray[i]);
-           }
-         ADDMSG(MYDEBUG,endl);
          break;
        }
        default: {