From 6d1d35e4b850b2380cadc5aebb002c9e70feac45 Mon Sep 17 00:00:00 2001 From: kgv Date: Sat, 4 Jul 2020 23:37:04 +0300 Subject: [PATCH] 0031652: Visualization - crash on highlighting HLR Computed presentation displayed with Shaded display mode PrsMgr_PresentationManager::displayImmediate() now uses proper ZLayer for a shadow presentation of computed presentation (fixes dynamic highlighting on mouse move). Graphic3d_CView::SetComputedMode() - added invalidation of bounding box on turning OFF compute mode. AIS_ViewController::contextLazyMoveTo() now ignores MoveTo() while rotating view with temporary disabled compute mode (leading to undefined results and crashes). Graphic3d_Structure::Graphic3d_Structure() - do not copy Graphic3d_TOS_COMPUTED visual from linked structure, as Graphic3d_CView::SetComputedMode() does not compute such structures. --- src/AIS/AIS_ViewController.cxx | 3 ++- src/Graphic3d/Graphic3d_CView.cxx | 15 ++++++++++++++- src/Graphic3d/Graphic3d_Structure.cxx | 7 +++++-- src/PrsMgr/PrsMgr_PresentationManager.cxx | 4 +++- tests/bugs/vis/bug31652 | 17 +++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 tests/bugs/vis/bug31652 diff --git a/src/AIS/AIS_ViewController.cxx b/src/AIS/AIS_ViewController.cxx index 17a5425e2d..9dd18a945d 100644 --- a/src/AIS/AIS_ViewController.cxx +++ b/src/AIS/AIS_ViewController.cxx @@ -2688,7 +2688,8 @@ void AIS_ViewController::contextLazyMoveTo (const Handle(AIS_InteractiveContext) const Handle(V3d_View)& theView, const Graphic3d_Vec2i& thePnt) { - if (myPrevMoveTo == thePnt) + if (myPrevMoveTo == thePnt + || myHasHlrOnBeforeRotation) // ignore highlighting in-between rotation of HLR view { return; } diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index 18c117fe7d..fa1005feb3 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -189,6 +189,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode) const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (anIndex); eraseStructure (aStructComp->CStructure()); displayStructure (aStruct->CStructure(), aStruct->DisplayPriority()); + Update (aStruct->GetZLayer()); } } return; @@ -223,6 +224,10 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode) { Handle(Graphic3d_Structure) aCompStruct; aStruct->computeHLR (myCamera, aCompStruct); + if (aCompStruct.IsNull()) + { + continue; + } aCompStruct->SetHLRValidation (Standard_True); const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME @@ -303,6 +308,11 @@ void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct) Handle(Graphic3d_Structure) aCompStruct = aCompStructOld; aCompStruct->SetTransformation (Handle(TopLoc_Datum3D)()); theStruct->computeHLR (myCamera, aCompStruct); + if (aCompStruct.IsNull()) + { + return; + } + aCompStruct->SetHLRValidation (Standard_True); aCompStruct->CalculateBoundBox(); @@ -774,7 +784,10 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure) aStruct->SetTransformation (Handle(TopLoc_Datum3D)()); } theStructure->computeHLR (myCamera, aStruct); - + if (aStruct.IsNull()) + { + return; + } aStruct->SetHLRValidation (Standard_True); // TOCOMPUTE and COMPUTED associated to sequences are added diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index c021facc4b..3492a3fd73 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -49,8 +49,11 @@ Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManage { if (!theLinkPrs.IsNull()) { - myOwner = theLinkPrs->myOwner; - myVisual = theLinkPrs->myVisual; + myOwner = theLinkPrs->myOwner; + if (theLinkPrs->myVisual != Graphic3d_TOS_COMPUTED) + { + myVisual = theLinkPrs->myVisual; + } myComputeVisual = theLinkPrs->myComputeVisual; myCStructure = theLinkPrs->myCStructure->ShadowLink (theManager); } diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 8ae5a7e6c4..b1deaba5f6 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -368,9 +368,11 @@ void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& the Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs); if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs)) { + const Graphic3d_ZLayerId aZLayer = aShadowPrs->GetZLayer(); aShadowPrs.Nullify(); + aShadowPrs = new Prs3d_PresentationShadow (myStructureManager, aViewDepPrs); - aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer()); + aShadowPrs->SetZLayer (aZLayer); aShadowPrs->SetClipPlanes (aViewDepPrs->ClipPlanes()); aShadowPrs->CStructure()->IsForHighlight = 1; aShadowPrs->Highlight (aPrs->HighlightStyle()); diff --git a/tests/bugs/vis/bug31652 b/tests/bugs/vis/bug31652 new file mode 100644 index 0000000000..150c56c6cf --- /dev/null +++ b/tests/bugs/vis/bug31652 @@ -0,0 +1,17 @@ +puts "============" +puts "0031652: Visualization - crash on highlighting HLR Computed presentation displayed with Shaded display mode" +puts "============" +puts "" + +pload MODELING VISUALIZATION +psphere s 1 +vclear +vinit View1 +vdisplay -dispMode 1 s +vaxo +vfit + +vhlr on -algoType polyAlgo +vmoveto 351 64 + +vdump ${imagedir}/${casename}.png -- 2.20.1