]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To clarify algorithm of "SelectPrs3dToBeDeleted" function
authorapo <apo@opencascade.com>
Wed, 20 Dec 2006 07:31:45 +0000 (07:31 +0000)
committerapo <apo@opencascade.com>
Wed, 20 Dec 2006 07:31:45 +0000 (07:31 +0000)
src/VISU_I/VISU_ColoredPrs3dCache_i.cc

index b24b2e19ed392a9e5bccb4016a0f40bbb26fe586..3447140e2a82775609eb513e74d98946272edc34 100644 (file)
@@ -157,23 +157,21 @@ namespace
     // by cleaning of active holder's presentation
     if( theActiveHolderEntry != "" ){
       aHolderIter = theHolderMap.find( theActiveHolderEntry );
+      if(aHolderIter == theHolderMap.end())
+       return false;
+
       const VISU::TLastVisitedPrsList& aPrsList = aHolderIter->second;
+
+      // To prefere "move" action instead of destroy / create presentation
+      if(aPrsList.back()->GetMemorySize() >= theRequiredMemory)
+       return false;
+
       VISU::TLastVisitedPrsList::const_reverse_iterator aPrsIter = aPrsList.rbegin();
-      VISU::TLastVisitedPrsList::const_reverse_iterator aPrsIterEnd = aPrsList.rend();
+      // Do not porcess first item to avoid of the device destruction
+      VISU::TLastVisitedPrsList::const_reverse_iterator aPrsIterEnd = aPrsList.rend()++;
       for(; aPrsIter != aPrsIterEnd; aPrsIter++){
        VISU::TPrs3dPtr aPrs3d = *aPrsIter;
-       // To avoid of device destruction
-       if(aPrs3d.GetPointer() == aPrsList.front().GetPointer())
-         return false;
-
-       CORBA::Float aMemory = aPrs3d->GetMemorySize();
-
-       // To prefere "move" action instead of destroy / create
-       if(aPrsIter == aPrsList.rbegin())
-         if(aMemory >= theRequiredMemory)
-           return false;
-
-       aGatheredMemory += aMemory;
+       aGatheredMemory += aPrs3d->GetMemorySize();
        theColoredPrs3dHolderMap[theActiveHolderEntry].push_back(aPrs3d);
        if( aGatheredMemory > theRequiredMemory )
          return true;