From $ROOTSYS/tutorials/eve/csgdemo.C

// Combinatorial Solid Geometry example
// Author: Andrei Gheata
//
// 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")

#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);
   gGeoManager->SetTopVolume(top);

   // 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
   tr->RegisterYourself();
   tr1->RegisterYourself();
   tr2->RegisterYourself();
   tr3->RegisterYourself();

   TGeoCompositeShape *cs = new TGeoCompositeShape
      ("mir", "(sph * box) + (sph1:tr - box1:tr1)");

   TGeoVolume *vol = new TGeoVolume("COMP4", cs);
   vol->SetLineColor(kMagenta);
   top->AddNode(vol,1);
   gGeoManager->CloseGeometry();
   top->Draw();

   gGeoManager->SetNsegments(40);
   TEveGeoNode::SetCSGExportNSeg(40);

   TGLFaceSet::SetEnforceTriangles(kTRUE);
   TEveManager::Create();

   TGeoNode* node = gGeoManager->GetTopNode();
   TEveGeoTopNode* en = new TEveGeoTopNode(gGeoManager, node);
   en->SetVisLevel(4);
   en->GetNode()->GetVolume()->SetVisibility(kFALSE);

   gEve->AddGlobalElement(en);

   gEve->Redraw3D(kTRUE);

   en->ExpandIntoListTreesRecursively();
   en->SaveExtract("csg.root", "CSG Demo", kFALSE);
}
 csgdemo.C:1
 csgdemo.C:2
 csgdemo.C:3
 csgdemo.C:4
 csgdemo.C:5
 csgdemo.C:6
 csgdemo.C:7
 csgdemo.C:8
 csgdemo.C:9
 csgdemo.C:10
 csgdemo.C:11
 csgdemo.C:12
 csgdemo.C:13
 csgdemo.C:14
 csgdemo.C:15
 csgdemo.C:16
 csgdemo.C:17
 csgdemo.C:18
 csgdemo.C:19
 csgdemo.C:20
 csgdemo.C:21
 csgdemo.C:22
 csgdemo.C:23
 csgdemo.C:24
 csgdemo.C:25
 csgdemo.C:26
 csgdemo.C:27
 csgdemo.C:28
 csgdemo.C:29
 csgdemo.C:30
 csgdemo.C:31
 csgdemo.C:32
 csgdemo.C:33
 csgdemo.C:34
 csgdemo.C:35
 csgdemo.C:36
 csgdemo.C:37
 csgdemo.C:38
 csgdemo.C:39
 csgdemo.C:40
 csgdemo.C:41
 csgdemo.C:42
 csgdemo.C:43
 csgdemo.C:44
 csgdemo.C:45
 csgdemo.C:46
 csgdemo.C:47
 csgdemo.C:48
 csgdemo.C:49
 csgdemo.C:50
 csgdemo.C:51
 csgdemo.C:52
 csgdemo.C:53
 csgdemo.C:54
 csgdemo.C:55
 csgdemo.C:56
 csgdemo.C:57
 csgdemo.C:58
 csgdemo.C:59
 csgdemo.C:60
 csgdemo.C:61
 csgdemo.C:62
 csgdemo.C:63
 csgdemo.C:64
 csgdemo.C:65
 csgdemo.C:66
 csgdemo.C:67
 csgdemo.C:68
 csgdemo.C:69
 csgdemo.C:70
 csgdemo.C:71
 csgdemo.C:72
 csgdemo.C:73
 csgdemo.C:74
 csgdemo.C:75