Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:38

0001 // @(#)root/eve:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_REveBoxSet
0013 #define ROOT_REveBoxSet
0014 
0015 #include "ROOT/REveDigitSet.hxx"
0016 #include "ROOT/REveVector.hxx"
0017 
0018 class TGeoMatrix;
0019 class TRandom;
0020 
0021 namespace ROOT {
0022 namespace Experimental {
0023 class REveBoxSet: public REveDigitSet
0024 {
0025    friend class REveBoxSetGL;
0026 
0027    REveBoxSet(const REveBoxSet&) = delete;
0028    REveBoxSet& operator=(const REveBoxSet&) = delete;
0029 
0030 public:
0031    enum EBoxType_e {
0032       kBT_Undef,           // unknown-ignored
0033       kBT_FreeBox,         // arbitrary box: specify 8*(x,y,z) box corners
0034       kBT_Instanced,              // axis-aligned digit w/ fixed dimensions: specify (x,y,z)
0035       kBT_InstancedScaled,        // axis-aligned digit: specify (x,y,z) and (w, h, d)
0036       kBT_InstancedScaledRotated  // generic Mat4 transformation
0037    };
0038 
0039    enum EShape_e {
0040       kBox,
0041       kHex,
0042       kCone,
0043       kConeCapped
0044    };
0045 
0046    struct BFreeBox_t       : public DigitBase_t { Float_t fVertices[8][3]; };
0047 
0048    struct Instanced_t      : public DigitBase_t   {  Float_t fX, fY, fZ; }; // save only position == INSTANCED_T
0049 
0050    struct InstancedScaled_t   : public Instanced_t   { Float_t fW, fH, fD; }; // scaled box INSTANCED_SCALED_T
0051 
0052    struct InstancedScaledRotated_t  : public DigitBase_t   { Float_t fMat[16]; }; // INSTANCED_SCALEDROTATED
0053 
0054  // ++ TODO add rotated
0055 
0056 protected:
0057    EBoxType_e        fBoxType;      // Type of rendered box.
0058    EShape_e          fShapeType{kBox};
0059 
0060    Float_t           fDefWidth  {1};     // Breadth assigned to first coordinate  (A).
0061    Float_t           fDefHeight {1};    // Breadth assigned to second coordinate (B).
0062    Float_t           fDefDepth  {1};     // Breadth assigned to third coordinate  (C).
0063 
0064    Int_t             fBoxSkip;      // Number of boxes to skip for each drawn box during scene rotation.
0065 
0066    Bool_t            fDrawConeCap{false};
0067 
0068    int                     fTexX{0}, fTexY{0};
0069    static Int_t SizeofAtom(EBoxType_e bt);
0070    void WriteShapeData(REveDigitSet::DigitBase_t &digit);
0071    unsigned int GetColorFromDigit(REveDigitSet::DigitBase_t &digit);
0072    float GetColorFromDigitAsFloat(REveDigitSet::DigitBase_t &digit);
0073 
0074 public:
0075    REveBoxSet(const char* n="REveBoxSet", const char* t="");
0076    ~REveBoxSet() override {}
0077 
0078    void Reset(EBoxType_e boxType, Bool_t valIsCol, Int_t chunkSize);
0079    void Reset();
0080 
0081    void AddFreeBox(const Float_t* verts);
0082    void AddInstanceScaled(Float_t a, Float_t b, Float_t c, Float_t w, Float_t h, Float_t d);
0083    void AddInstance(Float_t a, Float_t b, Float_t c);
0084    void AddInstanceMat4(const Float_t* mat4);
0085 
0086    void AddCone(const REveVector& pos, const REveVector& dir, Float_t r);
0087    void AddEllipticCone(const REveVector& pos, const REveVector& dir, Float_t r, Float_t r2, Float_t angle=0);
0088 
0089    void AddHex(const REveVector& pos, Float_t r, Float_t angle, Float_t depth);
0090    void SetShape(EShape_e x){fShapeType = x;}
0091 
0092    void ComputeBBox() override;
0093 
0094    void Test(Int_t nboxes);
0095 
0096    Float_t GetDefWidth()  const { return fDefWidth;  }
0097    Float_t GetDefHeight() const { return fDefHeight; }
0098    Float_t GetDefDepth()  const { return fDefDepth;  }
0099    Bool_t  GetDrawConeCap() const { return fDrawConeCap;  }
0100 
0101    void SetDefWidth(Float_t v)  { fDefWidth  = v ; }
0102    void SetDefHeight(Float_t v) { fDefHeight = v ; }
0103    void SetDefDepth(Float_t v)  { fDefDepth  = v ; }
0104    void SetDrawConeCap(Bool_t x) { fDrawConeCap=x; StampObjProps(); }
0105 
0106    Int_t GetBoxSkip()   const { return fBoxSkip; }
0107    void  SetBoxSkip(Int_t bs) { fBoxSkip = bs; }
0108 
0109 
0110    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0111    void  BuildRenderData() override;
0112 
0113    bool Instanced();
0114 };
0115 
0116 } // namespace Experimental
0117 } // namespace ROOT
0118 #endif