Logo ROOT   6.18/05
Reference Guide
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);
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);
61 top->Draw();
62
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
75
77
78 en->ExpandIntoListTreesRecursively();
79 en->SaveExtract("csg.root", "CSG Demo", kFALSE);
80}
#define c(i)
Definition: RSha256.hxx:101
const Bool_t kFALSE
Definition: RtypesCore.h:88
const Bool_t kTRUE
Definition: RtypesCore.h:87
@ kMagenta
Definition: Rtypes.h:64
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
The Canvas class.
Definition: TCanvas.h:31
static void SetCSGExportNSeg(Int_t nseg)
Sets number of segments used for CSG export.
Definition: TEveGeoNode.cxx:59
A wrapper over a TGeoNode, possibly displaced with a global trasformation stored in TEveElement.
Definition: TEveGeoNode.h:93
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
static void SetEnforceTriangles(Bool_t e)
Set state of static flag EnforceTriangles.
Definition: TGLFaceSet.cxx:442
Box class.
Definition: TGeoBBox.h:18
Class handling Boolean composition of shapes.
The manager class for any TGeo geometry.
Definition: TGeoManager.h:43
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
TGeoNode * GetTopNode() const
Definition: TGeoManager.h:532
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
Base class describing materials.
Definition: TGeoMaterial.h:31
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:24
Spherical shell class.
Definition: TGeoSphere.h:18
Class describing translations.
Definition: TGeoMatrix.h:122
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:53
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1843
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1