Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
shapes.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// The old geometry shapes (see script geodemo.C)
4///
5/// \macro_image
6/// \macro_code
7///
8/// \author Rene Brun
9
10#include "TGeometry.h"
11#include "TGeoManager.h"
12
13void shapes()
14{
15 TCanvas *c1 = new TCanvas("glc1", "Geometry Shapes", 200, 10, 700, 500);
16
17 gSystem->Load("libGeom");
18 // delete previous geometry objects in case this script is re-executed
19 if (gGeoManager) {
22 }
23
24 // Define some volumes
25 TBRIK *brik = new TBRIK("BRIK", "BRIK", "void", 200, 150, 150);
26 TTRD1 *trd1 = new TTRD1("TRD1", "TRD1", "void", 200, 50, 100, 100);
27 TTRD2 *trd2 = new TTRD2("TRD2", "TRD2", "void", 200, 50, 200, 50, 100);
28 TTRAP *trap = new TTRAP("TRAP", "TRAP", "void", 190, 0, 0, 60, 40, 90, 15, 120, 80, 180, 15);
29 TPARA *para = new TPARA("PARA", "PARA", "void", 100, 200, 200, 15, 30, 30);
30 TGTRA *gtra = new TGTRA("GTRA", "GTRA", "void", 390, 0, 0, 20, 60, 40, 90, 15, 120, 80, 180, 15);
31 TTUBE *tube = new TTUBE("TUBE", "TUBE", "void", 150, 200, 400);
32 TTUBS *tubs = new TTUBS("TUBS", "TUBS", "void", 80, 100, 100, 90, 235);
33 TCONE *cone = new TCONE("CONE", "CONE", "void", 100, 50, 70, 120, 150);
34 TCONS *cons = new TCONS("CONS", "CONS", "void", 50, 100, 100, 200, 300, 90, 270);
35 TSPHE *sphe = new TSPHE("SPHE", "SPHE", "void", 25, 340, 45, 135, 0, 270);
36 TSPHE *sphe1 = new TSPHE("SPHE1", "SPHE1", "void", 0, 140, 0, 180, 0, 360);
37 TSPHE *sphe2 = new TSPHE("SPHE2", "SPHE2", "void", 0, 200, 10, 120, 45, 145);
38
39 TPCON *pcon = new TPCON("PCON", "PCON", "void", 180, 270, 4);
40 pcon->DefineSection(0, -200, 50, 100);
41 pcon->DefineSection(1, -50, 50, 80);
42 pcon->DefineSection(2, 50, 50, 80);
43 pcon->DefineSection(3, 200, 50, 100);
44
45 TPGON *pgon = new TPGON("PGON", "PGON", "void", 180, 270, 8, 4);
46 pgon->DefineSection(0, -200, 50, 100);
47 pgon->DefineSection(1, -50, 50, 80);
48 pgon->DefineSection(2, 50, 50, 80);
49 pgon->DefineSection(3, 200, 50, 100);
50
51 // Set shapes attributes
52 brik->SetLineColor(1);
53 trd1->SetLineColor(2);
54 trd2->SetLineColor(3);
55 trap->SetLineColor(4);
56 para->SetLineColor(5);
57 gtra->SetLineColor(7);
58 tube->SetLineColor(6);
59 tubs->SetLineColor(7);
60 cone->SetLineColor(2);
61 cons->SetLineColor(3);
62 pcon->SetLineColor(6);
63 pgon->SetLineColor(2);
64 sphe->SetLineColor(kRed);
65 sphe1->SetLineColor(kBlack);
66 sphe2->SetLineColor(kBlue);
67
68 // Build the geometry hierarchy
69 TNode *node1 = new TNode("NODE1", "NODE1", "BRIK");
70 node1->cd();
71
72 TNode *node2 = new TNode("NODE2", "NODE2", "TRD1", 0, 0, -1000);
73 TNode *node3 = new TNode("NODE3", "NODE3", "TRD2", 0, 0, 1000);
74 TNode *node4 = new TNode("NODE4", "NODE4", "TRAP", 0, -1000, 0);
75 TNode *node5 = new TNode("NODE5", "NODE5", "PARA", 0, 1000, 0);
76 TNode *node6 = new TNode("NODE6", "NODE6", "TUBE", -1000, 0, 0);
77 TNode *node7 = new TNode("NODE7", "NODE7", "TUBS", 1000, 0, 0);
78 TNode *node8 = new TNode("NODE8", "NODE8", "CONE", -300, -300, 0);
79 TNode *node9 = new TNode("NODE9", "NODE9", "CONS", 300, 300, 0);
80 TNode *node10 = new TNode("NODE10", "NODE10", "PCON", 0, -1000, -1000);
81 TNode *node11 = new TNode("NODE11", "NODE11", "PGON", 0, 1000, 1000);
82 TNode *node12 = new TNode("NODE12", "NODE12", "GTRA", 0, -400, 700);
83 TNode *node13 = new TNode("NODE13", "NODE13", "SPHE", 10, -400, 500);
84 TNode *node14 = new TNode("NODE14", "NODE14", "SPHE1", 10, 250, 300);
85 TNode *node15 = new TNode("NODE15", "NODE15", "SPHE2", 10, -100, -200);
86
87 // Draw this geometry in the current canvas
88 node1->cd();
89 node1->Draw("gl");
90 c1->Update();
91 //
92 // Draw the geometry using the OpenGL viewer.
93 // Note that this viewer may also be invoked from the "View" menu in
94 // the canvas tool bar
95 //
96 // once in the viewer, select the Help button
97 // For example typing r will show a solid model of this geometry.
98}
@ kRed
Definition Rtypes.h:66
@ kBlack
Definition Rtypes.h:65
@ kBlue
Definition Rtypes.h:66
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
A box with faces perpendicular to the axes.
Definition TBRIK.h:26
A conical tube.
Definition TCONE.h:28
A segment of a conical tube.
Definition TCONS.h:27
The Canvas class.
Definition TCanvas.h:23
A general twisted trapezoid.
Definition TGTRA.h:27
TObjArray * GetListOfNodes()
TObjArray * GetListOfShapes() const
TNode description.
Definition TNode.h:33
void Draw(Option_t *option="") override
Draw Referenced node with current parameters.
Definition TNode.cxx:322
virtual void cd(const char *path=nullptr)
Change Current Reference node to this.
Definition TNode.cxx:249
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
A parallelepiped.
Definition TPARA.h:30
A polycone.
Definition TPCON.h:33
virtual void DefineSection(Int_t secNum, Float_t z, Float_t rmin, Float_t rmax)
Defines section secNum of the polycone.
Definition TPCON.cxx:174
A polygon.
Definition TPGON.h:30
A Sphere.
Definition TSPHE.h:28
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1857
A general trapezoid.
Definition TTRAP.h:33
A trapezoid with the x dimension varying along z.
Definition TTRD1.h:28
A trapezoid with both x and y dimensions varying along z.
Definition TTRD2.h:29
A tube.
Definition TTUBE.h:32
A segment of a tube.
Definition TTUBS.h:29
return c1
Definition legend1.C:41