From $ROOTSYS/tutorials/geom/xtruSamples.C

void xtruSamples()
{
// Draw a sample of TXTRU shapes some convex, concave (and possibly malformed)
// Change Bool_t's to test alternative specifications
// Author: Robert Hatcher (rhatcher@fnal.gov) 2000.09.06

// One normally specifies the x-y points in counter-clockwise order;
// flip this to TRUE to test that it doesn't matter.
  Bool_t makecw      = kFALSE;

// One normally specifies the z points in increasing z order;
// flip this to TRUE to test that it doesn't matter.
  Bool_t reversez    = kFALSE;

// One shouldn't be creating malformed polygons
// but to test what happens when one does here's a flag.
// The effect will be only apparent in solid rendering mode
  Bool_t domalformed = kFALSE;
//  domalformed = kTRUE;

  c1 = new TCanvas("c1","sample TXTRU Shapes",200,10,640,640);

// Create a new geometry
  TGeometry* geom = new TGeometry("sample","sample");
  geom->cd();

// Define the complexity of the drawing
  Int_t zseg     = 6;  // either 2 or 6
  Int_t extravis = 0;  // make extra z "arrow" visible

  Float_t unit = 1;

// Create a large BRIK to embed things into
  Float_t bigdim = 12.5*unit;
  TBRIK* world = new TBRIK("world","world","void",bigdim,bigdim,bigdim);

  // Create the main node, make it invisible
  TNode* worldnode = new TNode("worldnode","world node",world);
  worldnode->SetVisibility(0);
  worldnode->cd();

// Canonical shape ... gets further modified by scale factors
// to create convex (and malformed) versions
  Float_t x[] = { -0.50, -1.20,  1.20,  0.50,  0.50,  1.20, -1.20, -0.50 };
  Float_t y[] = { -0.75, -2.00, -2.00, -0.75,  0.75,  2.00,  2.00,  0.75 };
  Float_t z[] = { -0.50, -1.50, -1.50,  1.50,  1.50,  0.50 };
  Float_t s[] = {  0.50,  1.00,  1.50,  1.50,  1.00,  0.50 };
  Int_t   nxy = sizeof(x)/sizeof(Float_t);
  Float_t convexscale[] = { 7.0, -1.0, 1.5 };

  Int_t icolor[] = { 1, 2, 3, 2, 2, 2, 4, 2, 6 };

// xycase and zcase:  0=convex, 1=malformed, 2=concave
// this will either create a 2x2 matrix of shapes
// or a 3x3 array (if displaying malformed versions)
  for (Int_t zcase = 0; zcase<3; zcase++) {
     if (zcase == 1 && !domalformed) continue;
     for (Int_t xycase = 0; xycase<3; xycase++) {
        if (xycase == 1 && !domalformed) continue;

        char name[9];
        sprintf(name,"txtru%1d%1d%1d",xycase,zcase,zseg);
        TXTRU* mytxtru = new TXTRU(name,name,"void",8,2);

        Int_t i, j;
        Float_t xsign = (makecw) ? -1 : 1;
        Float_t zsign = (reversez) ? -1 : 1;

        // set the vertex points
        for (i=0; i<nxy; i++) {
           Float_t xtmp = x[i]*xsign;
           Float_t ytmp = y[i];
           if (i==0||i==3||i==4||i==7) xtmp *= convexscale[xycase];
           if (xycase==2) xtmp *=2;
           mytxtru->DefineVertex(i,xtmp,ytmp);
        }
        // set the z segment positions and scales
        for (i=0, j=0; i<zseg; i++) {
           Float_t ztmp = z[i]*zsign;
           if (i==0||i==5) ztmp *= convexscale[zcase];
           if (zcase==2) ztmp *= 2.5;
           if (zseg>2 && zcase!=2 && (i==1||i==4)) continue;
           mytxtru->DefineSection(j,ztmp,s[i]);
           j++;
        }

        TNode* txtrunode = new TNode(name,name,mytxtru);
        txtrunode->SetLineColor(icolor[3*zcase+xycase]);
        Float_t pos_scale = (domalformed) ? 10 : 6;
        Float_t xpos = (xycase-1)*pos_scale*unit;
        Float_t ypos = (zcase-1)*pos_scale*unit;
        txtrunode->SetPosition(xpos,ypos,0.);
     }
  }


// Some extra shapes to show the direction of "z"
  Float_t zhalf = 0.5*bigdim;
  Float_t rmax = 0.03*bigdim;
  TCONE* zcone = new TCONE("zcone","zcone","void",zhalf,0.,rmax,0.,0.);
  zcone->SetVisibility(extravis);
  TNode* zconenode = new TNode("zconenode","zconenode",zcone);
  zconenode->SetLineColor(3);

  Float_t dzstub = 2*rmax;
  TBRIK* zbrik = new TBRIK("zbrik","zbrik","void",rmax,rmax,dzstub);
  zbrik->SetVisibility(extravis);
  TNode* zbriknode = new TNode("zbriknode","zbriknode",zbrik);
  zbriknode->SetPosition(0.,0.,zhalf+dzstub);
  zbriknode->SetLineColor(3);

//  geom->ls();

  geom->Draw();

// Tweak the pad so that it displays the entire geometry undistorted
  TVirtualPad *thisPad = gPad;
  if (thisPad) {
    TView *view = thisPad->GetView();
    if (!view) return;
    Double_t min[3],max[3],center[3];
    view->GetRange(min,max);
    int i;
    // Find the boxed center
    for (i=0;i<3; i++) center[i] = 0.5*(max[i]+min[i]);
    Double_t maxSide = 0;
    // Find the largest side
    for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-center[i]);
    file://Adjust scales:
    for (i=0;i<3; i++) {
       max[i] = center[i] + maxSide;
       min[i] = center[i] - maxSide;
    }
    view->SetRange(min,max);
    thisPad->Modified();
    thisPad->Update();
  }

}
 xtruSamples.C:1
 xtruSamples.C:2
 xtruSamples.C:3
 xtruSamples.C:4
 xtruSamples.C:5
 xtruSamples.C:6
 xtruSamples.C:7
 xtruSamples.C:8
 xtruSamples.C:9
 xtruSamples.C:10
 xtruSamples.C:11
 xtruSamples.C:12
 xtruSamples.C:13
 xtruSamples.C:14
 xtruSamples.C:15
 xtruSamples.C:16
 xtruSamples.C:17
 xtruSamples.C:18
 xtruSamples.C:19
 xtruSamples.C:20
 xtruSamples.C:21
 xtruSamples.C:22
 xtruSamples.C:23
 xtruSamples.C:24
 xtruSamples.C:25
 xtruSamples.C:26
 xtruSamples.C:27
 xtruSamples.C:28
 xtruSamples.C:29
 xtruSamples.C:30
 xtruSamples.C:31
 xtruSamples.C:32
 xtruSamples.C:33
 xtruSamples.C:34
 xtruSamples.C:35
 xtruSamples.C:36
 xtruSamples.C:37
 xtruSamples.C:38
 xtruSamples.C:39
 xtruSamples.C:40
 xtruSamples.C:41
 xtruSamples.C:42
 xtruSamples.C:43
 xtruSamples.C:44
 xtruSamples.C:45
 xtruSamples.C:46
 xtruSamples.C:47
 xtruSamples.C:48
 xtruSamples.C:49
 xtruSamples.C:50
 xtruSamples.C:51
 xtruSamples.C:52
 xtruSamples.C:53
 xtruSamples.C:54
 xtruSamples.C:55
 xtruSamples.C:56
 xtruSamples.C:57
 xtruSamples.C:58
 xtruSamples.C:59
 xtruSamples.C:60
 xtruSamples.C:61
 xtruSamples.C:62
 xtruSamples.C:63
 xtruSamples.C:64
 xtruSamples.C:65
 xtruSamples.C:66
 xtruSamples.C:67
 xtruSamples.C:68
 xtruSamples.C:69
 xtruSamples.C:70
 xtruSamples.C:71
 xtruSamples.C:72
 xtruSamples.C:73
 xtruSamples.C:74
 xtruSamples.C:75
 xtruSamples.C:76
 xtruSamples.C:77
 xtruSamples.C:78
 xtruSamples.C:79
 xtruSamples.C:80
 xtruSamples.C:81
 xtruSamples.C:82
 xtruSamples.C:83
 xtruSamples.C:84
 xtruSamples.C:85
 xtruSamples.C:86
 xtruSamples.C:87
 xtruSamples.C:88
 xtruSamples.C:89
 xtruSamples.C:90
 xtruSamples.C:91
 xtruSamples.C:92
 xtruSamples.C:93
 xtruSamples.C:94
 xtruSamples.C:95
 xtruSamples.C:96
 xtruSamples.C:97
 xtruSamples.C:98
 xtruSamples.C:99
 xtruSamples.C:100
 xtruSamples.C:101
 xtruSamples.C:102
 xtruSamples.C:103
 xtruSamples.C:104
 xtruSamples.C:105
 xtruSamples.C:106
 xtruSamples.C:107
 xtruSamples.C:108
 xtruSamples.C:109
 xtruSamples.C:110
 xtruSamples.C:111
 xtruSamples.C:112
 xtruSamples.C:113
 xtruSamples.C:114
 xtruSamples.C:115
 xtruSamples.C:116
 xtruSamples.C:117
 xtruSamples.C:118
 xtruSamples.C:119
 xtruSamples.C:120
 xtruSamples.C:121
 xtruSamples.C:122
 xtruSamples.C:123
 xtruSamples.C:124
 xtruSamples.C:125
 xtruSamples.C:126
 xtruSamples.C:127
 xtruSamples.C:128
 xtruSamples.C:129
 xtruSamples.C:130
 xtruSamples.C:131
 xtruSamples.C:132
 xtruSamples.C:133
 xtruSamples.C:134
 xtruSamples.C:135
 xtruSamples.C:136
 xtruSamples.C:137
 xtruSamples.C:138
 xtruSamples.C:139
 xtruSamples.C:140