25#include <nlohmann/json.hpp>
27using namespace::ROOT::Experimental;
80int TexelsPerDigit(REveBoxSet::EBoxType_e bt)
83 case REveBoxSet::kBT_InstancedScaled:
return 2;
84 case REveBoxSet::kBT_InstancedScaledRotated:
return 4;
93REveBoxSet::REveBoxSet(
const char*
n,
const char* t) :
121 default:
throw(eH +
"unexpected atom type.");
176 throw(eH +
"expect box-type kBT_Vertices.");
179 memcpy(
b->fVertices, verts,
sizeof(
b->fVertices));
190 static const REveException eH(
"REveBoxSet::AddInstanceScaled ");
193 throw(eH +
"expect box-type kBT_InstancedScaled.");
224 throw(eH +
"expect box-type kBT_Instanced.");
248 static const REveException eH(
"REveBoxSet::AddInstanceMat4 ");
250 throw(eH +
"expect box-type kBT_InstancedScaledRotated.");
253 memcpy(
b->fMat, arr,
sizeof(
b->fMat));
263 using namespace TMath;
265 throw(eH +
"expect box-type kBT_InstancedScaledRotated.");
270 float phi = ATan2(dir.
fY, dir.
fX);
271 float theta = ATan (dir.
fZ / Sqrt(dir.
fX*dir.
fX + dir.
fY*dir.
fY));
273 theta = Pi()/2 -theta;
280 for(
Int_t i=0; i<16; ++i)
281 cone->
fMat[i] = t[i];
291 static const REveException eH(
"REveBoxSet::AddEllipticCone ");
292 using namespace TMath;
294 throw(eH +
"expect box-type kBT_InstancedScaledRotated.");
298 float phi = ATan2(dir.
fY, dir.
fX);
299 float theta = ATan (dir.
fZ / Sqrt(dir.
fX*dir.
fX + dir.
fY*dir.
fY));
301 theta = Pi()/2 -theta;
309 for(
Int_t i=0; i<16; ++i)
310 cone->
fMat[i] = t[i];
323 throw(eH +
"expect box-type kBT_InstancedScaledRotated.");
332 for(
Int_t i=0; i<16; ++i)
348 for (
int i=0; i<
n; ++i, bbps+=3)
369 for (
Int_t i = 0; i < 8; ++i)
393 for (
Int_t k = 0; k < 3; ++k)
394 h[k] = std::abs(
a[k]) + std::abs(
a[4 + k]) + std::abs(
a[8 + k]);
401 throw eH +
"unsupported box-type.";
421 std::string instanceFlag;
427 default:
R__LOG_ERROR(
REveLog()) <<
"REveBoxSet::WriteCoreJson Unhandled instancing type.";
430 j[
"instanceFlag"] = instanceFlag;
466 vertices ?
fRenderData->NewEntry(
"pos", RD::EType::kF32, 3).Role(RD::ERole::kVertex).Reserve(8 * n_visible)
467 :
fRenderData->NewEntry(
"inst", RD::EType::kF32, 4 * TexelsPerDigit(
fBoxType)).Reserve(n_visible);
468 RD::Entry *col =
nullptr;
470 col = &
fRenderData->NewEntry(
"col", RD::EType::kU8, 4).Role(RD::ERole::kInstance).Reserve(n_visible);
482 std::memcpy(
c, &
b->fValue, 4);
485 col->PushRGBA(
c[0],
c[1],
c[2],
c[3]);
492 shape.AsTexture(RD::ETexFormat::kRGBA32F, TexelsPerDigit(
fBoxType));
503 return (
c[0] << 16) + (
c[1] << 8) +
c[2];
508 return (
c[0] << 16) + (
c[1] << 8) +
c[2];
515 return (
c[0] << 16) + (
c[1] << 8) +
c[2];
522 auto pc = (
float *) &
c;
536 entry.
Push(&
b.fVertices[0][0], 24);
555 entry.
Push((
const float *)
a, 12);
559 default: assert(
false &&
"REveBoxSet::WriteShapeData unsupported box type");
572 for(
Int_t i=0; i<nboxes; ++i)
599bool REveBoxSet::SetDigitShape(const std::vector<float>& vrtBuff, const std::vector<int>& idxBuff)
#define R__LOG_ERROR(...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
float Float_t
Float 4 bytes (float)
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.
@ kBT_InstancedScaledRotated
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 ComputeBBox() override
Fill the bounding box (virtual from REveElement).
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...
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void WriteShapeData(REveDigitSet::DigitBase_t &digit, REveRenderData::Entry &entry)
Append the shape of digit to entry, its render data entry: pos for kBT_Vertices and inst for the inst...
void BuildRenderData() override
Write the render data entries, see the class description: inst for the instanced types,...
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 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).
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)
static Int_t SizeofAtom(EBoxType_e bt)
Return size of data-structure describing a box of type bt.
bool Instanced()
Every box type except kBT_Vertices is drawn by instancing.
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).
void Reset(Int_t atom_size, Int_t chunk_size)
Empty the container and reset it with given atom and chunk sizes.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
DigitBase_t * NewDigit()
Protected method called whenever a new digit is added.
bool IsDigitVisible(const DigitBase_t *) const
Utility function for maping digit idx with visible shape idx.
REveRGBAPalette * fPalette
void ReleaseIds()
Protected method.
void DigitValue(Int_t value)
Set signal value for the last digit added.
void BBoxCheckPoint(const REveVector &v)
std::unique_ptr< REveRenderData > fRenderData
! Render data entries for the client's maker, see REveRenderData.
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Set the bounding box to a cube of half-side epsilon at (x, y, z); with the defaults,...
void BBoxInit()
Start filling the bounding box with BBoxCheckPoint(): min at +infinity, max at -infinity,...
void BBoxCheckBox(const REveVector &c, const REveVector &h)
Grow the box to hold the axis-aligned box with centre c and half sizes h.
virtual Color_t GetMainColor() const
REveException Exception-type thrown by Eve classes.
Int_t GetFrameSize() const
Float_t * GetFramePoints() const
const UChar_t * ColorFromValue(Int_t val) const
Entry & Push(T v)
Append one element; T must be the entry's type.
Render data of an element: a client maker name and a list of tagged entries, each a typed array with ...
static void CheckAndFixBoxOrientationFv(Float_t box[8][3])
Make sure box orientation is consistent with standard arrangement.
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE)
Fill col with RGBA values corresponding to index ci.
This is the base class for the ROOT Random number generators.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
ROOT::RLogChannel & REveLog()
Log channel for Eve diagnostics.
REveVectorT< Float_t > REveVector
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Bool_t next()
Go to next atom.