00001
00002
00003
00004
00005
00006 TEveBoxSet* boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0,
00007 Int_t num=100, Bool_t register=kTRUE)
00008 {
00009 TEveManager::Create();
00010
00011 using namespace TMath;
00012
00013 TEveStraightLineSet* lines = new TEveStraightLineSet("StraightLines");
00014 lines->SetLineColor(kYellow);
00015 lines->SetLineWidth(2);
00016
00017 TRandom r(0);
00018 gStyle->SetPalette(1, 0);
00019 TEveRGBAPalette* pal = new TEveRGBAPalette(0, 500);
00020 TEveBoxSet* cones = new TEveBoxSet("ConeSet");
00021 cones->SetPalette(pal);
00022 cones->Reset(TEveBoxSet::kBT_Cone, kFALSE, 64);
00023
00024 Float_t a = 40;
00025 TEveVector dir, pos;
00026 Float_t theta, phi, height, rad;
00027 for (Int_t i=0; i<num; ++i)
00028 {
00029 theta = r.Uniform(0,TMath::Pi());
00030 phi = r.Uniform (-TMath::Pi(), TMath::Pi());
00031 height = r.Uniform(5, 15);
00032 rad = r.Uniform(3, 5);
00033 dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
00034 dir *= height;
00035 pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a));
00036
00037 cones->AddCone(pos, dir, rad);
00038 cones->DigitValue(r.Uniform(0, 500));
00039
00040
00041 TEveVector end = pos + dir*1.3;
00042 lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
00043 }
00044
00045
00046 if (r.Integer(2)>0) cones->SetDrawConeCap(kTRUE);
00047
00048 cones->RefitPlex();
00049 TEveTrans& t = cones->RefMainTrans();
00050 t.SetPos(x, y, z);
00051
00052 gEve->AddElement(cones);
00053 gEve->AddElement(lines);
00054
00055 gEve->Redraw3D(kTRUE);
00056
00057 return cones;
00058 }
00059
00060 TEveBoxSet*
00061 elliptic_boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0,
00062 Int_t num=100, Bool_t register=kTRUE)
00063 {
00064 TEveManager::Create();
00065
00066 using namespace TMath;
00067
00068 TEveManager::Create();
00069
00070 TEveStraightLineSet* lines = new TEveStraightLineSet("StraightLines");
00071 lines->SetLineColor(kYellow);
00072 lines->SetLineWidth(2);
00073
00074 TRandom r(0);
00075
00076 TEveBoxSet* cones = new TEveBoxSet("EllipticConeSet");
00077 cones->Reset(TEveBoxSet::kBT_EllipticCone, kTRUE, 64);
00078
00079 cones->SetPickable(kTRUE);
00080
00081 Float_t a = 40;
00082 TEveVector dir, pos;
00083 Float_t theta, phi, height, rad;
00084 for (Int_t i=0; i<num; ++i)
00085 {
00086 theta = r.Uniform(0,TMath::Pi());
00087 phi = r.Uniform (-TMath::Pi(), TMath::Pi());
00088 height = r.Uniform(5, 15);
00089 rad = r.Uniform(3, 5);
00090 dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
00091 dir *= height;
00092 pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a));
00093
00094 cones->AddEllipticCone(pos, dir, rad, 0.5*rad, r.Uniform(0,360));
00095 cones->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
00096 r.Uniform(20, 255), r.Uniform(20, 255));
00097
00098
00099 TEveVector end = pos + dir*1.3;
00100 lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
00101 }
00102
00103
00104 if (r.Integer(2)>0) cones->SetDrawConeCap(kTRUE);
00105
00106 cones->RefitPlex();
00107 TEveTrans& t = cones->RefMainTrans();
00108 t.SetPos(x, y, z);
00109
00110 gEve->AddElement(cones);
00111 gEve->AddElement(lines);
00112
00113 gEve->Redraw3D(kTRUE);
00114
00115 return cones;
00116 }