0031652: Visualization - crash on highlighting HLR Computed presentation displayed...
authorkgv <kgv@opencascade.com>
Sat, 4 Jul 2020 20:37:04 +0000 (23:37 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 8 Jul 2020 12:53:31 +0000 (15:53 +0300)
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
src/Graphic3d/Graphic3d_CView.cxx
src/Graphic3d/Graphic3d_Structure.cxx
src/PrsMgr/PrsMgr_PresentationManager.cxx
tests/bugs/vis/bug31652 [new file with mode: 0644]

index 17a5425..9dd18a9 100644 (file)
@@ -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;
   }
index 18c117f..fa1005f 100644 (file)
@@ -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
index c021fac..3492a3f 100644 (file)
@@ -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);
   }
index 8ae5a7e..b1deaba 100644 (file)
@@ -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 (file)
index 0000000..150c56c
--- /dev/null
@@ -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