]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Complete usage of boost-1.33.0 library
authorapo <apo@opencascade.com>
Fri, 16 Sep 2005 07:39:29 +0000 (07:39 +0000)
committerapo <apo@opencascade.com>
Fri, 16 Sep 2005 07:39:29 +0000 (07:39 +0000)
adm_local/unix/make_commence.in
src/CONVERTOR/Makefile.in
src/CONVERTOR/VISU_Convertor.hxx
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx

index 549610f5fa86769c350b1e28148c5f5735ae104b..574db11c074eba24f9f9fcb8d039cf0bb4f3aee9 100644 (file)
@@ -37,6 +37,7 @@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@
 # BOOST Library
 
 BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LIBS = @BOOST_LIBS@
 
 # JAVA
 
index 947461a22ca3d8464a03d36584f65218d7b1c48f..e91a493eb530d041ab9263191da028339a0d2685 100644 (file)
@@ -61,7 +61,11 @@ CPPFLAGS+= -ftemplate-depth-32 $(VTK_INCLUDES) $(HDF5_INCLUDES) $(QT_INCLUDES) \
        -I${GUI_ROOT_DIR}/include/salome \
        $(BOOST_CPPFLAGS)
 
-LDFLAGS+= $(VTK_LIBS) $(QT_LIBS) -L${MED_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lMEDWrapper -lVTKViewer
+LDFLAGS+= $(VTK_LIBS) $(QT_LIBS) \
+       $(BOOST_LIBS) -lboost_thread-mt \
+       -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper \
+       -L${GUI_ROOT_DIR}/lib/salome -lVTKViewer
+
 LDFLAGSFORBIN=$(LDFLAGS) -lMEDWrapper_V2_2 -lMEDWrapper_V2_1 -lMEDWrapperBase -lVTKViewer
 
 @CONCLUDE@
index 14500e14309ba982a1b12948d983a72bfbb5b5e5..140f27932628fec2015c388852f6a69f6551a0b8 100644 (file)
@@ -162,7 +162,8 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  typedef std::map<int,PValForTime> TValField;
+  typedef std::map<vtkIdType,PValForTime> TValField;
+  typedef std::pair<float,float> TMinMax;
 
   struct TField: virtual TIntId
   {
index 1e36439ce78a6b75c3f947446fe5ecb9bf9a5c12..dd69788c90b95510a5e170ae76d2e3bccb131706 100644 (file)
@@ -34,6 +34,8 @@
 #include "MED_GaussUtils.hxx"
 #include "MED_Utilities.hxx"
 
+#include <boost/thread/thread.hpp>
+
 #include <vtkCellType.h>
 
 using namespace std;
@@ -46,12 +48,14 @@ using MED::EBooleen;
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 static int MYVALUEDEBUG = 0;
+static int MYTHREADDEBUG = 1;
 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 MYTHREADDEBUG = 0;
 static int MY_FAMILY_DEBUG = 0;
 static int MY_GROUP_DEBUG = 0;
 #endif
@@ -394,8 +398,8 @@ namespace
   BuildMeshOnEntityMap(PMEDMesh theMesh,
                       TFamilyCounterMap& theFamilyID2CellsSize,
                       const MED::TEntityInfo& theEntityInfo,
-                      MED::PNodeInfo theNodeInfo,
-                      MED::PWrapper theMEDWrapper)
+                      const MED::PNodeInfo& theNodeInfo,
+                      const MED::PWrapper& theMEDWrapper)
   {
     INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
@@ -513,55 +517,184 @@ namespace
 
 
   //---------------------------------------------------------------
+  struct TFieldMinMax;
+
   void
-  CalculateMinMax(MED::PTimeStampVal theTimeStampVal,
-                 PMEDField theField,
-                 PMEDValForTime theValForTime)
+  GetMinMax(TFieldMinMax* theFieldMinMax,
+           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,
+           VISU_MedConvertor::TMutex& theMutex)
   {
+    //boost::mutex::scoped_lock aLock(theMutex);
+    INITMSG(MYTHREADDEBUG,"GetMinMax: - "<<theFieldMinMax<<
+           "; aFieldName = '"<<theField->myName<<"'"<<
+           "; theNbTimeStamps = "<<theNbTimeStamps<<
+           endl);
+
     TInt aNbComp = theField->myNbComp;
+    TValField& aValField = theField->myValField;
     TMinMaxArr& aMinMaxArr = theField->myMinMaxArr;
-    const MED::TTimeStampVal& aTimeStampValRef = theTimeStampVal;
+    for(TInt iTimeStamp = 1; iTimeStamp <= theNbTimeStamps; iTimeStamp++){
+      INITMSG(MYTHREADDEBUG,"- "<<theFieldMinMax<<"; iTimeStamp = "<<iTimeStamp<<endl);
 
-    PMEDProfile aProfile = theValForTime->myProfile;
-    TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
-    TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
-    for(; anIter != aGeom2SubProfile.end(); anIter++){
-      vtkIdType aVGeom = anIter->first;
-      PMEDSubProfile aSubProfile(anIter->second);
-      
-      TInt aNbElem = aSubProfile->myNbCells;
-      TInt aNbGauss = theValForTime->GetNbGauss(aVGeom);
+      MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(theFieldInfo,
+                                                                           theMEntity,
+                                                                           theGeom2Size,
+                                                                           iTimeStamp);
+      MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
+                                                                        theMKey2Profile,
+                                                                        theKey2Gauss);
+      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++){
+       vtkIdType aVGeom = anIter->first;
+       PMEDSubProfile aSubProfile(anIter->second);
       
-      if(aSubProfile->myStatus != eRemoveAll){
-       INITMSG(MYDEBUG,
-               "- aVGeom = "<<aVGeom<<
-               "; aNbElem = "<<aNbElem<<
-               "; aNbGauss = "<<aNbGauss<<
-               endl);
+       TInt aNbElem = aSubProfile->myNbCells;
+       TInt aNbGauss = aValForTime->GetNbGauss(aVGeom);
        
-       MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
-       const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
-       for(TInt iElem = 0; iElem < aNbElem; iElem++){
-         MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
-         ADDMSG(MYVALUEDEBUG,"{");
-         for(TInt iComp = 0; iComp < aNbComp; iComp++){
-           const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
-           TMinMax& aMinMax = aMinMaxArr[iComp];
-           float& aMin = aMinMax.first;
-           float& aMax = aMinMax.second;
-           for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
-             const float& aVal = aMValueSlice[iGauss];
-             ADDMSG(MYVALUEDEBUG,aVal<<" ");
-             aMin = min(aMin,aVal);
-             aMax = max(aMax,aVal);
+       if(aSubProfile->myStatus != eRemoveAll){
+         INITMSG(MYTHREADDEBUG,
+                 "- "<<theFieldMinMax<< 
+                 "; aVGeom = "<<aVGeom<<
+                 "; aNbElem = "<<aNbElem<<
+                 "; aNbGauss = "<<aNbGauss<<
+                 endl);
+         
+         MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
+         const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
+         for(TInt iElem = 0; iElem < aNbElem; iElem++){
+           MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+           ADDMSG(MYVALUEDEBUG,"{");
+           for(TInt iComp = 0; iComp < aNbComp; iComp++){
+             const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
+             TMinMax& aMinMax = aMinMaxArr[iComp];
+             float& aMin = aMinMax.first;
+             float& aMax = aMinMax.second;
+             for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+               const float& aVal = aMValueSlice[iGauss];
+               ADDMSG(MYVALUEDEBUG,aVal<<" ");
+               aMin = min(aMin,aVal);
+               aMax = max(aMax,aVal);
+             }
+             ADDMSG(MYVALUEDEBUG,"| ");
            }
-           ADDMSG(MYVALUEDEBUG,"| ");
+           ADDMSG(MYVALUEDEBUG,"} ");
          }
-         ADDMSG(MYVALUEDEBUG,"");
+         ADDMSG(MYVALUEDEBUG,"\n");
        }
-       ADDMSG(MYDEBUG,"\n");
       }
     }
+    for(TInt iComp = 0; iComp < aNbComp; iComp++){
+      VISU::TMinMax aMinMax = theField->GetMinMax(iComp);
+      INITMSG(MYTHREADDEBUG,"- "<<theFieldMinMax<<"; "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
+    }
+  }
+
+
+  //---------------------------------------------------------------
+  struct TFieldMinMax
+  {
+    PMEDField myField;
+    MED::PFieldInfo myFieldInfo;
+    TInt myNbTimeStamps;
+    MED::EEntiteMaillage myMEntity;
+    MED::TGeom2Size myGeom2Size;
+    MED::TMKey2Profile myMKey2Profile;
+    MED::TKey2Gauss myKey2Gauss;
+    MED::PWrapper myMEDWrapper;
+    VISU_MedConvertor::TMutex& myMutex;
+
+    TFieldMinMax(const 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,
+                VISU_MedConvertor::TMutex& theMutex):
+      myField(theField),
+      myFieldInfo(theFieldInfo),
+      myNbTimeStamps(theNbTimeStamps),
+      myMEntity(theMEntity),
+      myGeom2Size(theGeom2Size),
+      myMKey2Profile(theMKey2Profile),
+      myKey2Gauss(theKey2Gauss),
+      myMEDWrapper(theMEDWrapper),
+      myMutex(theMutex)
+    {}
+
+    void
+    operator()()
+    {
+      GetMinMax(this,
+               myField,
+               myFieldInfo,
+               myNbTimeStamps,
+               myMEntity,
+               myGeom2Size,
+               myMKey2Profile,
+               myKey2Gauss,
+               myMEDWrapper,
+               myMutex);
+    }
+  };
+
+  //---------------------------------------------------------------
+  void
+  MinMaxCalculation(PMEDMesh theMesh,
+                   const MED::TEntityInfo& theEntityInfo,
+                   const MED::TMKey2Profile& theMKey2Profile,
+                   const MED::TKey2Gauss& theKey2Gauss,
+                   const MED::PWrapper& theMEDWrapper,
+                   VISU_MedConvertor::TMutex& theMutex)
+  {
+    TInt aNbFields = theMEDWrapper->GetNbFields(); 
+    MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
+    const std::string& aMeshName = theMesh->myName;
+    INITMSG(MYDEBUG,"MinMaxCalculation: aNbFields = "<<aNbFields<<"\n");
+    for(TInt iField = 1; iField <= aNbFields; iField++){
+      MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
+      TInt aNbComp = aFieldInfo->GetNbComp();
+      std::string aFieldName = aFieldInfo->GetName();
+      
+      MED::TGeom2Size aGeom2Size;
+      MED::EEntiteMaillage aMEntity;
+      TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
+                                                         theEntityInfo,
+                                                         aMEntity,
+                                                         aGeom2Size);
+      if(aNbTimeStamps < 1)
+       continue;
+      
+      TEntity aVEntity = MEDEntityToVTK(aMEntity);
+      PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+      TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+      PMEDField aField = aFieldMap[aFieldName];
+
+      TFieldMinMax* aFieldMinMax = new TFieldMinMax(aField,
+                                                   aFieldInfo,
+                                                   aNbTimeStamps,
+                                                   aMEntity,
+                                                   aGeom2Size,
+                                                   theMKey2Profile,
+                                                   theKey2Gauss,
+                                                   theMEDWrapper,
+                                                   theMutex);
+      new boost::thread(*aFieldMinMax);
+    }
   }
 
 
@@ -637,10 +770,6 @@ namespace
                         aMeshOnEntity,
                         aGeom2Size,
                         aValForTime);
-       
-       CalculateMinMax(aTimeStampVal,
-                       aField,
-                       aValForTime);
       }
     }
   }
@@ -905,6 +1034,13 @@ VISU_MedConvertor
                    aFamilyInfoSet);
 #endif
 
+      MinMaxCalculation(aMesh,
+                       aEntityInfo,
+                       aMKey2Profile,
+                       aKey2Gauss,
+                       aMed,
+                       myMutex);
+
 #ifndef _DEXCEPT_
     }catch(std::exception& exc){
       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
@@ -1529,7 +1665,7 @@ LoadGaussMesh(const MED::PWrapper& theMed,
        aName = aGaussInfo->GetName();
        if(!aSubMeshID.empty()){
          const std::string& aProfileName = aSubProfile->myName;
-         MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(*theMed,
+         MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
                                                               aProfileName);
          if(aProfileInfo){
            const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
@@ -1548,7 +1684,7 @@ LoadGaussMesh(const MED::PWrapper& theMed,
     }else{
       if(!aSubMeshID.empty()){
        const std::string& aProfileName = aSubProfile->myName;
-       MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(*theMed,
+       MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
                                                             aProfileName);
        if(aProfileInfo){
          const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
@@ -1630,8 +1766,8 @@ LoadValForTime(const MED::PWrapper& theMed,
                              aGeom2Size,
                              theValForTime->myId);
 
-  MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(*theMed);
-  MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(*theMed);
+  MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
+  MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
 
   MED::PTimeStampVal aTimeStampVal = 
     theMed->GetPTimeStampVal(aTimeStampInfo,
index de23886c99d21f3a42ee03aa114dcae596a6d71f..1929587e0720a5c1f9dcf0bf8968492214be0e5e 100644 (file)
@@ -14,6 +14,7 @@
 #include "MED_Common.hxx"
 #include "MED_Structures.hxx"
 
+#include <boost/thread/mutex.hpp>
 #include <qfileinfo.h>
 
 namespace VISU
@@ -134,11 +135,13 @@ namespace VISU
 }
 
 class VISU_MedConvertor: public VISU_Convertor_impl
-{
+{  
   VISU_MedConvertor();
   VISU_MedConvertor(const VISU_MedConvertor&);
-
+  
 public:
+  typedef boost::mutex TMutex;
+
   VISU_MedConvertor(const std::string& theFileName);
 
   virtual
@@ -147,6 +150,7 @@ public:
 
 protected:
   QFileInfo myFileInfo;
+  TMutex myMutex;
 
   virtual
   int