ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
csgdemo.C File Reference

Combinatorial Solid Geometry example. More...

Go to the source code of this file.

Detailed Description

Combinatorial Solid Geometry example.

Stripped down to demonstrate EVE shape-extracts.

  1. Run root csgdemo.C This will produce csg.root containing the extract.
  2. Display the assebly as: root show_extract.C("csg.root")
eve_csgdemo.png
#include "TGeoManager.h"
//____________________________________________________________________________
void csgdemo ()
{
gSystem->Load("libGeom");
TCanvas *c = new TCanvas("composite shape", "A * B - C");
c->Iconify();
if (gGeoManager) delete gGeoManager;
new TGeoManager("xtru", "poza12");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *med = new TGeoMedium("MED",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
// define shape components with names
TGeoBBox *box = new TGeoBBox("box", 20., 20., 20.);
TGeoBBox *box1 = new TGeoBBox("box1", 5., 5., 5.);
TGeoSphere *sph = new TGeoSphere("sph", 5., 25.);
TGeoSphere *sph1 = new TGeoSphere("sph1", 1., 15.);
// create the composite shape based on a Boolean expression
TGeoTranslation *tr = new TGeoTranslation(0., 30., 0.);
TGeoTranslation *tr1 = new TGeoTranslation(0., 40., 0.);
TGeoTranslation *tr2 = new TGeoTranslation(0., 30., 0.);
TGeoTranslation *tr3 = new TGeoTranslation(0., 30., 0.);
tr->SetName("tr");
tr1->SetName("tr1");
tr2->SetName("tr2");
tr3->SetName("tr3");
// register all used transformations
("mir", "(sph * box) + (sph1:tr - box1:tr1)");
TGeoVolume *vol = new TGeoVolume("COMP4", cs);
top->AddNode(vol,1);
top->Draw();
en->SetVisLevel(4);
en->SaveExtract("csg.root", "CSG Demo", kFALSE);
}
Author
Andrei Gheata

Definition in file csgdemo.C.