22using namespace::ROOT::Experimental;
51REveBoxSet::REveBoxSet(
const char*
n,
const char* t) :
77 case kBT_Undef:
return 0;
79 case kBT_AABox:
return sizeof(
BAABox_t);
81 case kBT_Cone:
return sizeof(
BCone_t);
83 case kBT_Hex:
return sizeof(
BHex_t);
84 default:
throw(eH +
"unexpected atom type.");
96 fValueIsColor = valIsCol;
97 fDefaultValue = valIsCol ? 0 :
kMinInt;
100 fPlex.Reset(SizeofAtom(fBoxType), chunkSize);
107void REveBoxSet::Reset()
111 fPlex.Reset(SizeofAtom(fBoxType),
TMath::Max(fPlex.N(), 64));
122 if (fBoxType != kBT_FreeBox)
123 throw(eH +
"expect free box-type.");
126 memcpy(
b->fVertices, verts,
sizeof(
b->fVertices));
127 REveShape::CheckAndFixBoxOrientationFv(
b->fVertices);
139 if (fBoxType != kBT_AABox)
140 throw(eH +
"expect axis-aligned box-type.");
155 if (fBoxType != kBT_AABoxFixedDim)
156 throw(eH +
"expect axis-aligned fixed-dimension box-type.");
170 if (fBoxType != kBT_Cone)
171 throw(eH +
"expect cone box-type.");
186 static const REveException eH(
"REveBoxSet::AddEllipticCone ");
188 if (fBoxType != kBT_EllipticCone)
189 throw(eH +
"expect elliptic-cone box-type.");
206 static const REveException eH(
"REveBoxSet::AddEllipticCone ");
208 if (fBoxType != kBT_Hex)
209 throw(eH +
"expect hex box-type.");
222void REveBoxSet::ComputeBBox()
229 Int_t n = fFrame->GetFrameSize() / 3;
230 Float_t *bbps = fFrame->GetFramePoints();
231 for (
int i=0; i<
n; ++i, bbps+=3)
232 BBoxCheckPoint(bbps);
236 if(fPlex.Size() == 0)
252 for (
Int_t i = 0; i < 8; ++i)
253 BBoxCheckPoint(
b.fVertices[i]);
262 BBoxCheckPoint(
b.fA,
b.fB,
b.fC);
263 BBoxCheckPoint(
b.fA +
b.fW,
b.fB +
b.fH ,
b.fC +
b.fD);
268 case kBT_AABoxFixedDim:
272 BBoxCheckPoint(
b.fA,
b.fB,
b.fC);
273 BBoxCheckPoint(
b.fA + fDefWidth,
b.fB + fDefHeight ,
b.fC + fDefDepth);
280 Float_t mag2=0, mag2Max=0, rMax=0;
283 BBoxCheckPoint(
b.fPos.fX,
b.fPos.fY,
b.fPos.fZ);
284 mag2 =
b.fDir.Mag2();
285 if (mag2>mag2Max) mag2Max=mag2;
286 if (
b.fR>rMax) rMax=
b.fR;
289 fBBox[0] -= off;fBBox[2] -= off;fBBox[4] -= off;
290 fBBox[1] += off;fBBox[3] += off;fBBox[5] += off;
294 case kBT_EllipticCone:
296 Float_t mag2=0, mag2Max=0, rMax=0;
299 BBoxCheckPoint(
b.fPos.fX,
b.fPos.fY,
b.fPos.fZ);
300 mag2 =
b.fDir.Mag2();
301 if (mag2>mag2Max) mag2Max=mag2;
302 if (
b.fR > rMax) rMax =
b.fR;
303 if (
b.fR2 > rMax) rMax =
b.fR2;
306 fBBox[0] -= off;fBBox[2] -= off;fBBox[4] -= off;
307 fBBox[1] += off;fBBox[3] += off;fBBox[5] += off;
315 BBoxCheckPoint(
h.fPos.fX -
h.fR,
h.fPos.fY -
h.fR,
h.fPos.fZ);
316 BBoxCheckPoint(
h.fPos.fX +
h.fR,
h.fPos.fY -
h.fR,
h.fPos.fZ);
317 BBoxCheckPoint(
h.fPos.fX +
h.fR,
h.fPos.fY +
h.fR,
h.fPos.fZ);
318 BBoxCheckPoint(
h.fPos.fX -
h.fR,
h.fPos.fY +
h.fR,
h.fPos.fZ);
319 BBoxCheckPoint(
h.fPos.fX -
h.fR,
h.fPos.fY -
h.fR,
h.fPos.fZ +
h.fDepth);
320 BBoxCheckPoint(
h.fPos.fX +
h.fR,
h.fPos.fY -
h.fR,
h.fPos.fZ +
h.fDepth);
321 BBoxCheckPoint(
h.fPos.fX +
h.fR,
h.fPos.fY +
h.fR,
h.fPos.fZ +
h.fDepth);
322 BBoxCheckPoint(
h.fPos.fX -
h.fR,
h.fPos.fY +
h.fR,
h.fPos.fZ +
h.fDepth);
329 throw(eH +
"unsupported box-type.");
340 Int_t ret = REveDigitSet::WriteCoreJson(j, rnr_offset);
341 j[
"boxType"] =
int(fBoxType);
343 printf(
" WriteCoreJsonMAIN color %d \n", GetMainColor());
351void REveBoxSet::BuildRenderData()
353 fRenderData = std::make_unique<REveRenderData>(
"makeBoxSet", fPlex.Size()*24, 0, fPlex.Size());
357 case REveBoxSet::kBT_FreeBox:
364 for (
int c =0;
c < 8;
c++) {
365 for (
int j =0; j < 3; j++)
366 fRenderData->PushV(
b.fVertices[
c][j]);
371 case REveBoxSet::kBT_AABox:
378 fRenderData->PushV(
b.fA,
b.fB,
b.fC);
380 fRenderData->PushV(
b.fW,
b.fH,
b.fD);
385 assert(
false &&
"REveBoxSet::BuildRenderData only kBT_FreeBox type supported");
391 if (fSingleColor ==
false)
400 fRenderData->PushI(
int(
b.fValue));
402 else if (fSingleColor ==
false)
405 Bool_t visible = fPalette->ColorFromValue(
b.fValue, fDefaultValue,
c);
416 value += 256*256*256*
c[3];
419 fRenderData->PushI(value);
430 Reset(kBT_AABox,
kTRUE, nboxes);
432 const Float_t origin = 10, size = 2;
434 for(
Int_t i=0; i<nboxes; ++i)
436 AddBox(origin * rnd.
Uniform(-1, 1),
REveException Exception-type thrown by Eve classes.
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)
Short_t Max(Short_t a, Short_t b)
Double_t Sqrt(Double_t x)
basic_json<> json
default JSON class
Bool_t next()
Go to next atom.