Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
show_extract.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve7
3 /// Helper script for showing of extracted / simplified geometries.
4 /// By default shows a simplified ALICE geometry.
5 ///
6 /// \image html eve_show_extract.png
7 /// \macro_code
8 ///
9 /// \author Matevz Tadel
10 
11 #include "TFile.h"
12 #include "TKey.h"
13 
14 #include "TGeoShape.h"
15 
16 #include <ROOT/REveManager.hxx>
18 #include <ROOT/REveGeoShape.hxx>
19 
20 namespace REX = ROOT::Experimental;
21 
22 void show_extract(const char* file="csg.root")
23 {
24  // disable browser cache - all scripts and html files will be loaded every time, useful for development
25  // gEnv->SetValue("WebGui.HttpMaxAge", 0);
26 
27  auto eveMng = REX::REveManager::Create();
28 
29  TFile::Open(file);
30 
31  TIter next(gDirectory->GetListOfKeys());
32 
33  const TString extract_class("ROOT::Experimental::REveGeoShapeExtract");
34 
35  REX::REveGeoShape *eve_shape = nullptr;
36 
37  while (auto key = (TKey *)next())
38  {
39  if (extract_class == key->GetClassName())
40  {
41  auto gse = (REX::REveGeoShapeExtract*) key->ReadObj();
42  eve_shape = REX::REveGeoShape::ImportShapeExtract(gse, 0);
43  eveMng->AddGlobalElement(eve_shape);
44  }
45  }
46 
47  if (!eve_shape)
48  {
49  Error("show_extract.C", "No keys of class '%s'.", extract_class.Data());
50  return;
51  }
52 
53  eve_shape->GetShape()->Draw("ogl");
54 }