ROOT   Reference Guide
Searching...
No Matches
tank.C File Reference

Detailed Description

Drawing a fine tank, using ROOT geometry class.

Reviewed by Sunman Kim (sunma.nosp@m.n98@.nosp@m.hanma.nosp@m.il.n.nosp@m.et) Supervisor: Prof. Inkyu Park (icpar.nosp@m.k@ph.nosp@m.ysics.nosp@m..uos.nosp@m..ac.k.nosp@m.r)

How to run: .x tank.C in ROOT terminal, then use OpenGL

This macro was created for the evaluation of Computational Physics course in 2006. We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team

#include "TGeoManager.h"
void tank()
{
TGeoManager *geom = new TGeoManager("geom","My 3D Project");
//------------------Creat materials-----------------------------
TGeoMaterial *vacuum = new TGeoMaterial("vacuum",0,0,0);
TGeoMaterial *Fe = new TGeoMaterial("Fe",55.84,26.7,7.87);
TGeoMaterial *Cu = new TGeoMaterial("Cu",63.549,29,8.92);
//------------------Creat media----------------------------------
TGeoMedium *Air = new TGeoMedium("Air",0,vacuum);
TGeoMedium *Iron = new TGeoMedium("Iron",1,Fe);
//------------------Create TOP volume----------------------------
TGeoVolume *top = geom->MakeBox("top",Air,100,100,100);
geom->SetTopVolume(top);
geom->SetTopVisible(0);
// If you want to see the boundary, please input the number, 1 instead of 0.
// Like this, geom->SetTopVisible(1);
//-----------------Create Object volume--------------------------
//Now, we start real shape
//UpperBody
TGeoVolume *pl=geom->MakeBox("pl",Iron,210,93,20);
pl->SetLineColor(42);
TGeoVolume *pl1=geom->MakeBox("pl1",Iron,217,50,5);
pl1->SetLineColor(42);
TGeoVolume *pl2=geom->MakeTrd2("pl2",Iron,219,150,50,40,10);
pl2->SetLineColor(42);
TGeoVolume *plu=geom->MakeTrd2("plu",Iron,210,70,100,100,5);
plu->SetLineColor(42);
TGeoVolume *sp=geom->MakeTubs("sp",Iron,30,40,50,10,60);//Small Plate front
sp->SetLineColor(42);
//Top which will have the gun
TGeoVolume *tp=geom->MakeSphere("tp",Iron,0,100,67,90,0,360);//tp is Top with gun
tp->SetLineColor(12);
TGeoVolume *tp1=geom->MakeSphere("tp1",Iron,90,190,0,29,0,360);//tp1 is Top with roof
tp1->SetLineColor(12);
TGeoVolume *mgg=geom->MakeTubs("mgg",Iron,0,25,30,42,136);//Main Gun Guard
mgg->SetLineColor(12);
TGeoVolume *mgg1=geom->MakeTrd2("mgg1",Iron,30.5,45,19,30,35);
mgg1->SetLineColor(12);
//Small Top infront Top
TGeoVolume *stp=geom->MakeSphere("stp",Iron,0,30,67,90,0,360);//Top for driver
stp->SetLineColor(12);
TGeoVolume *stp1=geom->MakeSphere("stp1",Iron,115,120,0,12,0,360);//Top with roof
stp1->SetLineColor(12);
TGeoVolume *stpo1=geom->MakeBox("stpo1",Iron,3,1,5);
stpo1->SetLineColor(42);//Small T P Option 1
TGeoVolume *mg1=geom->MakeCone("mg1",Iron,160,4,5,4,7);
mg1->SetLineColor(12);
TGeoVolume *mg1o1=geom->MakeCone("mg1o1",Iron,40,4.1,8,4.1,8);
mg1o1->SetLineColor(12);//
//Underbody
TGeoVolume *underbody=geom->MakeTrd2("underbody",Iron,160,210,93,93,30);
underbody->SetLineColor(28);
TGeoVolume *bs=geom->MakeTubs("bs",Iron,0,20,93,10,270);
bs->SetLineColor(42);
TGeoVolume *bsp=geom->MakeTubs("bsp",Iron,0,20,30,10,270);
bsp->SetLineColor(42);
TGeoVolume *Tip=geom->MakeCone("Tip",Iron,21,0,24,0,24); //Tip is wheel
Tip->SetLineColor(12);
TGeoVolume *Tip1=geom->MakeCone("Tip1",Iron,10,23,30,25,30);
Tip1->SetLineColor(14);
TGeoVolume *Tip2=geom->MakeCone("Tip2",Iron,30,0,7,0,7);
Tip2->SetLineColor(42);
TGeoVolume *wheel=geom->MakeCone("wheel",Iron,30,0,7,0,7);
wheel->SetLineColor(42);
TGeoVolume *wheel1=geom->MakeCone("wheel1",Iron,21,0,16,0,16); //innner wheel
wheel1->SetLineColor(14);
TGeoVolume *wheel2=geom->MakeCone("wheel2",Iron,10,15,22,15,22); //outter wheel
wheel2->SetLineColor(12);
TGeoVolume *Tip0=geom->MakeCone("Tip0",Iron,30,0,7,0,7);
Tip0->SetLineColor(12);
TGeoVolume *Tip01=geom->MakeCone("Tip01",Iron,10,7,10.5,7,10.5);
Tip0->SetLineColor(14);
char name[50];
TGeoVolume *WH;//piece of chain
TGeoVolume *whp;
TGeoVolume *who;
//consist upper chain
for(int i=0;i<26;i++){
sprintf(name,"wh%d",i);
WH = geom->MakeBox(name,Iron,5.5,22,2);
whp = geom->MakeBox(name,Iron,5,2.1,4);
who = geom->MakeBox(name,Iron,2,6,1);
WH->SetLineColor(12);
whp->SetLineColor(14);
who->SetLineColor(42);
}
//chain connector
TGeoVolume *WHl = geom->MakeBox(name,Iron,187.5,5,1);
WHl->SetLineColor(12);
//just one side
//--------------------------
TGeoVolume *chc0=geom->MakeTubs("chc0",Iron,24.5,26.5,5,-34,0);//Small Plate front
chc0->SetLineColor(12);
TGeoVolume *chc1=geom->MakeTubs("chc1",Iron,24.5,26.5,5,-68,-34);//Small Plate front
chc1->SetLineColor(12);
TGeoVolume *chc2=geom->MakeTubs("chc2",Iron,24.5,26.5,5,-102,-68);//Small Plate front
chc2->SetLineColor(12);
TGeoVolume *chc3=geom->MakeTubs("chc3",Iron,24.5,26.5,5,-136,-102);//Small Plate front
chc3->SetLineColor(12);
TGeoVolume *chcl=geom->MakeBox("chcl",Iron,5,5,1);
chcl->SetLineColor(12);
TGeoVolume *chc4=geom->MakeTubs("chc4",Iron,31.5,34.5,5,-175,-145);//Small Plate front
chc4->SetLineColor(12);
//-------------------------
TGeoVolume *chc0i=geom->MakeTubs("chc0i",Iron,24.5,26.5,5,0,34);//Small Plate front
chc0i->SetLineColor(12);
TGeoVolume *chc1i=geom->MakeTubs("chc1i",Iron,24.5,26.5,5,34,68);//Small Plate front
chc1i->SetLineColor(12);
TGeoVolume *chc2i=geom->MakeTubs("chc2i",Iron,24.5,26.5,5,68,102);//Small Plate front
chc2i->SetLineColor(12);
TGeoVolume *chc3i=geom->MakeTubs("chc3i",Iron,24.5,26.5,5,102,136);//Small Plate front
chc3i->SetLineColor(12);
TGeoVolume *chc4i=geom->MakeTubs("chc4i",Iron,31.5,33,5,145,175);//Small Plate front
chc4i->SetLineColor(12);
//just other side
//--------------------------
//-------------------------
//consist under chain
for(int i=0;i<20;i++){
sprintf(name,"wh%d",i);
}
TGeoVolume *WHlu = geom->MakeBox(name,Iron,140,5,1);//chain connetor in under
WHlu->SetLineColor(12);
//Now, we put real shape
top->SetVisibility(0);
geom->CloseGeometry();
//------------------draw on GL viewer-------------------------------
top->Draw("ogl");
}
char name[80]
Definition TGX11.cxx:110
Class describing rotation + translation.
Definition TGeoMatrix.h:292
The manager class for any TGeo geometry.
Definition TGeoManager.h:45
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
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.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
Base class describing materials.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:24
Class describing rotations.
Definition TGeoMatrix.h:175
Class describing translations.
Definition TGeoMatrix.h:122
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:49
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
void Draw(Option_t *option="") override
draw top volume according to option
virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void SetLineColor(Color_t lcolor) override
Set the line color.

Definition in file tank.C.