Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
csgdemo.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Combinatorial Solid Geometry example
4///
5/// Stripped down to demonstrate EVE shape-extracts.
6/// 1. `Run root csgdemo.C`
7/// This will produce csg.root containing the extract.
8/// 2. Display the assembly as:
9/// `root show_extract.C("csg.root")`
10///
11/// \image html eve_csgdemo.png
12/// \macro_code
13///
14/// \author Andrei Gheata
15
16#include "TGeoManager.h"
17
18//____________________________________________________________________________
19void csgdemo ()
20{
21 gSystem->Load("libGeom");
22
23 auto c = new TCanvas("composite shape", "A * B - C");
24 c->Iconify();
25
26 if (gGeoManager) delete gGeoManager;
27
28 new TGeoManager("xtru", "poza12");
29 auto mat = new TGeoMaterial("Al", 26.98,13,2.7);
30 auto med = new TGeoMedium("MED",1,mat);
31 auto top = gGeoManager->MakeBox("TOP",med,100,100,100);
32 gGeoManager->SetTopVolume(top);
33
34 // define shape components with names
35 auto box = new TGeoBBox("box", 20., 20., 20.);
36 auto box1 = new TGeoBBox("box1", 5., 5., 5.);
37 auto sph = new TGeoSphere("sph", 5., 25.);
38 auto sph1 = new TGeoSphere("sph1", 1., 15.);
39 // create the composite shape based on a Boolean expression
40 auto tr = new TGeoTranslation(0., 30., 0.);
41 auto tr1 = new TGeoTranslation(0., 40., 0.);
42 auto tr2 = new TGeoTranslation(0., 30., 0.);
43 auto tr3 = new TGeoTranslation(0., 30., 0.);
44 tr->SetName("tr");
45 tr1->SetName("tr1");
46 tr2->SetName("tr2");
47 tr3->SetName("tr3");
48 // register all used transformations
49 tr->RegisterYourself();
50 tr1->RegisterYourself();
51 tr2->RegisterYourself();
52 tr3->RegisterYourself();
53
55 ("mir", "(sph * box) + (sph1:tr - box1:tr1)");
56
57 auto vol = new TGeoVolume("COMP4", cs);
58 vol->SetLineColor(kMagenta);
59 top->AddNode(vol,1);
60 gGeoManager->CloseGeometry();
61 top->Draw();
62
63 gGeoManager->SetNsegments(40);
65
68
69 auto node = gGeoManager->GetTopNode();
70 auto en = new TEveGeoTopNode(gGeoManager, node);
71 en->SetVisLevel(4);
72 en->GetNode()->GetVolume()->SetVisibility(kFALSE);
73
74 gEve->AddGlobalElement(en);
75
76 gEve->Redraw3D(kTRUE);
77
78 en->ExpandIntoListTreesRecursively();
79 en->SaveExtract("csg.root", "CSG Demo", kFALSE);
80}
#define c(i)
Definition RSha256.hxx:101
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
@ kMagenta
Definition Rtypes.h:66
R__EXTERN TEveManager * gEve
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TSystem * gSystem
Definition TSystem.h:566
The Canvas class.
Definition TCanvas.h:23
static void SetCSGExportNSeg(Int_t nseg)
Sets number of segments used for CSG export.
A wrapper over a TGeoNode, possibly displaced with a global trasformation stored in TEveElement.
Definition TEveGeoNode.h:90
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
static void SetEnforceTriangles(Bool_t e)
Set state of static flag EnforceTriangles.
Box class.
Definition TGeoBBox.h:17
Composite shapes are Boolean combinations of two or more shape components.
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
Base class describing materials.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
TGeoSphere are not just balls having internal and external radii, but sectors of a sphere having defi...
Definition TGeoSphere.h:17
Class describing translations.
Definition TGeoMatrix.h:116
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1