StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
STAR_shapes.C
1 {
2 //*-- Author : Valery Fine(fine@bnl.gov) 25/12/98
3 // Based on Begin_html <a href = "http://root.cern.ch/root/html/examples/shapes.C.html">shapes.C</a>
4 // end_html
5 //
6 // To see the output of this macro, click begin_html <a href="gif/shapes.gif" >here</a> end_html
7 //=======================================================================
8 // owner: Valery Fine
9 // what it does: Use TVolume class to show "geant" based shapes
10 //=======================================================================
11  //
12  gROOT->Reset();
13  gSystem->Load("libTable");
14  c1 = new TCanvas("c1","Geometry Shapes",200,10,700,500);
15 
16  // Define some volumes
17  TBRIK *brik = new TBRIK("BRIK","BRIK","void",200,150,150);
18  TTRD1 *trd1 = new TTRD1("TRD1","TRD1","void",200,50,100,100);
19  TTRD2 *trd2 = new TTRD2("TRD2","TRD2","void",200,50,200,50,100);
20  TTRAP *trap = new TTRAP("TRAP","TRAP","void",190,0,0,60,40,90,15,120,80,180,15);
21  TPARA *para = new TPARA("PARA","PARA","void",100,200,200,15,30,30);
22  TGTRA *gtra = new TGTRA("GTRA","GTRA","void",390,0,0,20,60,40,90,15,120,80,180,15);
23  TTUBE *tube = new TTUBE("TUBE","TUBE","void",150,200,400);
24  TTUBS *tubs = new TTUBS("TUBS","TUBS","void",80,100,100,90,235);
25  TCONE *cone = new TCONE("CONE","CONE","void",100,50,70,120,150);
26  TCONS *cons = new TCONS("CONS","CONS","void",50,100,100,200,300,90,270);
27  TSPHE *sphe = new TSPHE("SPHE","SPHE","void",25,340, 45,135, 0,270);
28  TSPHE *sphe1 = new TSPHE("SPHE1","SPHE1","void",0,140, 0,180, 0,360);
29  TSPHE *sphe2 = new TSPHE("SPHE2","SPHE2","void",0,200, 10,120, 45,145);
30 
31  pcon = new TPCON("PCON","PCON","void",180,270,4);
32  pcon->DefineSection(0,-200,50,100);
33  pcon->DefineSection(1,-50,50,80);
34  pcon->DefineSection(2,50,50,80);
35  pcon->DefineSection(3,200,50,100);
36 
37  pgon = new TPGON("PGON","PGON","void",180,270,8,4);
38  pgon->DefineSection(0,-200,50,100);
39  pgon->DefineSection(1,-50,50,80);
40  pgon->DefineSection(2,50,50,80);
41  pgon->DefineSection(3,200,50,100);
42 
43  // Set shapes attributes
44  brik->SetLineColor(1);
45  trd1->SetLineColor(2);
46  trd2->SetLineColor(3);
47  trap->SetLineColor(4);
48  para->SetLineColor(5);
49  gtra->SetLineColor(7);
50  tube->SetLineColor(6);
51  tubs->SetLineColor(7);
52  cone->SetLineColor(2);
53  cons->SetLineColor(3);
54  pcon->SetLineColor(6);
55  pgon->SetLineColor(2);
56  sphe->SetLineColor(kRed);
57  sphe1->SetLineColor(kBlack);
58  sphe2->SetLineColor(kBlue);
59 
60 
61  // Build the geometry hierarchy
62  node1 = new TVolume("NODE1","NODE1","BRIK");
63 
64  node1->Add(new TVolume("NODE2","NODE2","TRD1"),0,0,-1000);
65  node1->Add(new TVolume("NODE3","NODE3","TRD2"),0,0,1000);
66  node1->Add(new TVolume("NODE4","NODE4","TRAP"),0,-1000,0);
67  node1->Add(new TVolume("NODE5","NODE5","PARA"),0,1000,0);
68  node1->Add(new TVolume("NODE6","NODE6","TUBE"),-1000,0,0);
69  node1->Add(new TVolume("NODE7","NODE7","TUBS"),1000,0,0);
70  node1->Add(new TVolume("NODE8","NODE8","CONE"),-300,-300,0);
71  node1->Add(new TVolume("NODE9","NODE9","CONS"),300,300,0);
72  node1->Add(new TVolume("NODE10","NODE10","PCON"),0,-1000,-1000);
73  node1->Add(new TVolume("NODE11","NODE11","PGON"),0,1000,1000);
74  node1->Add(new TVolume("NODE12","NODE12","GTRA"),0,-400,700);
75  node1->Add(new TVolume("NODE13","NODE13","SPHE"),10,-400,500);
76  node1->Add(new TVolume("NODE14","NODE14","SPHE1"),10, 250,300);
77  node1->Add(new TVolume("NODE15","NODE15","SPHE2"),10,-100,-200);
78 
79  node1->MarkAll();
80 
81  // Create "view" object of the "node1" to browse
82  TVolumeView view(*node1);
83 
84  view.Draw();
85 
86 
87  //
88  // Draw the geometry using the x3d viewer.
89  // Note that this viewver may also be invoked from the "View" menu in
90  // the canvas tool bar
91  // c1->x3d();
92  //
93  // once in x3d viewer, type m to see the menu.
94  // For example typing r will show a solid model of this geometry.
95 }