Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveBoxSet.hxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_REveBoxSet
13#define ROOT_REveBoxSet
14
15#include "ROOT/REveDigitSet.hxx"
16#include "ROOT/REveVector.hxx"
17
18class TGeoMatrix;
19class TRandom;
20
21namespace ROOT {
22namespace Experimental {
24{
25 friend class REveBoxSetGL;
26
27 REveBoxSet(const REveBoxSet&) = delete;
28 REveBoxSet& operator=(const REveBoxSet&) = delete;
29
30public:
32 kBT_Undef, // unknown-ignored
33 kBT_Vertices, // arbitrary box: specify its 8 vertices, 8*(x,y,z)
34 kBT_FreeBox = kBT_Vertices, // the old name of kBT_Vertices
35 kBT_Instanced, // axis-aligned box of the default size, see SetDefWidth(): specify its centre
36 kBT_InstancedScaled, // axis-aligned box: specify its centre and half size
37 kBT_InstancedScaledRotated // any transformation of the instance shape: specify its matrix
38 };
39
40 /// The shape every instance of a kBT_Instanced* box set draws.
47
48 struct Vertices_t : public DigitBase_t {
50 }; // the 8 vertices
51 struct Instanced_t : public DigitBase_t {
53 }; // centre
56 }; // centre and half size
59 }; // column-major matrix
60
61 using BFreeBox_t = Vertices_t; // the old name of Vertices_t
62
63protected:
64 EBoxType_e fBoxType; // Type of rendered box.
65 EInstanceShape_e fInstanceShape{kIS_Box}; // Shape of the instances of the kBT_Instanced* types.
66
67 Float_t fDefHalfWidth{0.5}; // Half size along x of a kBT_Instanced box.
68 Float_t fDefHalfHeight{0.5}; // Half size along y of a kBT_Instanced box.
69 Float_t fDefHalfDepth{0.5}; // Half size along z of a kBT_Instanced box.
70
71 Int_t fBoxSkip; // Number of boxes to skip for each drawn box during scene rotation.
72
73 Bool_t fDrawConeCap{false}; // Close the base of a cone.
74
75 int fTexX{0}, fTexY{0}; // Size of the instance-data texture.
76
77 static Int_t SizeofAtom(EBoxType_e bt);
78 void InstanceHalfSize(const DigitBase_t &digit, Float_t half[3]) const;
79 void WriteShapeData(REveDigitSet::DigitBase_t &digit);
80 unsigned int GetColorFromDigit(REveDigitSet::DigitBase_t &digit);
81 float GetColorFromDigitAsFloat(REveDigitSet::DigitBase_t &digit);
82
83public:
84 REveBoxSet(const char* n="REveBoxSet", const char* t="");
85 ~REveBoxSet() override {}
86
87 void Reset(EBoxType_e boxType, Bool_t valIsCol, Int_t chunkSize);
88 void Reset();
89
90 void AddVertices(const Float_t *verts);
91 void AddFreeBox(const Float_t *verts) { AddVertices(verts); } // the old name of AddVertices()
92 void AddBox(const Float_t *verts) { AddVertices(verts); } // the TEveBoxSet name of AddVertices()
93 void AddInstanceScaled(Float_t cx, Float_t cy, Float_t cz, Float_t hw, Float_t hh, Float_t hd);
95 void AddInstance(Float_t cx, Float_t cy, Float_t cz);
97 void AddInstanceMat4(const Float_t* mat4);
98
99 void AddCone(const REveVector& pos, const REveVector& dir, Float_t r);
100 void AddEllipticCone(const REveVector& pos, const REveVector& dir, Float_t r, Float_t r2, Float_t angle=0);
101
102 void AddHex(const REveVector& pos, Float_t r, Float_t angle, Float_t depth);
103
106
107 void ComputeBBox() override;
108
109 void Test(Int_t nboxes);
110
111 // The size of a kBT_Instanced box, full or half.
112 Float_t GetDefWidth() const { return 2 * fDefHalfWidth; }
113 Float_t GetDefHeight() const { return 2 * fDefHalfHeight; }
114 Float_t GetDefDepth() const { return 2 * fDefHalfDepth; }
118
119 void SetDefWidth(Float_t v) { fDefHalfWidth = 0.5f * v; }
121 void SetDefDepth(Float_t v) { fDefHalfDepth = 0.5f * v; }
125
128 {
129 fDrawConeCap = x;
131 }
132
133 Int_t GetBoxSkip() const { return fBoxSkip; }
134 void SetBoxSkip(Int_t bs) { fBoxSkip = bs; }
135
136 Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
137 void BuildRenderData() override;
138
139 bool Instanced();
140};
141
142} // namespace Experimental
143} // namespace ROOT
144#endif
#define d(i)
Definition RSha256.hxx:102
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint angle
void AddInstanceMat4(const Float_t *mat4)
Create shape with arbitrary transformtaion.
void AddEllipticCone(const REveVector &pos, const REveVector &dir, Float_t r, Float_t r2, Float_t angle=0)
Create a cone with apex at pos, axis dir and radius r.
void AddFreeBox(const Float_t *verts)
EInstanceShape_e GetInstanceShape() const
void ComputeBBox() override
Fill the bounding box (virtual from REveElement).
void SetInstanceShape(EInstanceShape_e s)
void AddInstanceCorner(Float_t x, Float_t y, Float_t z)
Create a new axis-aligned box with lower corner (x, y, z) and the default size, see SetDefWidth() and...
void AddBox(const Float_t *verts)
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void BuildRenderData() override
Creates 3D point array for rendering.
REveBoxSet(const REveBoxSet &)=delete
void Test(Int_t nboxes)
Fill the structure with a random set of boxes.
void AddCone(const REveVector &pos, const REveVector &dir, Float_t r)
Create a cone with apex at pos, axis dir and radius r.
void Reset()
Reset the data containers to zero size.
void InstanceHalfSize(const DigitBase_t &digit, Float_t half[3]) const
Half size of an axis-aligned instance, kBT_Instanced or kBT_InstancedScaled, as the client draws it.
EInstanceShape_e fInstanceShape
void Reset(EBoxType_e boxType, Bool_t valIsCol, Int_t chunkSize)
void AddVertices(const Float_t *verts)
Create a new box from a set of 8 vertices.
void AddInstanceScaled(Float_t cx, Float_t cy, Float_t cz, Float_t hw, Float_t hh, Float_t hd)
Create a new axis-aligned box with centre (cx, cy, cz) and half size (hw, hh, hd).
REveBoxSet & operator=(const REveBoxSet &)=delete
void AddHex(const REveVector &pos, Float_t r, Float_t angle, Float_t depth)
Create a hexagonal prism with center of one hexagon at pos, radius of hexagon vertices r,...
unsigned int GetColorFromDigit(REveDigitSet::DigitBase_t &digit)
Get int value for color.
float GetColorFromDigitAsFloat(REveDigitSet::DigitBase_t &digit)
void WriteShapeData(REveDigitSet::DigitBase_t &digit)
Write shape data for different cases.
EInstanceShape_e
The shape every instance of a kBT_Instanced* box set draws.
static Int_t SizeofAtom(EBoxType_e bt)
Return size of data-structure describing a box of type bt.
bool Instanced()
Use instancing in RenderCore.
void AddInstance(Float_t cx, Float_t cy, Float_t cz)
Create a new axis-aligned box with centre (cx, cy, cz) and the default size, see SetDefWidth() and Se...
void AddInstanceScaledCorner(Float_t x, Float_t y, Float_t z, Float_t w, Float_t h, Float_t d)
Create a new axis-aligned box with lower corner (x, y, z) and size (w, h, d).
Geometrical transformation package.
Definition TGeoMatrix.h:39
This is the base class for the ROOT Random number generators.
Definition TRandom.h:28
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16