Logo ROOT   6.16/01
Reference Guide
show_extract.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
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>
17#include <ROOT/REveGeoShapeExtract.hxx>
18#include <ROOT/REveGeoShape.hxx>
19
20namespace REX = ROOT::Experimental;
21
22REX::REveGeoShape *eve_shape = 0;
23
24void show_extract(const char* file="csg.root")
25{
26 // disable browser cache - all scripts and html files will be loaded every time, useful for development
27 // gEnv->SetValue("WebGui.HttpMaxAge", 0);
28
29 REX::REveManager::Create();
30
32
33 TIter next(gDirectory->GetListOfKeys());
34 TKey* key;
35
36 const TString extract_class("ROOT::Experimental::REveGeoShapeExtract");
37
38 while ((key = (TKey*) next()))
39 {
40 if (extract_class == key->GetClassName())
41 {
42 auto gse = (REX::REveGeoShapeExtract*) key->ReadObj();
43 eve_shape = REX::REveGeoShape::ImportShapeExtract(gse, 0);
44 REX::gEve->AddGlobalElement(eve_shape);
45 }
46 }
47
48 if ( ! eve_shape)
49 {
50 Error("show_extract.C", "No keys of class '%s'.", extract_class.Data());
51 return;
52 }
53
54 eve_shape->GetShape()->Draw("ogl");
55}
#define gDirectory
Definition: TDirectory.h:213
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3975
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual const char * GetClassName() const
Definition: TKey.h:71
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition: TKey.cxx:722
Basic string class.
Definition: TString.h:131
Definition: file.py:1