0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / PrsMgr / PrsMgr_Presentation.cxx
index 190fc3b..c53573d 100644 (file)
 
 #include <PrsMgr_Presentation.hxx>
 
-#include <Geom_Transformation.hxx>
 #include <Graphic3d_DataStructureManager.hxx>
 #include <Precision.hxx>
 #include <Prs3d_Drawer.hxx>
-#include <Prs3d_Projector.hxx>
 #include <PrsMgr_PresentableObject.hxx>
 #include <PrsMgr_PresentationManager.hxx>
 #include <Quantity_Color.hxx>
@@ -104,12 +102,12 @@ void PrsMgr_Presentation::Erase()
   }
 
   // Erase structure from structure manager
-  base_type::Erase();
-  base_type::Clear();
+  erase();
+  clear (true);
   // Disconnect other structures
-  base_type::DisconnectAll (Graphic3d_TOC_DESCENDANT);
+  DisconnectAll (Graphic3d_TOC_DESCENDANT);
   // Clear groups and remove graphic structure
-  base_type::Remove();
+  Remove();
 }
 
 //=======================================================================
@@ -142,7 +140,7 @@ void PrsMgr_Presentation::Unhighlight()
       base_type::SetVisible (Standard_False);
       break;
     case State_Empty:
-      base_type::Erase();
+      base_type::erase();
       break;
   }
 }
@@ -164,8 +162,8 @@ void PrsMgr_Presentation::Clear (const Standard_Boolean theWithDestruction)
     return;
   }
 
-  base_type::Clear (theWithDestruction);
-  base_type::DisconnectAll (Graphic3d_TOC_DESCENDANT);
+  clear (theWithDestruction);
+  DisconnectAll (Graphic3d_TOC_DESCENDANT);
 }
 
 //=======================================================================
@@ -188,78 +186,43 @@ void PrsMgr_Presentation::Compute()
   myPresentableObject->Compute (myPresentationManager, this, aDispMode);
 }
 
-//=======================================================================
-//function : Compute
-//purpose  : Methods for hidden parts...
-//=======================================================================
-Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector)
-{
-  Handle(Graphic3d_Structure) aPrs = new Graphic3d_Structure (myPresentationManager->StructureManager());
-  myPresentableObject->Compute (Projector (theProjector), aPrs);
-  return aPrs;
-}
-
 //=======================================================================
 //function : Compute
 //purpose  :
 //=======================================================================
-void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
-                                   Handle(Graphic3d_Structure)& theStructToFill)
+void PrsMgr_Presentation::computeHLR (const Handle(Graphic3d_Camera)& theProjector,
+                                      Handle(Graphic3d_Structure)& theStructToFill)
 {
+  if (theStructToFill.IsNull())
+  {
+    theStructToFill = new Prs3d_Presentation (myPresentationManager->StructureManager());
+  }
+  Handle(Graphic3d_Structure) aPrs = theStructToFill;
   theStructToFill->Clear();
-  Handle(Prs3d_Presentation) aPrs = theStructToFill;
-  myPresentableObject->Compute (Projector (theProjector), aPrs);
+  myPresentableObject->computeHLR (theProjector, Transformation(), aPrs);
 }
 
 //=======================================================================
-//function : Compute
+//function : ~PrsMgr_Presentation
 //purpose  :
 //=======================================================================
-Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
-                                                          const Handle(Geom_Transformation)&            theTrsf)
+PrsMgr_Presentation::~PrsMgr_Presentation()
 {
-  Handle(Prs3d_Presentation) aPrs3d = new Prs3d_Presentation (myPresentationManager->StructureManager());
-  myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d);
-  return aPrs3d;
+  Erase();
 }
 
-//=======================================================================
-//function : Compute
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
-                                   const Handle(Geom_Transformation)& theTrsf,
-                                   Handle(Graphic3d_Structure)& theStructToFill)
+// =======================================================================
+// function : DumpJson
+// purpose  :
+// =======================================================================
+void PrsMgr_Presentation::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
 {
-  // recompute HLR after transformation in all the case
-  Handle(Graphic3d_Structure) aPrs = theStructToFill;
-  theStructToFill->Clear();
-  myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs);
-}
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Graphic3d_Structure)
 
-//=======================================================================
-//function : Projector
-//purpose  :
-//=======================================================================
-Handle(Prs3d_Projector) PrsMgr_Presentation::Projector (const Handle(Graphic3d_DataStructureManager)& theProjector)
-{
-  Handle(Graphic3d_Camera) aCamera = Handle(Graphic3d_CView)::DownCast (theProjector)->Camera();
-  const gp_Dir aDir = aCamera->Direction().Reversed();
-  const gp_Pnt anAt = aCamera->Center();
-  const gp_Dir anUp = aCamera->Up();
-  Handle(Prs3d_Projector) aProj = new Prs3d_Projector (!aCamera->IsOrthographic(),
-                                                       aCamera->Scale(),
-                                                       aDir.X(), aDir.Y(), aDir.Z(),
-                                                       anAt.X(), anAt.Y(), anAt.Z(),
-                                                       anUp.X(), anUp.Y(), anUp.Z());
-  return aProj;
-}
+  OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myPresentableObject)
 
-//=======================================================================
-//function : ~PrsMgr_Presentation
-//purpose  :
-//=======================================================================
-PrsMgr_Presentation::~PrsMgr_Presentation()
-{
-  Erase();
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBeforeHighlightState)
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMode)
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMustBeUpdated)
 }