Logo ROOT   6.07/09
Reference Guide
triangleset.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of class TEveTriangleSet.
4 ///
5 /// \image html eve_triangleset.png
6 /// \macro_code
7 ///
8 /// \author Matevz Tadel
9 
10 #include "TCanvas.h"
11 #include "TStyle.h"
12 #include "TFile.h"
13 #include "TStopwatch.h"
14 #include "TError.h"
15 
16 class TEveTriangleSet;
17 
18 TEveTriangleSet *ts1=0, *ts2=0, *ts3=0;
19 
20 void triangleset()
21 {
23 
24  {
25  ts1 = TEveTriangleSet::ReadTrivialFile("broken_torus.tring");
26  ts1->SetName("RandomColors");
28  ts1->GenerateRandomColors();
29  ts1->SetMainColor(0);
30  TGeoHMatrix m;
31  Double_t scale[3] = { 0.5, 0.5, 0.5 };
32  m.SetScale(scale);
33  ts1->SetTransMatrix(m);
34  gEve->AddElement(ts1);
35  }
36  {
37  ts2 = TEveTriangleSet::ReadTrivialFile("broken_torus.tring");
38  ts2->SetName("SmallBlue");
39  ts2->GenerateTriangleNormals();
40  ts2->SetMainColor(4);
41  TGeoHMatrix m;
42  m.RotateY(90);
43  Double_t scale[3] = { 0.8, 0.8, 1.2 };
44  m.SetScale(scale);
45  ts2->SetTransMatrix(m);
46  gEve->AddElement(ts2);
47  }
48  {
49  ts3 = TEveTriangleSet::ReadTrivialFile("broken_torus.tring");
50  ts3->SetName("Spectrum");
51  ts3->GenerateTriangleNormals();
52  ts3->GenerateZNormalColors(50, -50, 50, kTRUE, kTRUE);
53  ts3->SetMainColor(0);
54  TGeoHMatrix m;
55  m.RotateZ(90);
56  Double_t scale[3] = { 1.3, 1.0, 1.6 };
57  m.SetScale(scale);
58  ts3->SetTransMatrix(m);
59  gEve->AddElement(ts3);
60  }
61 
63 }
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
void GenerateTriangleNormals()
Generate triangle normals via cross product of triangle edges.
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:410
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
virtual void RotateY(Double_t angle)
Rotate about Y axis with angle expressed in degrees.
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
virtual void RotateZ(Double_t angle)
Rotate about Z axis with angle expressed in degrees.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
TMarker * m
Definition: textangle.C:8
virtual void SetMainColor(Color_t color)
Set main color of the element.
double Double_t
Definition: RtypesCore.h:55
Made from a list of vertices and a list of triangles (triplets of vertex indices).
void SetScale(const Double_t *scale)
Definition: TGeoMatrix.h:450
static TEveTriangleSet * ReadTrivialFile(const char *file)
Read a simple ascii input file describing vertices and triangles.
void GenerateRandomColors()
Assign random colors to all triangles.
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTransMatrix(Double_t *carr)
Set transformation matrix from column-major array.