Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
boxset_cones.C File Reference

Detailed Description

Demonstrates usage of 'cone' mode in TEveBoxSet class.

using namespace ROOT::Experimental;
REveBoxSet *elliptic_boxset_cones(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100)
{
using namespace TMath;
auto lines = new REveStraightLineSet("StraightLines");
lines->SetLineColor(kYellow);
lines->SetLineWidth(2);
TRandom r(0);
auto cones = new REveBoxSet("EllipticConeSet");
bool valIsColor = true;
cones->Reset(REveBoxSet::kBT_InstancedScaledRotated, valIsColor, 64);
cones->SetPickable(kTRUE);
Float_t a = 40; // max distance between cones
Float_t theta, phi, height, rad;
for (Int_t i = 0; i < num; ++i) {
theta = r.Uniform(0, TMath::Pi());
phi = r.Uniform(-TMath::Pi(), TMath::Pi());
height = r.Uniform(5, 15);
rad = r.Uniform(3, 5);
dir.Set(Cos(phi) * Cos(theta), Sin(phi) * Cos(theta), Sin(theta));
dir *= height;
pos.Set(r.Uniform(-a, a), r.Uniform(-a, a), r.Uniform(-a, a));
cones->AddEllipticCone(pos, dir, rad, 0.5 * rad, r.Uniform(0, 360));
if (i % 2 == 0)
cones->DigitColor(kRed);
else
cones->DigitColor(kGreen);
// draw axis line 30% longer than cone height
REveVector end = pos + dir * 1.3f;
lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
}
// by default cone cap not drawn
if (r.Integer(2) > 0)
cones->SetDrawConeCap(kTRUE);
cones->RefitPlex();
REveTrans &t = cones->RefMainTrans();
t.SetPos(x, y, z);
cones->SetPickable(1);
cones->SetAlwaysSecSelect(1);
eveMng->GetEventScene()->AddElement(cones);
eveMng->GetEventScene()->AddElement(lines);
REveViewer *v = (REveViewer *)eveMng->GetViewers()->FirstChild();
v->SetAxesType(REveViewer::kAxesOrigin);
eveMng->Show();
return cones;
}
REveBoxSet *boxset_cones(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100)
{
using namespace TMath;
lines->SetLineColor(kYellow);
lines->SetLineWidth(2);
auto pal = new REveRGBAPalette(0, 500);
auto cones = new REveBoxSet("ConeSet");
cones->SetPalette(pal);
bool valIsColor = false;
cones->Reset(REveBoxSet::kBT_InstancedScaledRotated, valIsColor, 64);
Float_t a = 40; // max distance between cones
Float_t theta, phi, height, rad;
for (Int_t i = 0; i < num; ++i) {
theta = r.Uniform(0, TMath::Pi());
phi = r.Uniform(-TMath::Pi(), TMath::Pi());
height = r.Uniform(5, 15);
rad = r.Uniform(3, 5);
dir.Set(Cos(phi) * Cos(theta), Sin(phi) * Cos(theta), Sin(theta));
dir *= height;
pos.Set(r.Uniform(-a, a), r.Uniform(-a, a), r.Uniform(-a, a));
cones->AddCone(pos, dir, rad);
cones->DigitValue(r.Uniform(0, 500));
// draw axis line 30% longer than cone height
REveVector end = pos + dir * 1.3f;
lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
}
cones->SetPickable(1);
cones->SetAlwaysSecSelect(1);
// by default cone cap not drawn
if (r.Integer(2) > 0)
cones->SetDrawConeCap(kTRUE);
cones->RefitPlex();
REveTrans &t = cones->RefMainTrans();
t.SetPos(x, y, z);
eveMng->GetEventScene()->AddElement(cones);
eveMng->GetEventScene()->AddElement(lines);
eveMng->GetEventScene()->AddElement(pal);
eveMng->Show();
return cones;
}
ROOT::R::TRInterface & r
Definition Object.C:4
#define a(i)
Definition RSha256.hxx:99
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kRed
Definition Rtypes.h:67
@ kGreen
Definition Rtypes.h:67
@ kYellow
Definition Rtypes.h:67
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
REveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Eve representation of a GL view.
static REveManager * Create()
If global REveManager* REX::gEve is not set initialize it.
REveStraightLineSet Set of straight lines with optional markers along the lines.
void Set(const Float_t *v)
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
ROOT::Experimental::REveManager * eveMng
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Namespace for ROOT features in testing.
Definition TROOT.h:100
REveVectorT< Float_t > REveVector
TMath.
Definition TMathBase.h:35
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:605
constexpr Double_t Pi()
Definition TMath.h:40
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:599
Author
Alja Mrak-Tadel

Definition in file boxset_cones.C.