From: ouv Date: Fri, 1 Dec 2006 14:09:28 +0000 (+0000) Subject: Cache improvement X-Git-Tag: WP1_2_3_05-12-2006_cache_system~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17963b774b80eb269783f85927e15c40066c1169;p=modules%2Fvisu.git Cache improvement --- diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index 1d191390..d89b0611 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -291,10 +291,15 @@ void VisuGUI_Slider::enableControls( bool on ) myTimeStampIndices->setFont(myTimeStampStrings->font()); myTimeStampIndices->updateGeometry(); + if( a_current_index > mySlider->maxValue() ) + mySlider->setMaxValue( aLength-1 ); + myTimeStampStrings->setCurrentItem( a_current_index ); myTimeStampIndices->setCurrentItem( a_current_index ); - mySlider->setMaxValue( aLength-1 ); mySlider->setValue( a_current_index ); + + if( a_current_index <= mySlider->maxValue() ) + mySlider->setMaxValue( aLength-1 ); } else { diff --git a/src/VISU_I/SALOME_GenericObjPointer.cc b/src/VISU_I/SALOME_GenericObjPointer.cc index 6b19648c..384f6481 100644 --- a/src/VISU_I/SALOME_GenericObjPointer.cc +++ b/src/VISU_I/SALOME_GenericObjPointer.cc @@ -22,7 +22,7 @@ // Author : Oleg UVAROV // Module : SALOME -#include "SALOME_GenericObjPtr.hh" +#include "SALOME_GenericObjPointer.hh" using namespace SALOME; diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 782b10fe..9e82c868 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -117,7 +117,7 @@ VISU::ColoredPrs3dCache_i const VISU::ColoredPrs3dHolder::BasicInput& theInput, float& theMemoryToClear) { - //cout << "VISU::ColoredPrs3dCache_i::IsPossible " << endl; + //if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::IsPossible" << endl; size_t aMemory = VISU::CheckIsPossible(theType, theInput, true); if(aMemory > 0){ @@ -125,12 +125,13 @@ VISU::ColoredPrs3dCache_i CORBA::Float aMemoryUsed = GetMemorySize(); CORBA::Float aMemoryLimit = GetLimitedMemory(); CORBA::Float aMemoryNeeded = CORBA::Float(aMemory/(1024.0*1024.0)); // convert to Mb - //cout<<"Memory needed: "< 0; @@ -360,7 +361,7 @@ VISU::ColoredPrs3dCache_i const VISU::ColoredPrs3dHolder::BasicInput& theInput, VISU::View3D_ptr theView3D) { - //cout << "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" << endl; + if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" << endl; TPrs3dPtr aLastVisitedPrs3d = GetLastVisitedPrs(theHolder); TLastVisitedPrsList& aLastVisitedPrsList = GetLastVisitedPrsList(theHolder); TPrs3dPtr aPrs3d = FindPrsByInput(aLastVisitedPrsList, theInput); @@ -368,25 +369,25 @@ VISU::ColoredPrs3dCache_i float aMemoryToClear = 0.; if(aPrs3d.GetPointer()){ aLastVisitedPrsList.push_front(aPrs3d); - //cout << "FindPrsByInput " << aPrs3d; + if(MYDEBUG) cout << "FindPrsByInput " << aPrs3d << endl; }else if(anIsCheckPossible && IsPossible(theHolder->GetPrsType(), theInput, aMemoryToClear)){ if( aMemoryToClear > 1 / VTK_LARGE_FLOAT ) ClearMemory(aMemoryToClear, theHolder); aPrs3d = CreatePrs(theHolder->GetPrsType(), theInput, theHolder); - //cout << "Created " << aPrs3d; + if(MYDEBUG) cout << "Created " << aPrs3d << endl; }else{ aPrs3d = aLastVisitedPrsList.back(); + aPrs3d->SetResultObject(theInput.myResult); + aPrs3d->SetMeshName(theInput.myMeshName); + aPrs3d->SetEntity(theInput.myEntity); + aPrs3d->SetFieldName(theInput.myFieldName); + aPrs3d->SetTimeStampNumber(theInput.myTimeStampNumber); aLastVisitedPrsList.pop_back(); aLastVisitedPrsList.push_front(aPrs3d); - //cout << "Move only " << aPrs3d; + if(MYDEBUG) cout << "Move only " << aPrs3d << endl; } - //cout << "; " << aLastVisitedPrsList.size() << endl; + if(MYDEBUG) PrintCache(); - aPrs3d->SetResultObject(theInput.myResult); - aPrs3d->SetMeshName(theInput.myMeshName); - aPrs3d->SetEntity(theInput.myEntity); - aPrs3d->SetFieldName(theInput.myFieldName); - aPrs3d->SetTimeStampNumber(theInput.myTimeStampNumber); aPrs3d->SameAs(thePrs); aPrs3d->UpdateActors(); if(!CORBA::is_nil(theView3D)){ @@ -431,7 +432,7 @@ void VISU::ColoredPrs3dCache_i ::ClearCache(float theMemory) { - //cout << "VISU::ColoredPrs3dCache_i::ClearCache( " << theMemory << " )" << endl; + //if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::ClearCache( " << theMemory << " )" << endl; float aCurrentMemory = GetMemorySize(); ClearMemory( aCurrentMemory - theMemory, NULL ); @@ -439,39 +440,49 @@ VISU::ColoredPrs3dCache_i //---------------------------------------------------------------------------- -void +bool VISU::ColoredPrs3dCache_i -::ClearMemory(float theMemory, VISU::ColoredPrs3dHolder_i* theActiveHolder) +::ClearMemory(float theMemory, VISU::ColoredPrs3dHolder_i* theActiveHolder, bool theOnlyCheck) { - if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::ClearMemory( " << theMemory << " )" << endl; + if(MYDEBUG) + { + cout << "VISU::ColoredPrs3dCache_i::ClearMemory( "; + cout << (int)theOnlyCheck; + cout << " , " << theMemory; + if( theActiveHolder ) + cout << " , " << theActiveHolder->GetEntry().c_str(); + cout << " )" << endl; + } if( theMemory < 1 / VTK_LARGE_FLOAT ) - return; + return false; if(MYDEBUG) PrintCache(); TColoredPrs3dHolderMap::iterator aHolderIter = myHolderMap.begin(); TColoredPrs3dHolderMap::iterator aHolderIterEnd = myHolderMap.end(); + std::string anEntry; + if( theActiveHolder )//&& myHolderMap.size() > 1 ) + anEntry = theActiveHolder->GetEntry(); + int anIteration = 0; for( ; aHolderIter != aHolderIterEnd; aHolderIter++ ) { + if( aHolderIter->first == anEntry ) + continue; TLastVisitedPrsList& aPrsList = aHolderIter->second; anIteration = QMAX( aPrsList.size() - 1, anIteration ); } if(MYDEBUG) cout << "Iteration - " << anIteration << endl; - std::string anEntry; - if( theActiveHolder ) - anEntry = theActiveHolder->GetEntry(); - float aMemory, aGatheredMemory = 0.; while( anIteration > 0 ) { for( aHolderIter = myHolderMap.begin(); aHolderIter != aHolderIterEnd; aHolderIter++ ) { - //if( aHolderIter->first == anEntry ) - //continue; + if( aHolderIter->first == anEntry ) + continue; TLastVisitedPrsList& aPrsList = aHolderIter->second; if( anIteration < aPrsList.size() ) @@ -485,22 +496,55 @@ VISU::ColoredPrs3dCache_i aGatheredMemory += aMemory; if(MYDEBUG) cout << aMemory << " >> " << aGatheredMemory; - aPrsList.pop_back(); + if( !theOnlyCheck ) + aPrsList.pop_back(); if( aGatheredMemory > theMemory ) { if(MYDEBUG) cout << " STOP" << endl; - goto stop; + if(MYDEBUG) PrintCache(); + return true; } if(MYDEBUG) cout << endl; } } - anIteration--; } - stop: + // clear active holder in a last order + if( theActiveHolder ) + { + aHolderIter = myHolderMap.find( anEntry ); + + TLastVisitedPrsList& aPrsList = aHolderIter->second; + TLastVisitedPrsList::reverse_iterator aPrsIter = aPrsList.rbegin(); + TLastVisitedPrsList::reverse_iterator aPrsIterEnd = aPrsList.rend(); + for(; aPrsIter != aPrsIterEnd; aPrsIter++) + { + TPrs3dPtr aPrs3d = *aPrsIter; + if(MYDEBUG) cout << aPrs3d.GetPointer() << " "; + if( !aPrs3d.GetPointer() ) + continue; + + aMemory = aPrs3d->GetMemorySize(); + aGatheredMemory += aMemory; + if(MYDEBUG) cout << aMemory << " >> " << aGatheredMemory; + + if( !theOnlyCheck ) + aPrsList.pop_back(); + + if( aGatheredMemory > theMemory ) + { + if(MYDEBUG) cout << " STOP" << endl; + if(MYDEBUG) PrintCache(); + return true; + } + if(MYDEBUG) cout << endl; + } + } + if(MYDEBUG) PrintCache(); + return false; } @@ -509,8 +553,7 @@ void VISU::ColoredPrs3dCache_i ::PrintCache() { - cout << "VISU::ColoredPrs3dCache_i::PrintCache()" << endl; - + cout << "--------------CACHE-----------------" << endl; cout << "Cache memory - " << GetMemorySize() << " Mb" << endl; TColoredPrs3dHolderMap::const_iterator aHolderIter = myHolderMap.begin(); TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = myHolderMap.end(); @@ -519,14 +562,22 @@ VISU::ColoredPrs3dCache_i TLastVisitedPrsList::const_iterator aPrsIter = aPrsList.begin(); TLastVisitedPrsList::const_iterator aPrsIterEnd = aPrsList.end(); + cout << "--------------------------" << endl; cout << "Holder - " << aHolderIter->first.c_str() << endl; cout << "Size - " << aPrsList.size() << endl; - for(aPrsIter++; aPrsIter != aPrsIterEnd; aPrsIter++) + for(; aPrsIter != aPrsIterEnd; aPrsIter++) if(TPrs3dPtr aPrs3d = *aPrsIter) - cout << aPrs3d.GetPointer() << " (" << aPrs3d->GetMemorySize() << " Mb)"<< endl; + { + cout << aPrs3d.GetPointer() << " (" << aPrs3d->GetMemorySize() << " Mb)"; + if(aPrsIter == aPrsList.begin()) + cout << " (device)"; + cout << endl; + } } + cout << "------------------------------------" << endl; } + //---------------------------------------------------------------------------- void VISU::ColoredPrs3dCache_i diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index 45f0ebc5..df42f7f7 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -178,9 +178,10 @@ namespace VISU void ClearCache(float theMemory = 0); - void + bool ClearMemory(float theMemory, - VISU::ColoredPrs3dHolder_i* theActiveHolder); + VISU::ColoredPrs3dHolder_i* theActiveHolder, + bool theOnlyCheck = false); void PrintCache();