18 using namespace ROOT::Experimental;
 
   19 namespace REX = ROOT::Experimental;
 
   36 REveShape::REveShape(
const std::string &n, 
const std::string &t) :
 
   42    fHighlightFrame(kFALSE),
 
   45    fCanEditMainColor        = kTRUE;
 
   46    fCanEditMainTransparency = kTRUE;
 
   47    SetMainColorPtr(&fFillColor);
 
   53 REveShape::~REveShape()
 
   60 Int_t REveShape::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
 
   62    Int_t ret = REveElement::WriteCoreJson(j, rnr_offset);
 
   64    j[
"fFillColor"] = fFillColor;
 
   65    j[
"fLineColor"] = fLineColor;
 
   66    j[
"fLineWidth"] = fLineWidth;
 
   67    j[
"fDrawFrame"] = fDrawFrame;
 
   77 void REveShape::SetMainColor(Color_t color)
 
   79    if (fFillColor == fLineColor) {
 
   83    REveElement::SetMainColor(color);
 
   89 void REveShape::CopyVizParams(
const REveElement* el)
 
   91    const REveShape* m = 
dynamic_cast<const REveShape*
>(el);
 
   94       fFillColor = m->fFillColor;
 
   95       fLineColor = m->fLineColor;
 
   96       fLineWidth = m->fLineWidth;
 
   97       fDrawFrame      = m->fDrawFrame;
 
   98       fHighlightFrame = m->fHighlightFrame;
 
   99       fMiniFrame      = m->fMiniFrame;
 
  102    REveElement::CopyVizParams(el);
 
  108 void REveShape::WriteVizParams(std::ostream& out, 
const TString& var)
 
  110    REveElement::WriteVizParams(out, var);
 
  112    TString t = 
"   " + var + 
"->";
 
  113    out << t << 
"SetFillColor(" << fFillColor << 
");\n";
 
  114    out << t << 
"SetLineColor(" << fLineColor << 
");\n";
 
  115    out << t << 
"SetLineWidth(" << fLineWidth << 
");\n";
 
  116    out << t << 
"SetDrawFrame("      << ToString(fDrawFrame) << 
");\n";
 
  117    out << t << 
"SetHighlightFrame(" << ToString(fHighlightFrame) << 
");\n";
 
  128 Int_t REveShape::FindConvexHull(
const vVector2_t& pin, vVector2_t& pout, REveElement* caller)
 
  130    Int_t N = pin.size();
 
  134    for (Int_t i = 1; i < N; ++i)
 
  136       if (pin[i].fY < pin[min_point].fY || (pin[i].fY == pin[min_point].fY && pin[i].fX < pin[min_point].fX))
 
  141    std::vector<Float_t> angles(N);
 
  142    for (Int_t i = 0; i < N; ++i)
 
  144       angles[i] = (pin[i] - pin[min_point]).Phi();
 
  146    std::vector<Int_t> idcs(N);
 
  147    TMath::Sort(N, &angles[0], &idcs[0], kFALSE);
 
  153       std::vector<Int_t> new_idcs;
 
  154       new_idcs.push_back(idcs[0]);
 
  155       auto a = idcs.begin(); ++a;
 
  157       while (b != idcs.end())
 
  159          if (TMath::Abs(angles[*a] - angles[*b]) < 1e-5f)
 
  161             if (pin[idcs[0]].SquareDistance(pin[*a]) < pin[idcs[0]].SquareDistance(pin[*b]))
 
  166             new_idcs.push_back(*a);
 
  171       new_idcs.push_back(*a);
 
  178    std::vector<Int_t> hull;
 
  181       hull.push_back(idcs[0]);
 
  182       hull.push_back(idcs[1]);
 
  183       hull.push_back(idcs[2]);
 
  188             Int_t n = hull.size() - 1;
 
  189             if ((pin[hull[n]] - pin[hull[n-1]]).Cross(pin[idcs[i]] - pin[hull[n]]) > 0)
 
  191                hull.push_back(idcs[i]);
 
  203       ::Warning(
"REveShape::FindConvexHull()", 
"Polygon reduced to %d points. for '%s'.",
 
  204               N, caller ? caller->GetCName() : 
"unknown");
 
  210    Int_t Nold = pout.size();
 
  211    pout.resize(Nold + N);
 
  212    for (Int_t i = 0; i < N; ++i)
 
  214       pout[Nold + i] = pin[hull[i]];
 
  232 Bool_t REveShape::IsBoxOrientationConsistentEv(
const REveVector box[8])
 
  234    REveVector f1 = box[1] - box[0];
 
  235    REveVector f2 = box[3] - box[0];
 
  236    REveVector up = box[4] - box[0];
 
  238    return up.Dot(f1.Cross(f2)) < 0;
 
  246 Bool_t REveShape::IsBoxOrientationConsistentFv(
const Float_t box[8][3])
 
  248    REveVector b0(box[0]);
 
  249    REveVector f1(box[1]); f1 -= b0;
 
  250    REveVector f2(box[3]); f2 -= b0;
 
  251    REveVector up(box[4]); up -= b0;
 
  253    return up.Dot(f1.Cross(f2)) < 0;
 
  259 void REveShape::CheckAndFixBoxOrientationEv(REveVector box[8])
 
  261    if ( ! IsBoxOrientationConsistentEv(box))
 
  263       std::swap(box[1], box[3]);
 
  264       std::swap(box[5], box[7]);
 
  271 void REveShape::CheckAndFixBoxOrientationFv(Float_t box[8][3])
 
  273    if ( ! IsBoxOrientationConsistentFv(box))
 
  275       std::swap(box[1][0], box[3][0]);
 
  276       std::swap(box[1][1], box[3][1]);
 
  277       std::swap(box[1][2], box[3][2]);
 
  278       std::swap(box[5][0], box[7][0]);
 
  279       std::swap(box[5][1], box[7][1]);
 
  280       std::swap(box[5][2], box[7][2]);