Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / CONVERTOR / VISU_MedConvertor.cxx
index 2eaddcfe6d7449aa0b81033270e69e4bc8fdec3b..c905b9eeac20e25dd3127e261feb2f0848c89cab 100644 (file)
@@ -34,8 +34,7 @@
 #include "MED_GaussUtils.hxx"
 #include "MED_Utilities.hxx"
 
-#include <boost/thread/thread.hpp>
-#include <boost/bind.hpp>
+#include "CASCatch.hxx"
 
 #include <vtkCellType.h>
 
@@ -894,14 +893,16 @@ namespace
   //---------------------------------------------------------------
   TGaussPointID
   TMEDGaussSubMesh
-  ::GetObjID(vtkIdType theID) const
+  ::GetObjID(vtkIdType theID,
+            vtkIdType theStartID) const
   {
-    TInt aNbPoints = myGauss->myNbPoints;
-    TCellID aCellID = theID / aNbPoints;
+    TCellID aCellID = theID / myGauss->myNbPoints;
+    TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
+    
     if(myIsElemNum)
       aCellID = myElemNum[aCellID];
-
-    TLocalPntID aLocalPntID = theID % aNbPoints;
+    else
+      aCellID += theStartID;
 
     return TGaussPointID(aCellID,aLocalPntID);
   }
@@ -913,7 +914,10 @@ namespace
   ::Init(const MED::PElemInfo& theElemInfo)
   {
     myIsElemNum = theElemInfo->IsElemNum();
-    myElemNum = theElemInfo->myElemNum;
+
+    if(myIsElemNum)
+      myElemNum = theElemInfo->myElemNum;
+
     if(theElemInfo->IsElemNames())
       myElemInfo = theElemInfo;
   }
@@ -958,7 +962,7 @@ extern "C"
 VISU_Convertor* 
 CreateConvertor(const string& theFileName)
 {
-  if(MED::PWrapper aMed = MED::CrWrapper(theFileName))
+  if(MED::PWrapper aMed = MED::CrWrapper(theFileName,true))
     return new VISU_MedConvertor(theFileName);
   return NULL;
 }
@@ -1190,80 +1194,85 @@ VISU_MedConvertor
            INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
            
 #ifndef _DEXCEPT_
-           try{
+           CASCatch_TRY{ 
+             try{
 #endif
-             MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
-                                                                          aMEntity,
-                                                                          aGeom2Size,
-                                                                          iTimeStamp);
-             
-             MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
-                                                                       aMKey2Profile,
-                                                                       aKey2Gauss);
-             
-             const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
-             
-             const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
-             
-             const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
-             MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
-             for(; anIter != aGeom2Value.end(); anIter++){
-               const MED::TMeshValue& aMMeshValue = anIter->second;
-               MED::EGeometrieElement aMGeom = anIter->first;
+               MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
+                                                                            aMEntity,
+                                                                            aGeom2Size,
+                                                                            iTimeStamp);
                
-               TInt aNbElem = aMMeshValue.myNbElem;
-               TInt aNbGauss = aMMeshValue.myNbGauss;
+               MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
+                                                                         aMKey2Profile,
+                                                                         aKey2Gauss);
                
-               MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
-               if(aGaussIter == aGeom2Gauss.end())
-                 aNbGauss = 1;
+               const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
                
-               INITMSG(MYDEBUG,
-                       "- aMGeom = "<<aMGeom<<
-                       "; aNbElem = "<<aNbElem<<
-                       "; aNbGauss = "<<aNbGauss<<
-                       endl);
+               const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
                
-               // To calculate min/max per components
-               for(TInt iElem = 0; iElem < aNbElem; iElem++){
-                 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
-                 for(TInt iComp = 0; iComp < aNbComp; iComp++){
-                   const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
-                   TMinMax& aMinMax = aMinMaxArr[iComp+1];
-                   float& aMin = aMinMax.first;
-                   float& aMax = aMinMax.second;
-                   for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
-                     const float& aVal = aMValueSlice[iGauss];
-                     aMin = min(aMin,aVal);
-                     aMax = max(aMax,aVal);
+               const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
+               MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
+               for(; anIter != aGeom2Value.end(); anIter++){
+                 const MED::TMeshValue& aMMeshValue = anIter->second;
+                 MED::EGeometrieElement aMGeom = anIter->first;
+                 
+                 TInt aNbElem = aMMeshValue.myNbElem;
+                 TInt aNbGauss = aMMeshValue.myNbGauss;
+                 
+                 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
+                 if(aGaussIter == aGeom2Gauss.end())
+                   aNbGauss = 1;
+                 
+                 INITMSG(MYDEBUG,
+                         "- aMGeom = "<<aMGeom<<
+                         "; aNbElem = "<<aNbElem<<
+                         "; aNbGauss = "<<aNbGauss<<
+                         endl);
+                 
+                 // To calculate min/max per components
+                 for(TInt iElem = 0; iElem < aNbElem; iElem++){
+                   MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+                   for(TInt iComp = 0; iComp < aNbComp; iComp++){
+                     const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
+                     TMinMax& aMinMax = aMinMaxArr[iComp+1];
+                     float& aMin = aMinMax.first;
+                     float& aMax = aMinMax.second;
+                     for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+                       const float& aVal = aMValueSlice[iGauss];
+                       aMin = min(aMin,aVal);
+                       aMax = max(aMax,aVal);
+                     }
                    }
                  }
-               }
-               
-               // To calculate min/max per vector modulus
-               TMinMax& aMinMax = aMinMaxArr[0];
-               float& aMin = aMinMax.first;
-               float& aMax = aMinMax.second;
-               for(TInt iElem = 0; iElem < aNbElem; iElem++){
-                 MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
-                 for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
-                   const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
-                   float aValue = 0.0;
-                   for(TInt iComp = 0; iComp < aNbComp2; iComp++){
-                     float aVal = aMValueSlice[iComp];
-                     aValue += aVal*aVal;
+                 
+                 // To calculate min/max per vector modulus
+                 TMinMax& aMinMax = aMinMaxArr[0];
+                 float& aMin = aMinMax.first;
+                 float& aMax = aMinMax.second;
+                 for(TInt iElem = 0; iElem < aNbElem; iElem++){
+                   MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
+                   for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+                     const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+                     float aValue = 0.0;
+                     for(TInt iComp = 0; iComp < aNbComp2; iComp++){
+                       float aVal = aMValueSlice[iComp];
+                       aValue += aVal*aVal;
+                     }
+                     aValue = sqrt(aValue);
+                     aMin = min(aMin,aValue);
+                     aMax = max(aMax,aValue);
                    }
-                   aValue = sqrt(aValue);
-                   aMin = min(aMin,aValue);
-                   aMax = max(aMax,aValue);
                  }
                }
-             }
 #ifndef _DEXCEPT_
-           }catch(std::exception& exc){
-             MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
-           }catch(...){
-             MSG(MYDEBUG,"Unknown exception !!!");
+             }catch(std::exception& exc){
+               MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+             }catch(...){
+               MSG(MYDEBUG,"Unknown exception !!!");
+             }
+           }CASCatch_CATCH(Standard_Failure){
+             Handle(Standard_Failure) aFail = Standard_Failure::Caught();          
+             MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
            }
 #endif
          }
@@ -2166,7 +2175,8 @@ LoadGaussMesh(const MED::PWrapper& theMed,
              "; aNbGauss = "<<aNbGauss<<
              "; aNbCells = "<<aNbCells<<
              endl);
-    }
+    }else
+      EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
   }
   
   aGaussMesh->myIsDone = true;