]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve Min/Max calculation
authorapo <apo@opencascade.com>
Mon, 19 Sep 2005 06:02:47 +0000 (06:02 +0000)
committerapo <apo@opencascade.com>
Mon, 19 Sep 2005 06:02:47 +0000 (06:02 +0000)
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx

index 245f8149ec7157b8d2ce66afacc2b33a18d092a2..133e200b6407fef5f0e9e8182ea91c98d8da5738 100644 (file)
@@ -49,6 +49,7 @@ using MED::EBooleen;
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 static int MYVALUEDEBUG = 0;
+static int MYMEMORYDEBUG = 1;
 static int MYTHREADDEBUG = 0;
 static int MY_FAMILY_DEBUG = 0;
 static int MY_GROUP_DEBUG = 0;
@@ -56,6 +57,7 @@ static int MY_GROUP_DEBUG = 0;
 #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;
@@ -520,7 +522,7 @@ namespace
   //---------------------------------------------------------------
   struct TFieldMinMax
   {
-    PMEDField myField;
+    VISU::PMEDField myField;
     MED::PFieldInfo myFieldInfo;
     TInt myNbTimeStamps;
     MED::EEntiteMaillage myMEntity;
@@ -528,17 +530,15 @@ namespace
     MED::TMKey2Profile myMKey2Profile;
     MED::TKey2Gauss myKey2Gauss;
     MED::PWrapper myMEDWrapper;
-    VISU_MedConvertor::TMutex& myMutex;
 
-    TFieldMinMax(const PMEDField& theField,
+    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,
-                VISU_MedConvertor::TMutex& theMutex):
+                const MED::PWrapper& theMEDWrapper):
       myField(theField),
       myFieldInfo(theFieldInfo),
       myNbTimeStamps(theNbTimeStamps),
@@ -546,21 +546,19 @@ namespace
       myGeom2Size(theGeom2Size),
       myMKey2Profile(theMKey2Profile),
       myKey2Gauss(theKey2Gauss),
-      myMEDWrapper(theMEDWrapper),
-      myMutex(theMutex)
+      myMEDWrapper(theMEDWrapper)
     {
-      INITMSG(MYTHREADDEBUG,"TFieldMinMax() - "<<this<<endl);
+      INITMSG(MYMEMORYDEBUG,"TFieldMinMax() - "<<this<<endl);
     }
 
     ~TFieldMinMax()
     {
-      INITMSG(MYTHREADDEBUG,"~TFieldMinMax() - "<<this<<endl);
+      INITMSG(MYMEMORYDEBUG,"~TFieldMinMax() - "<<this<<endl);
     }
 
     void
     Calculate()
     {
-      //boost::mutex::scoped_lock aLock(myMutex);
       INITMSG(MYTHREADDEBUG,"TFieldMinMax::Calculate() - "<<this<<
              "; aFieldName = '"<<myField->myName<<"'"<<
              "; myNbTimeStamps = "<<myNbTimeStamps<<
@@ -638,49 +636,80 @@ namespace
 
 
   //---------------------------------------------------------------
-  void
-  MinMaxCalculation(PMEDMesh theMesh,
-                   const MED::TEntityInfo& theEntityInfo,
-                   const MED::TMKey2Profile& theMKey2Profile,
-                   const MED::TKey2Gauss& theKey2Gauss,
-                   const MED::PWrapper& theMEDWrapper,
-                   VISU_MedConvertor::TMutex& theMutex)
+  struct TCalculateMinMax
   {
-    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];
-
-      PFieldMinMax aFieldMinMax(new TFieldMinMax(aField,
-                                                aFieldInfo,
-                                                aNbTimeStamps,
-                                                aMEntity,
-                                                aGeom2Size,
-                                                theMKey2Profile,
-                                                theKey2Gauss,
-                                                theMEDWrapper,
-                                                theMutex));
-
-      boost::thread aThread(boost::bind(&GetFieldMinMax,aFieldMinMax));
+    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();
   }
 
 
@@ -1020,12 +1049,13 @@ VISU_MedConvertor
                    aFamilyInfoSet);
 #endif
 
-      MinMaxCalculation(aMesh,
-                       aEntityInfo,
-                       aMKey2Profile,
-                       aKey2Gauss,
-                       aMed,
-                       myMutex);
+      PCalculateMinMax aCalculateMinMax(new TCalculateMinMax(aMesh,
+                                                            aEntityInfo,
+                                                            aMKey2Profile,
+                                                            aKey2Gauss,
+                                                            aMed));
+       
+      boost::thread aThread(boost::bind(&CalculateMinMax,aCalculateMinMax));
 
 #ifndef _DEXCEPT_
     }catch(std::exception& exc){
index 1929587e0720a5c1f9dcf0bf8968492214be0e5e..0307427d904ffd53a1527d96f0d5d069a9915627 100644 (file)
@@ -140,8 +140,6 @@ class VISU_MedConvertor: public VISU_Convertor_impl
   VISU_MedConvertor(const VISU_MedConvertor&);
   
 public:
-  typedef boost::mutex TMutex;
-
   VISU_MedConvertor(const std::string& theFileName);
 
   virtual
@@ -150,7 +148,6 @@ public:
 
 protected:
   QFileInfo myFileInfo;
-  TMutex myMutex;
 
   virtual
   int