Logo ROOT   6.07/09
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 assebly 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 //____________________________________________________________________________
19 void csgdemo ()
20 {
21  gSystem->Load("libGeom");
22 
23  TCanvas *c = new TCanvas("composite shape", "A * B - C");
24  c->Iconify();
25 
26  if (gGeoManager) delete gGeoManager;
27 
28  new TGeoManager("xtru", "poza12");
29  TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
30  TGeoMedium *med = new TGeoMedium("MED",1,mat);
31  TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
33 
34  // define shape components with names
35  TGeoBBox *box = new TGeoBBox("box", 20., 20., 20.);
36  TGeoBBox *box1 = new TGeoBBox("box1", 5., 5., 5.);
37  TGeoSphere *sph = new TGeoSphere("sph", 5., 25.);
38  TGeoSphere *sph1 = new TGeoSphere("sph1", 1., 15.);
39  // create the composite shape based on a Boolean expression
40  TGeoTranslation *tr = new TGeoTranslation(0., 30., 0.);
41  TGeoTranslation *tr1 = new TGeoTranslation(0., 40., 0.);
42  TGeoTranslation *tr2 = new TGeoTranslation(0., 30., 0.);
43  TGeoTranslation *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  TGeoVolume *vol = new TGeoVolume("COMP4", cs);
58  vol->SetLineColor(kMagenta);
59  top->AddNode(vol,1);
61  top->Draw();
62 
65 
68 
69  TGeoNode* node = gGeoManager->GetTopNode();
70  TEveGeoTopNode* en = new TEveGeoTopNode(gGeoManager, node);
71  en->SetVisLevel(4);
73 
75 
77 
79  en->SaveExtract("csg.root", "CSG Demo", kFALSE);
80 }
Spherical shell class.
Definition: TGeoSphere.h:19
The manager class for any TGeo geometry.
Definition: TGeoManager.h:38
Box class.
Definition: TGeoBBox.h:19
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:106
void SaveExtract(const char *file, const char *name, Bool_t leafs_only)
Save the shape tree as TEveGeoShapeExtract.
return c
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:61
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
virtual void Draw(Option_t *option="")
draw top volume according to option
Class describing translations.
Definition: TGeoMatrix.h:131
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1818
Base class describing materials.
Definition: TGeoMaterial.h:35
const Bool_t kFALSE
Definition: Rtypes.h:92
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
void Iconify()
Definition: TCanvas.h:185
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
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.
TGeoNode * GetTopNode() const
Definition: TGeoManager.h:498
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.
Definition: TGLFaceSet.cxx:442
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition: TGeoVolume.cxx:985
A wrapper over a TGeoNode, possibly displaced with a global trasformation stored in TEveElement...
Definition: TEveGeoNode.h:92
Class handling Boolean composition of shapes.
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Definition: TGeoMatrix.cxx:575
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
void SetVisLevel(Int_t vl)
Definition: TEveGeoNode.h:115
The Canvas class.
Definition: TCanvas.h:41
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:554
virtual void SetVisibility(Bool_t vis=kTRUE)
set visibility of this volume
static void SetCSGExportNSeg(Int_t nseg)
Sets number of segments used for CSG export.
Definition: TEveGeoNode.cxx:59
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:25
virtual void SetLineColor(Color_t lcolor)
Set the line color.
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:51
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
TGeoNode * GetNode() const
Definition: TEveGeoNode.h:57
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void ExpandIntoListTreesRecursively()
Expand children into all list-trees recursively.