#include "MED_Utilities.hxx"
#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
#include <vtkCellType.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYVALUEDEBUG = 0;
-static int MYTHREADDEBUG = 1;
+static int MYTHREADDEBUG = 0;
static int MY_FAMILY_DEBUG = 0;
static int MY_GROUP_DEBUG = 0;
//#define _DEXCEPT_
}
- //---------------------------------------------------------------
- struct TFieldMinMax;
-
- void
- 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;
- for(TInt iTimeStamp = 1; iTimeStamp <= theNbTimeStamps; iTimeStamp++){
- INITMSG(MYTHREADDEBUG,"- "<<theFieldMinMax<<"; iTimeStamp = "<<iTimeStamp<<endl);
-
- 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);
-
- TInt aNbElem = aSubProfile->myNbCells;
- TInt aNbGauss = aValForTime->GetNbGauss(aVGeom);
-
- 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,"\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
{
myKey2Gauss(theKey2Gauss),
myMEDWrapper(theMEDWrapper),
myMutex(theMutex)
- {}
+ {
+ INITMSG(MYTHREADDEBUG,"TFieldMinMax() - "<<this<<endl);
+ }
+
+ ~TFieldMinMax()
+ {
+ INITMSG(MYTHREADDEBUG,"~TFieldMinMax() - "<<this<<endl);
+ }
void
- operator()()
+ Calculate()
{
- GetMinMax(this,
- myField,
- myFieldInfo,
- myNbTimeStamps,
- myMEntity,
- myGeom2Size,
- myMKey2Profile,
- myKey2Gauss,
- myMEDWrapper,
- myMutex);
+ //boost::mutex::scoped_lock aLock(myMutex);
+ INITMSG(MYTHREADDEBUG,"TFieldMinMax::Calculate() - "<<this<<
+ "; aFieldName = '"<<myField->myName<<"'"<<
+ "; myNbTimeStamps = "<<myNbTimeStamps<<
+ endl);
+
+ TInt aNbComp = myField->myNbComp;
+ 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++){
+ vtkIdType aVGeom = anIter->first;
+ PMEDSubProfile aSubProfile(anIter->second);
+
+ TInt aNbElem = aSubProfile->myNbCells;
+ TInt aNbGauss = aValForTime->GetNbGauss(aVGeom);
+
+ if(aSubProfile->myStatus != eRemoveAll){
+ INITMSG(MYTHREADDEBUG,
+ "- "<<this<<
+ "; 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);
+ 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];
+ aMin = min(aMin,aVal);
+ aMax = max(aMax,aVal);
+ }
+ }
+ }
+ }
+ }
+ }
+ 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();
+ }
+
//---------------------------------------------------------------
void
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);
+ PFieldMinMax aFieldMinMax(new TFieldMinMax(aField,
+ aFieldInfo,
+ aNbTimeStamps,
+ aMEntity,
+ aGeom2Size,
+ theMKey2Profile,
+ theKey2Gauss,
+ theMEDWrapper,
+ theMutex));
+
+ boost::thread aThread(boost::bind(&GetFieldMinMax,aFieldMinMax));
}
}