0026284: Visualization - eliminate recursion in SelectMgr_SelectionManager
authorvpa <vpa@opencascade.com>
Thu, 4 Jun 2015 11:37:52 +0000 (14:37 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 4 Jun 2015 11:38:45 +0000 (14:38 +0300)
Small correction of test case for issue CR26284

src/QABugs/QABugs_19.cxx
src/SelectMgr/SelectMgr_SelectionManager.cxx
tests/bugs/vis/bug26284 [new file with mode: 0644]

index 0fa1943..6bcc1c3 100755 (executable)
@@ -3489,6 +3489,42 @@ static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theA
   return 0;
 }
 
+//=======================================================================
+//function : OCC26284
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
+{
+  if (theArgNb != 1)
+  {
+    std::cerr << "Error: wrong number of arguments! See usage:\n";
+    theDI.PrintHelp (theArgVec[0]);
+    return 1;
+  }
+
+  Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+  if (anAISContext.IsNull())
+  {
+    std::cerr << "Error: no active view. Please call vinit.\n";
+    return 1;
+  }
+
+  BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
+  Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
+  anAISContext->Display (aSphere);
+  for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
+  {
+    BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
+    Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
+    aSphere->AddChild (aChild);
+    anAISContext->Display (aChild);
+  }
+
+  anAISContext->RecomputeSelectionOnly (aSphere);
+
+  return 0;
+}
+
 #include <IntTools_Context.hxx>
 #include <GeomAPI_ProjectPointOnSurf.hxx>
 
@@ -3698,5 +3734,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
   theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
   theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
+  theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
   return;
 }
index 3ded691..88ff77c 100644 (file)
@@ -515,7 +515,7 @@ void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMg
 {
   for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObj->Children()); anChildrenIter.More(); anChildrenIter.Next())
   {
-    ClearSelectionStructures (theObj, theMode, theSelector);
+    ClearSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
   }
 
   if (!theObj->HasOwnPresentations())
@@ -575,7 +575,7 @@ void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(Select
 {
   for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObj->Children()); anChildrenIter.More(); anChildrenIter.Next())
   {
-    RestoreSelectionStructures (theObj, theMode, theSelector);
+    RestoreSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
   }
 
   if (!theObj->HasOwnPresentations())
@@ -687,7 +687,6 @@ void SelectMgr_SelectionManager::RecomputeSelection (const Handle(SelectMgr_Sele
   for(theObject->Init(); theObject->More(); theObject->Next())
   {
     const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
-    aSelection->UpdateStatus (SelectMgr_TOU_Full);
     Standard_Integer aSelMode = aSelection->Mode();
 
     for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
@@ -695,23 +694,13 @@ void SelectMgr_SelectionManager::RecomputeSelection (const Handle(SelectMgr_Sele
       const Handle(SelectMgr_ViewerSelector)& aCurSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
       if (aCurSelector->Status (aSelection) == SelectMgr_SOS_Activated)
       {
-        switch (aSelection->UpdateStatus())
-        {
-        case SelectMgr_TOU_Full:
           ClearSelectionStructures (theObject, aSelMode, aCurSelector);
           theObject->RecomputePrimitives(aSelMode);
           RestoreSelectionStructures (theObject, aSelMode, aCurSelector);
-        case SelectMgr_TOU_Partial:
-          theObject->UpdateTransformations (aSelection);
-          aCurSelector->RebuildObjectsTree();
-          aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
-          break;
-        default:
-          break;
-        }
-        aSelection->UpdateStatus (SelectMgr_TOU_None);
       }
     }
+    aSelection->UpdateStatus (SelectMgr_TOU_None);
+    aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
   }
 }
 
diff --git a/tests/bugs/vis/bug26284 b/tests/bugs/vis/bug26284
new file mode 100644 (file)
index 0000000..413c636
--- /dev/null
@@ -0,0 +1,15 @@
+puts "========"
+puts "OCC26284"
+puts "========"
+puts ""
+##################################################################
+puts "Visualization - eliminate recursion in SelectMgr_SelectionManager"
+##################################################################
+
+pload QAcommands VISUALIZATION
+
+vinit
+OCC26284
+
+vfit
+set only_screen 1