From 2a1d6145bf2493dffc1d8279195081d584902b07 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 19 Sep 2005 06:02:47 +0000 Subject: [PATCH] To improve Min/Max calculation --- src/CONVERTOR/VISU_MedConvertor.cxx | 144 +++++++++++++++++----------- src/CONVERTOR/VISU_MedConvertor.hxx | 3 - 2 files changed, 87 insertions(+), 60 deletions(-) diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 245f8149..133e200b 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -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() - "<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() - "<GetNbFields(); + MED::PMeshInfo aMeshInfo = myMesh->myMeshInfo; + const std::string& aMeshName = myMesh->myName; + INITMSG(MYDEBUG,"MinMaxCalculation: aNbFields = "<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 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){ diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 1929587e..0307427d 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -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 -- 2.39.2