00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 void csgdemo ()
00012 {
00013 gSystem->Load("libGeom");
00014
00015 TCanvas *c = new TCanvas("composite shape", "A * B - C");
00016 c->Iconify();
00017
00018 if (gGeoManager) delete gGeoManager;
00019
00020 new TGeoManager("xtru", "poza12");
00021 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00022 TGeoMedium *med = new TGeoMedium("MED",1,mat);
00023 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00024 gGeoManager->SetTopVolume(top);
00025
00026
00027 TGeoBBox *box = new TGeoBBox("box", 20., 20., 20.);
00028 TGeoBBox *box1 = new TGeoBBox("box1", 5., 5., 5.);
00029 TGeoSphere *sph = new TGeoSphere("sph", 5., 25.);
00030 TGeoSphere *sph1 = new TGeoSphere("sph1", 1., 15.);
00031
00032 TGeoTranslation *tr = new TGeoTranslation(0., 30., 0.);
00033 TGeoTranslation *tr1 = new TGeoTranslation(0., 40., 0.);
00034 TGeoTranslation *tr2 = new TGeoTranslation(0., 30., 0.);
00035 TGeoTranslation *tr3 = new TGeoTranslation(0., 30., 0.);
00036 tr->SetName("tr");
00037 tr1->SetName("tr1");
00038 tr2->SetName("tr2");
00039 tr3->SetName("tr3");
00040
00041 tr->RegisterYourself();
00042 tr1->RegisterYourself();
00043 tr2->RegisterYourself();
00044 tr3->RegisterYourself();
00045
00046 TGeoCompositeShape *cs = new TGeoCompositeShape
00047 ("mir", "(sph * box) + (sph1:tr - box1:tr1)");
00048
00049 TGeoVolume *vol = new TGeoVolume("COMP4", cs);
00050 vol->SetLineColor(kMagenta);
00051 top->AddNode(vol,1);
00052 gGeoManager->CloseGeometry();
00053 top->Draw();
00054
00055 gGeoManager->SetNsegments(40);
00056 TEveGeoNode::SetCSGExportNSeg(40);
00057
00058 TGLFaceSet::SetEnforceTriangles(kTRUE);
00059 TEveManager::Create();
00060
00061 TGeoNode* node = gGeoManager->GetTopNode();
00062 TEveGeoTopNode* en = new TEveGeoTopNode(gGeoManager, node);
00063 en->SetVisLevel(4);
00064 en->GetNode()->GetVolume()->SetVisibility(kFALSE);
00065
00066 gEve->AddGlobalElement(en);
00067
00068 gEve->Redraw3D(kTRUE);
00069
00070 en->ExpandIntoListTreesRecursively();
00071 en->SaveExtract("csg.root", "CSG Demo", kFALSE);
00072 }