From: nge Date: Tue, 8 Jul 2008 09:39:52 +0000 (+0000) Subject: UNSTABLE : Add set instead of double for loop (WARNING seems Display is broken) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=24d71761857398edd8b99f82861182a69cb57c17;p=modules%2Fgui.git UNSTABLE : Add set instead of double for loop (WARNING seems Display is broken) --- diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 382416f8c..d0b409696 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -24,6 +24,7 @@ #include "SUIT_Session.h" #include "SUIT_Application.h" #include +#include //#include "ToolsGUI.h" @@ -39,6 +40,15 @@ #include #include +struct AISLessThan +{ + bool operator()(const Handle(AIS_InteractiveObject)* theRightIO, + const Handle(AIS_InteractiveObject)* theLeftIO) const + { + return (theLeftIO( prs ); if ( !anOCCPrs || anOCCPrs->IsNull() ) @@ -351,11 +360,29 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) ic->ObjectsInCollector( ListCollector ); #endif + + START_TIMING // get objects to be displayed AIS_ListOfInteractive anAISObjects; anOCCPrs->GetObjects( anAISObjects ); AIS_ListIteratorOfListOfInteractive aIter( anAISObjects ); + AIS_ListIteratorOfListOfInteractive ite( List ); + + std::set check; + std::set checkCollector; + + for ( ; ite.More();ite.Next()) + { + check.insert(&ite.Value()); + } + + ite.Initialize(ListCollector); + for ( ; ite.More();ite.Next()) + { + checkCollector.insert(&ite.Value()); + } + for ( ; aIter.More(); aIter.Next() ) { Handle(AIS_InteractiveObject) anAIS = aIter.Value(); @@ -363,33 +390,25 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) { // try to find presentation in the viewer bool bDisplayed = false; - AIS_ListIteratorOfListOfInteractive ite( List ); - for ( ; ite.More(); ite.Next() ) - { + // if insert.second is True object was not displayed before + if (!check.insert(&anAIS).second) // compare presentations by handles // if the object is already displayed - nothing to do more - if ( ite.Value() == anAIS ) - { // Deactivate object if necessary if ( !anOCCPrs->ToActivate() ) ic->Deactivate( anAIS ); bDisplayed = true; break; - } - } if ( bDisplayed ) continue; // then try to find presentation in the collector bDisplayed = false; - ite.Initialize( ListCollector ); - for ( ; ite.More(); ite.Next() ) + if (!checkCollector.insert(&anAIS).second) { // compare presentations by handles // if the object is in collector - display it - if ( ite.Value() == anAIS ) - { ic->DisplayFromCollector( anAIS, false ); // Deactivate object if necessary @@ -405,11 +424,9 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); //if ( !anObj.IsNull() && anObj->hasEntry() ) //{ - // if ( study ) // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); //} break; - } } if ( bDisplayed ) continue;