]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Initial patch for Bug GVIEW10573
authorapo <apo@opencascade.com>
Mon, 21 Nov 2005 07:24:11 +0000 (07:24 +0000)
committerapo <apo@opencascade.com>
Mon, 21 Nov 2005 07:24:11 +0000 (07:24 +0000)
 time to load sandia file too long

src/CONVERTOR/VISU_Convertor.hxx
src/CONVERTOR/VISU_ConvertorUtils.cxx
src/CONVERTOR/VISU_ConvertorUtils.hxx
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_IDMapper.hxx
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx
src/VISU_I/Makefile.in
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

index 4af7323bc76e4d04dfd45b2b2e12714acf29921d..ea3debee762b1a6d93276ecd682ca53cf409187d 100644 (file)
@@ -274,6 +274,26 @@ public:
   VISU_Convertor* 
   Build() = 0;
 
+  //! This method perform first parsing of MED file to get known what MED mesh entities are pressent in it
+  virtual
+  VISU_Convertor* 
+  BuildEntities() = 0;
+
+  //! This method perform first parsing of MED file to get known what MED fields are pressent in it
+  virtual
+  VISU_Convertor* 
+  BuildFields() = 0;
+
+  //! This min /max calculation over existing MED fields
+  virtual
+  VISU_Convertor* 
+  BuildMinMax() = 0;
+
+  //! This method perform first parsing of MED file to get known what MED groups are pressent in it
+  virtual
+  VISU_Convertor* 
+  BuildGroups() = 0;
+
   //! This method allow to get known what MED entities are present is the MED file
   virtual
   const VISU::TMeshMap& 
index ac737d3785875596569a9f7fe49feaf336e80128..622caf4ea799e81a8c95d2b8e8a905c1e4d1e426 100644 (file)
@@ -30,7 +30,7 @@
 #include <vtkTimerLog.h>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 2;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -49,20 +49,30 @@ namespace VISU
     aWriter->Delete();
   }
 
+
   TTimerLog
   ::TTimerLog(const std::string& theName):
     myTimerLog(vtkTimerLog::New()),
+    myPrefixPrinter(MYDEBUG == 1),
     myName(theName)
   {
     myCPUTime = myTimerLog->GetCPUTime();
+    BEGMSG(MYDEBUG > 1,"{\n");
   }
 
   TTimerLog
   ::~TTimerLog()
   {
     myCPUTime = myTimerLog->GetCPUTime() - myCPUTime;
-    INITMSG(MYDEBUG,"~TTimerLog for "<<myName<<" takes "<<myCPUTime<<" secs\n");
+
+    if(MYDEBUG > 1){
+      BEGMSG(MYDEBUG,"} = "<<myCPUTime<<" secs ("<<myName<<")\n");
+    }else{
+      BEGMSG(MYDEBUG,myName<<" takes "<<myCPUTime<<" secs\n");
+    }
+    
     myTimerLog->Delete();
+    myTimerLog = NULL;
   }
 
 }
index 124eb8d7ee1fe11d34581e1f8c6d4a3394fb8b79..ae2f0881dffc0950a4370ccb2526334c62ff7274 100644 (file)
 class vtkUnstructuredGrid;
 class vtkTimerLog;
 
+namespace MED
+{
+  class PrefixPrinter;
+}
+
 namespace VISU{
 
   void 
@@ -43,9 +48,10 @@ namespace VISU{
 
   class TTimerLog
   {
-    vtkTimerLog* myTimerLog;
     double myCPUTime;
     std::string myName;
+    vtkTimerLog* myTimerLog;
+    MED::PrefixPrinter myPrefixPrinter;
   public:
     TTimerLog(const std::string& theName);
     ~TTimerLog();
index d8c2c0efc98acb88e49859a9f7a28fb4d70596be..e7e13a26500da67d599afc3d33ab1d4d1e1e85ff 100644 (file)
@@ -1765,6 +1765,43 @@ VISU_Convertor_impl
 {}
 
 
+//---------------------------------------------------------------
+VISU_Convertor* 
+VISU_Convertor_impl
+::Build() 
+{ 
+  return this;
+}
+
+VISU_Convertor* 
+VISU_Convertor_impl
+::BuildEntities() 
+{ 
+  return this;
+}
+
+VISU_Convertor* 
+VISU_Convertor_impl
+::BuildFields() 
+{ 
+  return this;
+}
+
+VISU_Convertor* 
+VISU_Convertor_impl
+::BuildMinMax() 
+{ 
+  return this;
+}
+
+VISU_Convertor* 
+VISU_Convertor_impl
+::BuildGroups() 
+{ 
+  return this;
+}
+
+
 //---------------------------------------------------------------
 VISU::PNamedIDMapper 
 VISU_Convertor_impl
index 45d6531e1eb34b055ee78b0fe40ffd09bb1ba788..5e910090f274b7f5955bdba5a98bb34f5e528c1a 100644 (file)
@@ -770,10 +770,27 @@ public:
   //! Just to define default behaviour
   virtual
   VISU_Convertor* 
-  Build() 
-  { 
-    return this;
-  }
+  Build();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildEntities();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildFields();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildMinMax();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildGroups();
 
   //! Implemention of the VISU_Convertor::GetSize
   virtual 
index e4b2825f61516a514a8f000509b5aaf3c68b4c3b..57cf9ee79ae815204bb7e1f0ae186a827e472803 100644 (file)
@@ -51,6 +51,8 @@ namespace VISU
     //! Just to provide possibility of dynamic navigation through the class hierarchy
     virtual ~TBaseStructure()
     {}
+
+    std::string myEntry; //!< To simplify publication of the object tree
   };
   typedef SharedPtr<TBaseStructure> PBaseStructure;
 
index 8961e2b6240ab1388c754247b15e671ba604c566..c35eef812e8eee0106c16b1b8e77141c72510ccf 100644 (file)
@@ -47,18 +47,14 @@ using MED::TFloat;
 using MED::EBooleen;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 static int MYVALUEDEBUG = 0;
-static int MYMEMORYDEBUG = 0;
-static int MYTHREADDEBUG = 0;
 static int MY_FAMILY_DEBUG = 0;
 static int MY_GROUP_DEBUG = 0;
 #define _DEXCEPT_
 #else
 static int MYDEBUG = 0;
 static int MYVALUEDEBUG = 0;
-static int MYMEMORYDEBUG = 0;
-static int MYTHREADDEBUG = 0;
 static int MY_FAMILY_DEBUG = 0;
 static int MY_GROUP_DEBUG = 0;
 #endif
@@ -363,7 +359,6 @@ namespace
     PMEDProfile aProfile = theValForTime.myProfile;
     TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
 
-    const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
     const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
     const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
 
@@ -505,17 +500,15 @@ namespace
 
 
   //---------------------------------------------------------------
-  typedef std::map<TInt,TInt> TFamilyCounterMap;
-
   void
   BuildMeshOnEntityMap(PMEDMesh theMesh,
-                      TFamilyCounterMap& theFamilyID2CellsSize,
                       const MED::TEntityInfo& theEntityInfo,
                       const MED::PNodeInfo& theNodeInfo,
                       const MED::PWrapper& theMEDWrapper)
   {
     TTimerLog aTimerLog("BuildMeshOnEntityMap");
     INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
+
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
     const std::string& aMeshName = theMesh->myName;
     TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
@@ -529,7 +522,8 @@ namespace
       aMeshOnEntity->myEntity = aVEntity;
       aMeshOnEntity->myMeshName = aMeshName;
       aMeshOnEntity->myGeom2Size = aGeom2Size;
-      
+      TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+
       INITMSG(MYDEBUG,
              "- aMEntity = "<<aMEntity<<
              "; aVEntity = "<<aVEntity<<
@@ -542,7 +536,7 @@ namespace
        for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
          TInt aFamId = theNodeInfo->GetFamNum(iElem);
          if(aFamId != 0)
-           theFamilyID2CellsSize[aFamId] += 2;
+           aFamilyID2CellsSize[aFamId] += 2;
        }
        
        INITMSG(MYDEBUG,
@@ -573,7 +567,7 @@ namespace
              aMeshOnEntity->myCellsSize += aNbConn;
              TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
              if(aFamId != 0)
-               theFamilyID2CellsSize[aFamId] += aNbConn + 1;
+               aFamilyID2CellsSize[aFamId] += aNbConn + 1;
            }
            break;
          }
@@ -599,7 +593,7 @@ namespace
              aMeshOnEntity->myCellsSize += aCellSize;
              TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
              if(aFamId != 0)
-               theFamilyID2CellsSize[aFamId] += aCellSize + 1;
+               aFamilyID2CellsSize[aFamId] += aCellSize + 1;
            }
            break;
          }
@@ -621,7 +615,7 @@ namespace
            for(TInt iElem = 0; iElem < aNbElem; iElem++){
              TInt aFamId = aCellInfo->GetFamNum(iElem);
              if(aFamId != 0)
-               theFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
+               aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
            }
          }} // end switch(...)
        }
@@ -630,233 +624,10 @@ namespace
   }
 
 
-  //---------------------------------------------------------------
-  struct TFieldMinMax
-  {
-    VISU::PMEDField myField;
-    MED::PFieldInfo myFieldInfo;
-    TInt myNbTimeStamps;
-    MED::EEntiteMaillage myMEntity;
-    MED::TGeom2Size myGeom2Size;
-    MED::TMKey2Profile myMKey2Profile;
-    MED::TKey2Gauss myKey2Gauss;
-    MED::PWrapper myMEDWrapper;
-
-    TFieldMinMax(const VISU::PMEDField& theField,
-                const MED::PFieldInfo& theFieldInfo,
-                TInt theNbTimeStamps,
-                MED::EEntiteMaillage theMEntity,
-                const MED::TGeom2Size& theGeom2Size,
-                const MED::TMKey2Profile& theMKey2Profile,
-                const MED::TKey2Gauss& theKey2Gauss,
-                const MED::PWrapper& theMEDWrapper):
-      myField(theField),
-      myFieldInfo(theFieldInfo),
-      myNbTimeStamps(theNbTimeStamps),
-      myMEntity(theMEntity),
-      myGeom2Size(theGeom2Size),
-      myMKey2Profile(theMKey2Profile),
-      myKey2Gauss(theKey2Gauss),
-      myMEDWrapper(theMEDWrapper)
-    {
-      INITMSG(MYMEMORYDEBUG,"TFieldMinMax() - "<<this<<endl);
-    }
-
-    ~TFieldMinMax()
-    {
-      INITMSG(MYMEMORYDEBUG,"~TFieldMinMax() - "<<this<<endl);
-    }
-
-    void
-    Calculate()
-    {
-      INITMSG(MYTHREADDEBUG,"TFieldMinMax::Calculate() - "<<this<<
-             "; aFieldName = '"<<myField->myName<<"'"<<
-             "; myNbTimeStamps = "<<myNbTimeStamps<<
-             endl);
-      
-      TInt aNbComp = myField->myNbComp;
-      int aNbComp2 = aNbComp;
-      if(aNbComp == 2 || aNbComp == 4)
-       aNbComp2 = 2;
-      else if(aNbComp > 4)
-       aNbComp2 = 3;
-
-      TValField& aValField = myField->myValField;
-      TMinMaxArr& aMinMaxArr = myField->myMinMaxArr;
-      for(TInt iTimeStamp = 1; iTimeStamp <= myNbTimeStamps; iTimeStamp++){
-       INITMSG(MYTHREADDEBUG,"- "<<this<<"; iTimeStamp = "<<iTimeStamp<<endl);
-       
-       MED::PTimeStampInfo aTimeStampInfo = myMEDWrapper->GetPTimeStampInfo(myFieldInfo,
-                                                                            myMEntity,
-                                                                            myGeom2Size,
-                                                                            iTimeStamp);
-       MED::PTimeStampVal aTimeStampVal = myMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
-                                                                         myMKey2Profile,
-                                                                         myKey2Gauss);
-       PMEDValForTime aValForTime = aValField[iTimeStamp];
-       
-       const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
-       
-       PMEDProfile aProfile = aValForTime->myProfile;
-       TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
-       TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
-       for(; anIter != aGeom2SubProfile.end(); anIter++){
-         VISU::EGeometry aEGeom = anIter->first;
-         PMEDSubProfile aSubProfile(anIter->second);
-         
-         TInt aNbElem = aSubProfile->myNbCells;
-         TInt aNbGauss = aValForTime->GetNbGauss(aEGeom);
-         
-         if(aSubProfile->myStatus != eRemoveAll){
-           INITMSG(MYTHREADDEBUG,
-                   "- "<<this<< 
-                   "; aEGeom = "<<aEGeom<<
-                   "; aNbElem = "<<aNbElem<<
-                   "; aNbGauss = "<<aNbGauss<<
-                   endl);
-           
-           MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
-           const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
-
-           // 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;
-               }
-               aValue = sqrt(aValue);
-               aMin = min(aMin,aValue);
-               aMax = max(aMax,aValue);
-             }
-           }
-         }
-       }
-      }
-      for(TInt iComp = 0; iComp <= aNbComp; iComp++){
-       VISU::TMinMax aMinMax = myField->GetMinMax(iComp);
-       INITMSG(MYTHREADDEBUG,"- "<<this<<"; "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
-      }
-    }
-  };
-  typedef SharedPtr<TFieldMinMax> PFieldMinMax;
-
-
-  //---------------------------------------------------------------
-  void
-  GetFieldMinMax(PFieldMinMax theFieldMinMax)
-  {
-    theFieldMinMax->Calculate();
-  }
-
-
-  //---------------------------------------------------------------
-  struct TCalculateMinMax
-  {
-    VISU::PMEDMesh myMesh;
-    MED::TEntityInfo myEntityInfo;
-    MED::TMKey2Profile myMKey2Profile;
-    MED::TKey2Gauss myKey2Gauss;
-    MED::PWrapper myMEDWrapper;
-
-    TCalculateMinMax(const VISU::PMEDMesh& theMesh,
-                    const MED::TEntityInfo& theEntityInfo,
-                    const MED::TMKey2Profile& theMKey2Profile,
-                    const MED::TKey2Gauss& theKey2Gauss,
-                    const MED::PWrapper& theMEDWrapper):
-      myMesh(theMesh),
-      myEntityInfo(theEntityInfo),
-      myMKey2Profile(theMKey2Profile),
-      myKey2Gauss(theKey2Gauss),
-      myMEDWrapper(theMEDWrapper)
-    {
-      INITMSG(MYMEMORYDEBUG,"TCalculateMinMax() - "<<this<<endl);
-    }
-
-    ~TCalculateMinMax()
-    {
-      INITMSG(MYMEMORYDEBUG,"~TCalculateMinMax() - "<<this<<endl);
-    }
-
-    void
-    Calculate()
-    {
-      TInt aNbFields = myMEDWrapper->GetNbFields(); 
-      MED::PMeshInfo aMeshInfo = myMesh->myMeshInfo;
-      const std::string& aMeshName = myMesh->myName;
-      INITMSG(MYDEBUG,"MinMaxCalculation: aNbFields = "<<aNbFields<<"\n");
-      for(TInt iField = 1; iField <= aNbFields; iField++){
-       MED::PFieldInfo aFieldInfo = myMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
-       TInt aNbComp = aFieldInfo->GetNbComp();
-       std::string aFieldName = aFieldInfo->GetName();
-       
-       MED::TGeom2Size aGeom2Size;
-       MED::EEntiteMaillage aMEntity;
-       TInt aNbTimeStamps = myMEDWrapper->GetNbTimeStamps(aFieldInfo,
-                                                           myEntityInfo,
-                                                           aMEntity,
-                                                           aGeom2Size);
-       if(aNbTimeStamps < 1)
-         continue;
-       
-       TEntity aVEntity = MEDEntityToVTK(aMEntity);
-       PMEDMeshOnEntity aMeshOnEntity = myMesh->myMeshOnEntityMap[aVEntity];
-       TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-       PMEDField aField = aFieldMap[aFieldName];
-       
-       PFieldMinMax aFieldMinMax(new TFieldMinMax(aField,
-                                                  aFieldInfo,
-                                                  aNbTimeStamps,
-                                                  aMEntity,
-                                                  aGeom2Size,
-                                                  myMKey2Profile,
-                                                  myKey2Gauss,
-                                                  myMEDWrapper));
-       
-       boost::thread aThread(boost::bind(&GetFieldMinMax,aFieldMinMax));
-      }
-    }
-  };
-  typedef SharedPtr<TCalculateMinMax> PCalculateMinMax;
-
-
-  //---------------------------------------------------------------
-  void
-  CalculateMinMax(PCalculateMinMax theCalculateMinMax)
-  {
-    theCalculateMinMax->Calculate();
-  }
-
-
   //---------------------------------------------------------------
   void
   BuildFieldMap(PMEDMesh theMesh,
                const MED::TEntityInfo& theEntityInfo,
-               const MED::TMKey2Profile& theMKey2Profile,
-               const MED::TKey2Gauss& theKey2Gauss,
                MED::PWrapper theMEDWrapper)
   {
     TTimerLog aTimerLog("BuildFieldMap");
@@ -865,7 +636,7 @@ namespace
     const std::string& aMeshName = theMesh->myName;
     INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
     for(TInt iField = 1; iField <= aNbFields; iField++){
-      TTimerLog aTimerLog("BuildFieldMap - GetPFieldInfo");
+      TTimerLog aTimerLog("GetPFieldInfo");
       MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
       TInt aNbComp = aFieldInfo->GetNbComp();
       std::string aFieldName = aFieldInfo->GetName();
@@ -902,36 +673,23 @@ namespace
       }
       
       for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
-       TTimerLog aTimerLog("BuildFieldMap - GetPTimeStampInfo");
+       TTimerLog aTimerLog("GetPTimeStampInfo");
        MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
                                                                              aMEntity,
                                                                              aGeom2Size,
                                                                              iTimeStamp);
        TFloat aDt = aTimeStampInfo->GetDt();
        std::string anUnitDt = aTimeStampInfo->GetUnitDt();
-       {
-         TTimerLog aTimerLog("BuildFieldMap - GetPTimeStampVal");
-         MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
-                                                                            theMKey2Profile,
-                                                                            theKey2Gauss);
-         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->myNbGauss = aTimeStampInfo->GetNbGauss();
-         aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
-         INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
-         
-         InitGaussProfile(theMEDWrapper,
-                          aMeshInfo,
-                          aTimeStampVal,
-                          aMeshOnEntity,
-                          aMEntity,
-                          aGeom2Size,
-                          aValForTime);
-       }
+
+       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->myNbGauss = aTimeStampInfo->GetNbGauss();
+       aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
+       INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
       }
     }
   }
@@ -940,7 +698,6 @@ namespace
   //---------------------------------------------------------------
   void
   BuildFamilyMap(PMEDMesh theMesh,
-                const TFamilyCounterMap& theFamilyID2CellsSize,
                 const MED::TEntityInfo& theEntityInfo,
                 const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
                 const MED::TFamilyInfoSet& theFamilyInfoSet,
@@ -948,6 +705,7 @@ namespace
   {
     TTimerLog aTimerLog("BuildFamilyMap");
     INITMSG(MYDEBUG,"BuildFamilyMap\n");
+
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
     MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
     MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
@@ -957,6 +715,7 @@ namespace
       
       TEntity aVEntity = MEDEntityToVTK(aMEntity);
       PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+      const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
       TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
        
       if(aFamilyTSizeSet.empty())
@@ -985,8 +744,8 @@ namespace
        aFamily->myNbCells = aSize;
 
        aFamily->myCellsSize = 0;
-       TFamilyCounterMap::const_iterator anIter = theFamilyID2CellsSize.find(anId);
-       if(anIter != theFamilyID2CellsSize.end())
+       TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
+       if(anIter != aFamilyID2CellsSize.end())
          aFamily->myCellsSize = anIter->second;
        
        INITMSG(MY_FAMILY_DEBUG,
@@ -1018,6 +777,7 @@ namespace
   {
     TTimerLog aTimerLog("BuildGroupMap");
     INITMSG(MYDEBUG,"BuildGroupMap\n");
+
     TGroupMap& aGroupMap = theMesh->myGroupMap;
     MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
     MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
@@ -1172,43 +932,37 @@ VISU_MedConvertor
 //---------------------------------------------------------------
 VISU_Convertor* 
 VISU_MedConvertor
-::Build()
+::BuildEntities()
 {
-  TTimerLog aTimerLog("Build");
+  TTimerLog aTimerLog("BuildEntities");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
-  MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
-  MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
-
   TInt aNbMeshes = aMed->GetNbMeshes();
   TMeshMap& aMeshMap = myMeshMap;
 
-  MSG(MYDEBUG,"VISU_MedConvertor::Build()");
-  INITMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<"\n");
+  INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
 
   for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
 #ifndef _DEXCEPT_
     try{
 #endif
+      TTimerLog aTimerLog("GetPMeshInfo");
+
       MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+      std::string aMeshName = aMeshInfo->GetName();
+      TInt aDim = aMeshInfo->GetDim();
       
       MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
       
-      MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
-      
-      MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = 
-       MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,aEntityInfo);
-      
-      // creating TMesh structure and TMeshOnEntityMap     
-      TInt aDim = aMeshInfo->GetDim();
-      std::string aMeshName = aMeshInfo->GetName();
+      MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
       
+      // creating TMesh structure and TMeshOnEntityMap         
       PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
       aMesh->myDim = aDim;
       aMesh->myName = aMeshName;
       aMesh->myNbPoints = aNodeInfo->GetNbElem();
       aMesh->myMeshInfo = aMeshInfo;
-      aMesh->myEntityInfo = aEntityInfo;
+      aMesh->myEntityInfo = anEntityInfo;
       aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
 
       INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
@@ -1218,41 +972,299 @@ VISU_MedConvertor
 #ifndef _DEXCEPT_
       try{
 #endif
-       BEGMSG(MYDEBUG,"aEntityInfo.size() = "<<aEntityInfo.size()<<"\n");
-       TFamilyCounterMap aFamilyID2CellsSize;
+       BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
        
        BuildMeshOnEntityMap(aMesh,
-                            aFamilyID2CellsSize,
-                            aEntityInfo,
+                            anEntityInfo,
                             aNodeInfo,
                             aMed);
        
+#ifndef _DEXCEPT_
+      }catch(std::exception& exc){
+       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+      }catch(...){
+       EXCEPTION(runtime_error,"Unknown exception !!!");
+      }
+#endif
+
+#ifndef _DEXCEPT_
+    }catch(std::exception& exc){
+      MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+    }catch(...){
+      EXCEPTION(runtime_error,"Unknown exception !!!");
+    }
+#endif
+  } 
+
+  return this; 
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor* 
+VISU_MedConvertor
+::BuildFields()
+{
+  TTimerLog aTimerLog("BuildFields");
+  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+  TInt aNbMeshes = aMed->GetNbMeshes();
+  TMeshMap& aMeshMap = myMeshMap;
+
+  INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
+
+  for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+    try{
+#endif
+      TTimerLog aTimerLog("GetPMeshInfo");
+
+      MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+      std::string aMeshName = aMeshInfo->GetName();
+      
+      TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+      if(anIter == aMeshMap.end())
+       continue;
+      PMEDMesh aMesh = anIter->second;
+
+      INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
+#ifndef _DEXCEPT_
+      try{
+#endif
+       MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
        BuildFieldMap(aMesh,
-                     aEntityInfo,
-                     aMKey2Profile,
-                     aKey2Gauss,
+                     anEntityInfo,
                      aMed);
+#ifndef _DEXCEPT_
+      }catch(std::exception& exc){
+       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+      }catch(...){
+       EXCEPTION(runtime_error,"Unknown exception !!!");
+      }
+#endif
+
+#ifndef _DEXCEPT_
+    }catch(std::exception& exc){
+      MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+    }catch(...){
+      EXCEPTION(runtime_error,"Unknown exception !!!");
+    }
+#endif
+  } 
+
+  return this; 
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor* 
+VISU_MedConvertor
+::BuildMinMax()
+{
+  TTimerLog aTimerLog("BuildMinMax");
+  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
-#ifdef _LOAD_FAMILIES_
+  MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
+  MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
+
+  TInt aNbMeshes = aMed->GetNbMeshes();
+  TMeshMap& aMeshMap = myMeshMap;
+
+  INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
+
+  for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+    try{
+#endif
+      TTimerLog aTimerLog("BuildMinMax - GetPMeshInfo");
+
+      MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+      std::string aMeshName = aMeshInfo->GetName();
+      
+      TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+      if(anIter == aMeshMap.end())
+       continue;
+      PMEDMesh aMesh = anIter->second;
+
+#ifndef _DEXCEPT_
+      try{
+#endif
+       TInt aNbFields = aMed->GetNbFields(); 
+
+       INITMSG(MYDEBUG,
+               "- aMeshName = '"<<aMeshName<<"'"<<
+               "; aNbFields = "<<aNbFields<<"\n");
+
+       MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
+       for(TInt iField = 1; iField <= aNbFields; iField++){
+         TTimerLog aTimerLog("BuildMinMax - GetPFieldInfo()");
+         MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
+         std::string aFieldName = aFieldInfo->GetName();
+         INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
+         
+         MED::TGeom2Size aGeom2Size;
+         MED::EEntiteMaillage aMEntity;
+         TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,
+                                                    anEntityInfo,
+                                                    aMEntity,
+                                                    aGeom2Size);
+         if(aNbTimeStamps < 1)
+           continue;
+       
+         TEntity aVEntity = MEDEntityToVTK(aMEntity);
+         PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
+         TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+         PMEDField aField = aFieldMap[aFieldName];
+       
+         TInt aNbComp = aField->myNbComp;
+         int aNbComp2 = aNbComp;
+         if(aNbComp == 2 || aNbComp == 4)
+           aNbComp2 = 2;
+         else if(aNbComp > 4)
+           aNbComp2 = 3;
+
+         TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
+         for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
+           TTimerLog aTimerLog("BuildMinMax - GetPTimeStampInfo()");
+           INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
+           
+           MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
+                                                                        aMEntity,
+                                                                        aGeom2Size,
+                                                                        iTimeStamp);
+           
+           MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
+                                                                     aMKey2Profile,
+                                                                     aKey2Gauss);
+           
+           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;
+             
+             TInt aNbElem = aMMeshValue.myNbElem;
+             TInt aNbGauss = aMMeshValue.myNbGauss;
+             
+             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;
+                 }
+                 aValue = sqrt(aValue);
+                 aMin = min(aMin,aValue);
+                 aMax = max(aMax,aValue);
+               }
+             }
+           }
+         }
+         for(TInt iComp = 0; iComp <= aNbComp; iComp++){
+           VISU::TMinMax aMinMax = aField->GetMinMax(iComp);
+           INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
+         }
+       }
+#ifndef _DEXCEPT_
+      }catch(std::exception& exc){
+       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+      }catch(...){
+       EXCEPTION(runtime_error,"Unknown exception !!!");
+      }
+#endif
+
+#ifndef _DEXCEPT_
+    }catch(std::exception& exc){
+      MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+    }catch(...){
+      EXCEPTION(runtime_error,"Unknown exception !!!");
+    }
+#endif
+  }
+
+  return this; 
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor* 
+VISU_MedConvertor
+::BuildGroups()
+{
+  TTimerLog aTimerLog("BuildGroups");
+  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+  TInt aNbMeshes = aMed->GetNbMeshes();
+  TMeshMap& aMeshMap = myMeshMap;
+
+  INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
+
+  for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+    try{
+#endif
+      TTimerLog aTimerLog("GetPMeshInfo");
+
+      MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+      std::string aMeshName = aMeshInfo->GetName();      
+
+      TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+      if(anIter == aMeshMap.end())
+       continue;
+      PMEDMesh aMesh = anIter->second;
+
+      INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
+
+      MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+      
+      MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = 
+       MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo);
+      
+#ifndef _DEXCEPT_
+      try{
+#endif
        MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo);
        
        BuildFamilyMap(aMesh,
-                      aFamilyID2CellsSize,
-                      aEntityInfo,
+                      anEntityInfo,
                       anEntity2TGeom2ElemInfo,
                       aFamilyInfoSet,
                       aMed);
        
        BuildGroupMap(aMesh,
                      aFamilyInfoSet);
-#endif
-       PCalculateMinMax aCalculateMinMax(new TCalculateMinMax(aMesh,
-                                                              aEntityInfo,
-                                                              aMKey2Profile,
-                                                              aKey2Gauss,
-                                                              aMed));
-
-       boost::thread aThread(boost::bind(&CalculateMinMax,aCalculateMinMax));
 #ifndef _DEXCEPT_
       }catch(std::exception& exc){
        MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
@@ -1281,6 +1293,8 @@ VISU_MedConvertor
                   VISU::PMeshOnEntityImpl theMeshOnEntity)
 {
   TTimerLog aTimerLog("LoadMeshOnEntity");
+  INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
+
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   const TEntity& anEntity = theMeshOnEntity->myEntity;
 
@@ -1304,6 +1318,8 @@ VISU_MedConvertor
                     VISU::PFamilyImpl theFamily)
 {
   TTimerLog aTimerLog("LoadFamilyOnEntity");
+  INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
+
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   const TEntity& anEntity = theMeshOnEntity->myEntity;
 
@@ -1326,6 +1342,8 @@ VISU_MedConvertor
                  const VISU::TFamilySet& theFamilySet)
 {
   TTimerLog aTimerLog("LoadMeshOnGroup");
+  INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
+
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
   TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
@@ -1354,6 +1372,8 @@ VISU_MedConvertor
                       VISU::PValForTimeImpl theValForTime)
 {
   TTimerLog aTimerLog("LoadValForTimeOnMesh");
+  INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
+
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
   const TEntity& anEntity = theMeshOnEntity->myEntity;
@@ -1376,6 +1396,8 @@ VISU_MedConvertor
                           VISU::PValForTimeImpl theValForTime)
 {
   TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
+  INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
+
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
   const TEntity& anEntity = theMeshOnEntity->myEntity;
@@ -2084,6 +2106,14 @@ LoadValForTime(const MED::PWrapper& theMed,
                             aMKey2Profile,
                             aKey2Gauss);
 
+  InitGaussProfile(theMed,
+                  aMeshInfo,
+                  aTimeStampVal,
+                  theMeshOnEntity,
+                  aMEntity,
+                  aGeom2Size,
+                  theValForTime);
+
   LoadProfile(theMed,
              theMesh,
              aTimeStampVal,
@@ -2100,7 +2130,6 @@ LoadValForTime(const MED::PWrapper& theMed,
   PMEDProfile aProfile = theValForTime->myProfile;
   TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
 
-  const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
   TInt aNbComp = theField->myNbComp;
 
   INITMSGA(MYDEBUG,0,
@@ -2169,7 +2198,6 @@ VISU_MedConvertor
                       VISU::PMEDField theField, 
                       VISU::PMEDValForTime theValForTime)
 {
-  TTimerLog aTimerLog("LoadValForTimeOnMesh");
   PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
   return LoadValForTime(theMed,
                        theMesh,
@@ -2190,7 +2218,6 @@ VISU_MedConvertor
                           VISU::PMEDField theField, 
                           VISU::PMEDValForTime theValForTime)
 {
-  TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
   PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
   return LoadValForTime(theMed,
                        theMesh,
index 61bb67e18d16864bdf013c57c0e499354245f8df..43416b95cf0a6687194cbfb03c0781a164e2bb14 100644 (file)
@@ -130,8 +130,11 @@ namespace VISU
 
 
   //---------------------------------------------------------------
+  typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
+
   struct TMEDMeshOnEntity: virtual TMeshOnEntityImpl
   {
+    TFamilyID2CellsSize myFamilyID2CellsSize;
     MED::TGeom2Size myGeom2Size;
   };
   typedef SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
@@ -172,7 +175,19 @@ public:
 
   virtual
   VISU_Convertor* 
-  Build();
+  BuildEntities();
+
+  virtual
+  VISU_Convertor* 
+  BuildFields();
+
+  virtual
+  VISU_Convertor* 
+  BuildMinMax();
+
+  virtual
+  VISU_Convertor* 
+  BuildGroups();
 
 protected:
   QFileInfo myFileInfo;
index bad03e4f3d0f1c3aafe9f984a3c4a6a72d1a25cd..0131825adea75447868cb74a262fe084aa51cd09 100644 (file)
@@ -19,6 +19,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl
 LIB = libVISUEngineImpl.la
 
 LIB_SRC = \
+       VISU_Result_i.cc \
        VISUConfig.cc \
        VISU_PrsObject_i.cc \
        VISU_Prs3d_i.cc \
@@ -35,7 +36,6 @@ LIB_SRC = \
        VISU_Mesh_i.cc \
        VISU_Table_i.cc \
        VISU_Gen_i.cc \
-       VISU_Result_i.cc \
        VISU_ViewManager_i.cc \
        VISU_View_i.cc \
        VISU_TimeAnimation.cxx \
index 2ecd1f0fcf551cd969d12070090f523e81acbc6d..2b9ea7f9dd6d15e9cc96353aeeb4aabf2ddf3b55 100644 (file)
 #include "SALOMEDS_Tool.hxx"
 #include "HDFascii.hxx"
 
+#include "SUIT_Session.h"
+#include "SALOME_Event.hxx"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
 // QT Includes
 #include <qstring.h>
 #include <qfileinfo.h>
@@ -145,8 +153,8 @@ void VISU::Result_i::RemoveFromStudy()
 
 
 int
-VISU::Result_i::
-IsPossible()
+VISU::Result_i
+::IsPossible()
 {
   try{
     float aSize = myInput->GetSize();
@@ -162,9 +170,10 @@ IsPossible()
 }
 
 
+//---------------------------------------------------------------
 CORBA::Boolean
-VISU::Result_i::
-BuildAll()
+VISU::Result_i
+::BuildAll()
 {
   if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
   if(myIsDone) return 1;
@@ -246,21 +255,20 @@ BuildAll()
 }
 
 
-VISU::Storable*
-VISU::Result_i::
-Build(SALOMEDS::SObject_ptr theSObject)
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildEntities(SALOMEDS::SObject_ptr theSObject)
 {
-  SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
-  aStudyBuilder->NewCommand();  // There is a transaction
-  if(MYDEBUG) MESSAGE("Result_i::Build");
-  try{
-    const TMeshMap& aMeshMap = myInput->GetMeshMap();
-    if(aMeshMap.empty())
-      throw std::runtime_error("Build - There is no any mesh information in the file !!!");
+  QString aComment;
+  myInput->BuildEntities();
+  string aRefFatherEntry = GetRefFatherEntry();
+  const TMeshMap& aMeshMap = myInput->GetMeshMap();
+  TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+  for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
     mySComponent = FindOrCreateVisuComponent(myStudyDocument);
-    CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID());
-    string aRefFatherEntry = GetRefFatherEntry();
-    QString aComment;
+    CORBA::String_var aSComponentEntry = mySComponent->GetID();
+    CORBA::String_var anIOR(GetID());
     aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
                     GetComment(),
                     VISU::TRESULT,
@@ -276,7 +284,6 @@ Build(SALOMEDS::SObject_ptr theSObject)
                       aComment.latin1(),
                       true);
     mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
-    if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!");
     if(!CORBA::is_nil(theSObject)){
       CORBA::String_var aString = theSObject->GetID();
       CreateReference(myStudyDocument,aResultEntry,aString.in());
@@ -284,151 +291,370 @@ Build(SALOMEDS::SObject_ptr theSObject)
     TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
     for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
       const string& aMeshName = aMeshMapIter->first;
-      const VISU::PMesh aMesh = aMeshMapIter->second;
-      const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-      VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
+      const PMesh& aMesh = aMeshMapIter->second;
+      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      if(aMeshOnEntityMap.empty()) 
+       continue;
+
       aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
-                      aMeshName.c_str(),aMesh->myDim);
-      string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(),
-                                          "",aMeshName.c_str(),"",aComment.latin1(),true);
-      if(aMeshOnEntityMap.empty()) continue;
-      aComment.sprintf("myComment=FAMILIES;myMeshName=%s",aMeshName.c_str());
-      string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(),
-                                               "","Families","",aComment.latin1(),true);
-      //Import entities and according families
-      aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-      typedef std::map<std::string,std::string> TComment2EntryMap;
-      TComment2EntryMap aComment2EntryMap;
-      typedef std::map<VISU::TEntity,std::string> TEntity2EntryMap;
-      TEntity2EntryMap aEntity2EntryMap;
+                      aMeshName.c_str(),
+                      aMesh->myDim);
+      aMesh->myEntry = 
+       CreateAttributes(myStudyDocument,
+                        aResultEntry.c_str(),
+                        aRefFatherEntry.c_str(),
+                        "",
+                        aMeshName.c_str(),
+                        "",
+                        aComment.latin1(),
+                        true);
+
+      aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
+                      aMeshName.c_str());
+      string aSubMeshesEntry = 
+       CreateAttributes(myStudyDocument,
+                        aMesh->myEntry.c_str(),
+                        aRefFatherEntry.c_str(),
+                        "",
+                        "Families",
+                        "",
+                        aComment.latin1(),
+                        true);
+      //Import entities
+      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+       string anEntityName;
+       switch(anEntity){
+       case NODE_ENTITY: 
+         anEntityName = "onNodes"; 
+         break;
+       case EDGE_ENTITY: 
+         anEntityName = "onEdges"; 
+         break;
+       case FACE_ENTITY: 
+         anEntityName = "onFaces"; 
+         break;
+       case CELL_ENTITY: 
+         anEntityName = "onCells"; 
+         break;
+       default:
+         continue;
+       }
+
        aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
                         VISU::TENTITY,
                         aMeshName.c_str(),
                         anEntity);
-       string anEntityName;
-       switch(anEntity){
-       case VISU::NODE_ENTITY : anEntityName = "onNodes"; break;
-       case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break;
-       case VISU::FACE_ENTITY : anEntityName = "onFaces"; break;
-       case VISU::CELL_ENTITY : anEntityName = "onCells"; break;
-       default:
-         throw std::runtime_error("Build >> Value of entity is incorrect!");
+
+       aMeshOnEntity->myEntry = 
+         CreateAttributes(myStudyDocument, 
+                          aSubMeshesEntry.c_str(), 
+                          aRefFatherEntry.c_str(),
+                          "", 
+                          anEntityName.c_str(), 
+                          "", 
+                          aComment.latin1(), 
+                          true);
+      }
+    }
+  }
+}
+
+
+//---------------------------------------------------------------
+namespace
+{
+  struct TMemManager
+  {
+    VISU::Result_i* myResult;
+    TMemManager(VISU::Result_i* theResult):
+      myResult(theResult)
+    {
+      myResult->Register();
+    }
+
+    ~TMemManager()
+    {
+      myResult->Destroy();
+    }
+  };
+
+  struct TUpdateObjBrowser: public SALOME_Event
+  {
+    int myStudyId;
+
+    TUpdateObjBrowser(const int theStudyId):
+      myStudyId(theStudyId)
+    {}
+    
+    virtual
+    void
+    Execute()
+    {
+      SUIT_Session* aSession = SUIT_Session::session();
+      QPtrList<SUIT_Application> anApplications = aSession->applications();
+      QPtrListIterator<SUIT_Application> anIter (anApplications);
+      while (SUIT_Application* aSApp = anIter.current()) {
+       if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
+         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
+           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+             if (myStudyId == aCStudy->StudyId()) {
+               MESSAGE("Result_i::updateObjectBrowser");
+               anApp->updateObjectBrowser();
+               break;
+             }
+           }
+         }
        }
-       aEntity2EntryMap[anEntity] = CreateAttributes
-         (myStudyDocument, aSubMeshesEntry.c_str(), aRefFatherEntry.c_str(),
-          "", anEntityName.c_str(), "", aComment.latin1(), true);
-       const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
-       const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
-       VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
-       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
-         const string& aFamilyName = aFamilyMapIter->first;
-         aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
-                          VISU::TFAMILY,
-                          aMeshName.c_str(),
-                          anEntity,
-                          aFamilyName.c_str());
-         aComment2EntryMap[aComment.latin1()] =
+       ++anIter;
+      }
+    }
+  };
+}
+
+void
+VISU::Result_i
+::BuildGroups()
+{
+  TMemManager aMemManager(this);
+
+  QString aComment;
+  myInput->BuildGroups();
+  string aRefFatherEntry = GetRefFatherEntry();
+  const TMeshMap& aMeshMap = myInput->GetMeshMap();
+  TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+  for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+    const string& aMeshName = aMeshMapIter->first;
+    const PMesh& aMesh = aMeshMapIter->second;
+
+    const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+    if(aMeshOnEntityMap.empty()) 
+      continue;
+
+    TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+    for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+      const TEntity& anEntity = aMeshOnEntityMapIter->first;
+      const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+      const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+      TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+      for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+       const string& aFamilyName = aFamilyMapIter->first;
+       const PFamily& aFamily = aFamilyMapIter->second;
+       aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
+                        TFAMILY,
+                        aMeshName.c_str(),
+                        anEntity,
+                        aFamilyName.c_str());
+       aFamily->myEntry =
+         CreateAttributes(myStudyDocument,
+                          aMeshOnEntity->myEntry.c_str(),
+                          aRefFatherEntry.c_str(),
+                          "",
+                          aFamilyName.c_str(),
+                          "",
+                          aComment.latin1(),
+                          true);
+      }
+    }
+    //Importing groups
+    const TGroupMap& aGroupMap = aMesh->myGroupMap;
+    if(!aGroupMap.empty()){
+      aComment.sprintf("myComment=GROUPS;myMeshName=%s",
+                      aMeshName.c_str());
+      string aGroupsEntry =
+       CreateAttributes(myStudyDocument,
+                        aMesh->myEntry.c_str(),
+                        aRefFatherEntry.c_str(),
+                        "",
+                        "Groups",
+                        "",
+                        aComment.latin1(),
+                        true);
+      TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
+      for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
+       const string& aGroupName = aGroupMapIter->first;
+       const PGroup& aGroup = aGroupMapIter->second;
+       aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
+                        TGROUP,aMeshName.c_str(),aGroupName.c_str());
+       aGroup->myEntry = 
+         CreateAttributes(myStudyDocument,
+                          aGroupsEntry.c_str(),
+                          aRefFatherEntry.c_str(),
+                          "",
+                          aGroupName.c_str(),
+                          "",
+                          aComment.latin1(),
+                          true);
+       const TFamilySet& aFamilySet = aGroup->myFamilySet;
+       TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
+       for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
+         const PFamily& aFamily = *aFamilyIter;
+         CreateReference(myStudyDocument,
+                         aGroup->myEntry,
+                         aFamily->myEntry);
+       }
+      }
+    }
+  }
+
+  ProcessVoidEvent(new TUpdateObjBrowser(myStudyDocument->StudyId()));
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildFields()
+{
+  TMemManager aMemManager(this);
+
+  QString aComment;
+  myInput->BuildFields();
+  string aRefFatherEntry = GetRefFatherEntry();
+  const TMeshMap& aMeshMap = myInput->GetMeshMap();
+  TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+  for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+    const string& aMeshName = aMeshMapIter->first;
+    const PMesh& aMesh = aMeshMapIter->second;
+
+    const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+    if(aMeshOnEntityMap.empty()) 
+      continue;
+
+    //Import fields
+    string aFieldsEntry;
+    bool anIsFieldsEntryCreated = false;
+
+    TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+    for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+      const TEntity& anEntity = aMeshOnEntityMapIter->first;
+      const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+      const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+      TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
+      for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
+       if(!anIsFieldsEntryCreated){
+         aComment.sprintf("myComment=FIELDS;myMeshName=%s",
+                          aMeshName.c_str());
+         aFieldsEntry =
            CreateAttributes(myStudyDocument,
-                            aEntity2EntryMap[anEntity].c_str(),
+                            aMesh->myEntry.c_str(),
                             aRefFatherEntry.c_str(),
                             "",
-                            aFamilyName.c_str(),
+                            "Fields",
                             "",
                             aComment.latin1(),
                             true);
+         anIsFieldsEntryCreated = true;
        }
-      }
-      //Importing groups
-      const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
-      if(aGroupMap.size() > 0){
-       aComment.sprintf("myComment=GROUPS;myMeshName=%s",
-                        aMeshName.c_str());
-       string aGroupsEntry =
+       const string& aFieldName = aFieldMapIter->first;
+       const PField& aField = aFieldMapIter->second;
+       const TValField& aValField = aField->myValField;
+       QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]);
+       aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
+                        VISU::TFIELD,
+                        aMeshName.c_str(),
+                        anEntity,
+                        aFieldName.c_str(),
+                        aValField.size(),
+                        aField->myNbComp);
+       aField->myEntry = 
          CreateAttributes(myStudyDocument,
-                          aMeshEntry.c_str(),
+                          aFieldsEntry.c_str(),
                           aRefFatherEntry.c_str(),
                           "",
-                          "Groups",
+                          aFieldNameWithUnit.latin1(),
                           "",
                           aComment.latin1(),
                           true);
-       VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
-       for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
-         const string& aGroupName = aGroupMapIter->first;
-         aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
-                          VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str());
-         string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(),
-                                               "",aGroupName.c_str(),"",aComment.latin1(),true);
-         const VISU::PGroup aGroup = aGroupMapIter->second;
-         const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
-         VISU::TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
-         for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
-           const VISU::PFamily& aFamily = *aFamilyIter;
-           const string& aFamilyName = aFamily->myName;
-           const VISU::TEntity& anEntity = aFamily->myEntity;
-           aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
-                            VISU::TFAMILY,
-                            aMeshName.c_str(),
-                            anEntity,
-                            aFamilyName.c_str());
-           TComment2EntryMap::const_iterator anIter = aComment2EntryMap.find(aComment.latin1());
-           if(anIter != aComment2EntryMap.end()){
-             const std::string& anEntry = anIter->second;
-             CreateReference(myStudyDocument,aGroupEntry,anEntry);
-           }
-         }
-       }
-      }
-      //Import fields
-      string aFieldsEntry;
-      bool isFieldEntryCreated = 0;
-      aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
-       const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-       VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
-       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
-         if(!isFieldEntryCreated){
-           aComment.sprintf("myComment=FIELDS;myMeshName=%s",
-                            aMeshName.c_str());
-           aFieldsEntry =
-             CreateAttributes(myStudyDocument,
-                              aMeshEntry.c_str(),
-                              aRefFatherEntry.c_str(),
-                              "",
-                              "Fields",
-                              "",
-                              aComment.latin1(),
-                              true);
-           isFieldEntryCreated = true;
-         }
-         const string& aFieldName = aFieldMapIter->first;
-         const VISU::PField aField = aFieldMapIter->second;
-         const VISU::TValField& aValField = aField->myValField;
-         QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]);
-         aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
-                          VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField->myNbComp);
-         string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(),
-                                               "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true);
-         CreateReference(myStudyDocument,aFieldEntry,aEntity2EntryMap[anEntity]);
-         VISU::TValField::const_iterator aValFieldIter = aValField.begin();
-         for(; aValFieldIter != aValField.end(); aValFieldIter++){
-           int aTimeStamp = aValFieldIter->first;
-           const VISU::PValForTime aValForTime = aValFieldIter->second;
-           aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
-                            VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField->myNbComp);
-           string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
-           CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(),
-                            "",aTimeStampId.c_str(),"",aComment.latin1(),true);
-         }
+       CreateReference(myStudyDocument,
+                       aField->myEntry,
+                       aMeshOnEntity->myEntry);
+       TValField::const_iterator aValFieldIter = aValField.begin();
+       for(; aValFieldIter != aValField.end(); aValFieldIter++){
+         int aTimeStamp = aValFieldIter->first;
+         const PValForTime& aValForTime = aValFieldIter->second;
+         aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
+                          VISU::TTIMESTAMP,
+                          aMeshName.c_str(),
+                          anEntity,
+                          aFieldName.c_str(),
+                          aTimeStamp,
+                          aField->myNbComp);
+         string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
+         aValForTime->myEntry = 
+           CreateAttributes(myStudyDocument,
+                            aField->myEntry.c_str(),
+                            aRefFatherEntry.c_str(),
+                            "",
+                            aTimeStampId.c_str(),
+                            "",
+                            aComment.latin1(),
+                            true);
        }
       }
     }
-    bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
-    if(isBuildAll) BuildAll();
+  }
+
+  ProcessVoidEvent(new TUpdateObjBrowser(myStudyDocument->StudyId()));
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildMinMax()
+{
+  TMemManager aMemManager(this);
+
+  myInput->BuildMinMax();
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Result_i
+::Build(SALOMEDS::SObject_ptr theSObject)
+{
+  bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
+  if(isBuildAll) 
+    return BuildAll(theSObject);
+  else{
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+    aStudyBuilder->NewCommand();  // There is a transaction
+
+    BuildEntities(theSObject);
+
+    boost::thread(boost::bind(&Result_i::BuildFields,this));
+
+    boost::thread(boost::bind(&Result_i::BuildGroups,this));
+
+    boost::thread(boost::bind(&Result_i::BuildMinMax,this));
+
+    aStudyBuilder->CommitCommand();
+
+    return this;
+  }
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Result_i
+::BuildAll(SALOMEDS::SObject_ptr theSObject)
+{
+  SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+  aStudyBuilder->NewCommand();  // There is a transaction
+
+  if(MYDEBUG) MESSAGE("Result_i::Build");
+  try{
+    BuildEntities(theSObject);
+    BuildFields();
+    BuildGroups();
+    BuildAll();
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
     return NULL;
@@ -436,11 +662,14 @@ Build(SALOMEDS::SObject_ptr theSObject)
     INFOS("Unknown exception was occured!!!");
     return NULL;
   }
+
   aStudyBuilder->CommitCommand();
+
   return this;
 }
 
 
+//---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i::
 Create(const char* theFileName)
@@ -473,6 +702,7 @@ Create(const char* theFileName)
 }
 
 
+//---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i::
 Create(SALOMEDS::SObject_ptr theMedSObject)
@@ -499,6 +729,8 @@ Create(SALOMEDS::SObject_ptr theMedSObject)
   return NULL;
 }
 
+
+//---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i::
 Create(SALOME_MED::FIELD_ptr theField)
@@ -529,6 +761,7 @@ Create(SALOME_MED::FIELD_ptr theField)
 }
 
 
+//---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i::
 Restore(SALOMEDS::SObject_ptr theSObject,
@@ -637,21 +870,32 @@ Restore(SALOMEDS::SObject_ptr theSObject,
   return NULL;
 }
 
-VISU::Result_i::TInput* VISU::Result_i::GetInput() {
+//---------------------------------------------------------------
+VISU::Result_i::TInput* 
+VISU::Result_i
+::GetInput() 
+{
   return myInput;
 }
 
-void VISU::Result_i::ToStream(std::ostringstream& theStr){
+//---------------------------------------------------------------
+void 
+VISU::Result_i
+::ToStream(std::ostringstream& theStr)
+{
   if(MYDEBUG) MESSAGE(GetComment());
   Storable::DataToStream(theStr,"myName",myName.c_str());
   Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
   Storable::DataToStream(theStr,"myCreationId",myCreationId);
 }
 
+
+//---------------------------------------------------------------
 VISU::Storable*
-VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
-                       const string& thePrefix,
-                       const Storable::TRestoringMap& theMap)
+VISU::Result_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+         const string& thePrefix,
+         const Storable::TRestoringMap& theMap)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
 
@@ -667,25 +911,56 @@ VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
   return pResult->Restore(theSObject,theMap,thePrefix);
 }
 
-string VISU::Result_i::GetRefFatherEntry() {
+
+//---------------------------------------------------------------
+string 
+VISU::Result_i
+::GetRefFatherEntry() 
+{
   //return QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry();
   return "";
 }
 
-string VISU::Result_i::GetEntry(){
+string
+VISU::Result_i
+::GetEntry()
+{
   CORBA::String_var anEntry = mySObject->GetID();
   return string(anEntry);
 }
 
-const SALOMEDS::SObject_var& VISU::Result_i::GetSObject() const { return mySObject;}
-const SALOMEDS::Study_var& VISU::Result_i::GetStudyDocument() const { return myStudyDocument;}
-const SALOMEDS::SComponent_var& VISU::Result_i::GetSComponent() const { return mySComponent;}
-std::string VISU::Result_i::GetEntry(const std::string& theComment)
+const SALOMEDS::SObject_var& 
+VISU::Result_i
+::GetSObject() const 
+{ 
+  return mySObject;
+}
+
+const SALOMEDS::Study_var& 
+VISU::Result_i
+::GetStudyDocument() const 
+{ 
+  return myStudyDocument;
+}
+
+const SALOMEDS::SComponent_var& 
+VISU::Result_i
+::GetSComponent() const
+{
+  return mySComponent;
+}
+
+std::string 
+VISU::Result_i
+::GetEntry(const std::string& theComment)
 {
   return FindEntryWithComment(myStudyDocument,GetEntry().c_str(),theComment.c_str());
 }
 
-VISU::Result_i::~Result_i()
+
+//---------------------------------------------------------------
+VISU::Result_i
+::~Result_i()
 {
   MESSAGE("Result_i::~Result_i() - this = "<<this);
   if (mySourceId == eRestoredFile) {
index beb1e55868d11c9dea680efaf25933d1a95b3de8..f560ee11cf6bf4bfa08319bb02d5557c708513c0 100644 (file)
@@ -58,6 +58,10 @@ namespace VISU{
     virtual VISU::VISUType GetType() { return VISU::TRESULT;}
     virtual CORBA::Boolean BuildAll();
 
+    virtual void BuildGroups();
+    virtual void BuildFields();
+    virtual void BuildMinMax();
+
     typedef VISU_Convertor TInput;
 
   private:
@@ -71,6 +75,9 @@ namespace VISU{
 
   protected:
     virtual Storable* Build(SALOMEDS::SObject_ptr theSObject = SALOMEDS::SObject::_nil()) ;
+    virtual Storable* BuildAll(SALOMEDS::SObject_ptr theSObject) ;
+
+    void BuildEntities(SALOMEDS::SObject_ptr theSObject);
 
   public:
     virtual int IsPossible();
@@ -99,6 +106,7 @@ namespace VISU{
 
   private:
     SALOMEDS::SObject_var mySObject;
+    SALOMEDS::SObject_var myRefSObject;
     SALOMEDS::Study_var myStudyDocument;
     SALOMEDS::SComponent_var mySComponent;