Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:26:22

0001 // @(#)root/base:$Id: TBuffer3D.h,v 1.00
0002 // Author: Olivier Couet   05/05/04
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, 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_TBuffer3D
0013 #define ROOT_TBuffer3D
0014 
0015 #include "TObject.h"
0016 
0017 class TBuffer3D : public TObject
0018 {
0019 private:
0020    const Int_t fType;        // Primitive type - predefined ones in TBuffer3DTypes.h
0021 
0022    UInt_t    fNbPnts;        // Number of points describing the shape
0023    UInt_t    fNbSegs;        // Number of segments describing the shape
0024    UInt_t    fNbPols;        // Number of polygons describing the shape
0025 
0026    UInt_t    fPntsCapacity;  // Current capacity of fPnts space
0027    UInt_t    fSegsCapacity;  // Current capacity of fSegs space
0028    UInt_t    fPolsCapacity;  // Current capacity of fSegs space
0029 
0030    UInt_t    fSections;      // Section validity flags
0031 
0032    void Init();
0033 
0034    // Non-copyable class
0035    TBuffer3D(const TBuffer3D &) = delete;
0036    TBuffer3D & operator=(const TBuffer3D &) = delete;
0037 
0038    //CS specific
0039    static UInt_t fgCSLevel;
0040 
0041 public:
0042    //CS specific
0043    enum EBoolOpCode {kCSUnion, kCSIntersection, kCSDifference, kCSNoOp};
0044 
0045    static UInt_t GetCSLevel();
0046    static void IncCSLevel();
0047    static UInt_t DecCSLevel();
0048 
0049    enum ESection {
0050 // clang++ <v20 (-Wshadow) complains about shadowing GuiTypes.h global variable kNone. Let's silence warning:
0051 #if defined(__clang__) && __clang_major__ < 20
0052 #pragma clang diagnostic push
0053 #pragma clang diagnostic ignored "-Wshadow"
0054 #endif
0055                    kNone            = BIT(0),
0056 #if defined(__clang__) && __clang_major__ < 20
0057 #pragma clang diagnostic pop
0058 #endif
0059                    kCore            = BIT(1),
0060                    kBoundingBox     = BIT(2),
0061                    kShapeSpecific   = BIT(3),
0062                    kRawSizes        = BIT(4),
0063                    kRaw             = BIT(5),
0064                    kAll             = kCore|kBoundingBox|kShapeSpecific|kRawSizes|kRaw
0065    };
0066 
0067    TBuffer3D(Int_t type,
0068              UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0069              UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0070              UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0071    virtual  ~TBuffer3D();
0072 
0073    // Section validity flags
0074    void   SetSectionsValid(UInt_t mask)     { fSections |= mask & kAll; }
0075    void   ClearSectionsValid();
0076    Bool_t SectionsValid(UInt_t mask) const   { return (Bool_t) (GetSections(mask) == mask); }
0077    UInt_t GetSections(UInt_t mask)   const   { return (UInt_t) (fSections & mask); }
0078 
0079    // Convenience functions
0080    void   SetLocalMasterIdentity();                  // Set fLocalMaster in kCore to identity
0081    void   SetAABoundingBox(const Double_t origin[3], // Set fBBVertex in kBoundingBox to axis aligned BB
0082                            const Double_t halfLengths[3]);
0083 
0084    // SECTION: kRawSize get/set
0085    Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity,
0086                       UInt_t reqSegs, UInt_t reqSegsCapacity,
0087                       UInt_t reqPols, UInt_t reqPolsCapacity);
0088 
0089    UInt_t NbPnts() const { return fNbPnts; }
0090    UInt_t NbSegs() const { return fNbSegs; }
0091    UInt_t NbPols() const { return fNbPols; }
0092 
0093    // SECTION: kCore
0094    Int_t  Type() const { return fType; }
0095 
0096    TObject    *fID;              // ID/object generating buffer - see TVirtualViewer3D for setting
0097    Int_t       fColor;           // Color index
0098    Short_t     fTransparency;    // Percentage transparency [0,100]
0099    Bool_t      fLocalFrame;      // True = Local, False = Master reference frame
0100    Bool_t      fReflection;      // Matrix is reflection
0101    Bool_t      fScaled;          // The shape is scaled
0102    Double_t    fLocalMaster[16]; // Local->Master Matrix - identity if master frame
0103 
0104    // SECTION: kBoundingBox
0105    //
0106    // Local frame (fLocalFrame true) axis aligned
0107    // Master frame (fLocalFrame false) oriented
0108    // Could be more compact (2 and 3 vertices respectively) and rest
0109    // calculated as needed - but not worth it
0110    //   7-------6
0111    //  /|      /|
0112    // 3-------2 |
0113    // | 4-----|-5
0114    // |/      |/
0115    // 0-------1
0116    //
0117    Double_t    fBBVertex[8][3];  // 8 vertices defining bounding box.
0118 
0119    // SECTION: kShapeSpecific - none for base class
0120 
0121    // SECTION: kRaw
0122    Double_t *fPnts;              // x0, y0, z0, x1, y1, z1, ..... ..... ....
0123    Int_t    *fSegs;              // c0, p0, q0, c1, p1, q1, ..... ..... ....
0124    Int_t    *fPols;              // c0, n0, s0, s1, ... sn, c1, n1, s0, ... sn
0125 
0126 
0127    // OUTPUT SECTION, filled by viewer as response
0128    mutable UInt_t fPhysicalID;   // Unique replica ID.
0129 
0130 
0131    ClassDefOverride(TBuffer3D,0)     // 3D primitives description
0132 };
0133 
0134 /** \class TBuffer3DSphere
0135 Sphere description class - see TBuffer3DTypes for producer classes
0136 Supports hollow and cut spheres.*/
0137 
0138 class TBuffer3DSphere : public TBuffer3D
0139 {
0140 private:
0141    // Non-copyable class
0142    TBuffer3DSphere(const TBuffer3DSphere &) = delete;
0143    TBuffer3DSphere & operator=(const TBuffer3DSphere &) = delete;
0144 
0145 public:
0146    TBuffer3DSphere(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0147                    UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0148                    UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0149 
0150    Bool_t IsSolidUncut() const;
0151 
0152    // SECTION: kShapeSpecific
0153    Double_t fRadiusInner;
0154    Double_t fRadiusOuter;
0155    Double_t fThetaMin;     // Lower theta limit (orientation?)
0156    Double_t fThetaMax;     // Higher theta limit (orientation?)
0157    Double_t fPhiMin;       // Lower phi limit (orientation?)
0158    Double_t fPhiMax;       // Higher phi limit (orientation?)
0159 };
0160 
0161 /** \class TBuffer3DTube
0162 Complete tube description class - see TBuffer3DTypes for producer classes
0163 */
0164 
0165 class TBuffer3DTube : public TBuffer3D
0166 {
0167 private:
0168    // Non-copyable class
0169    TBuffer3DTube(const TBuffer3DTube &) = delete;
0170    TBuffer3DTube & operator=(const TBuffer3DTube &) = delete;
0171 
0172 protected:
0173    TBuffer3DTube(Int_t type,
0174                  UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0175                  UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0176                  UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0177 
0178 public:
0179    TBuffer3DTube(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0180                  UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0181                  UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0182 
0183    // SECTION: kShapeSpecific
0184    Double_t fRadiusInner;  // Inner radius
0185    Double_t fRadiusOuter;  // Outer radius
0186    Double_t fHalfLength;   // Half length (dz)
0187 };
0188 
0189 /** \class TBuffer3DTubeSeg
0190 Tube segment description class - see TBuffer3DTypes for producer classes
0191 */
0192 
0193 class TBuffer3DTubeSeg : public TBuffer3DTube
0194 {
0195 private:
0196    // Non-copyable class
0197    TBuffer3DTubeSeg(const TBuffer3DTubeSeg &);
0198    TBuffer3DTubeSeg & operator=(const TBuffer3DTubeSeg &) = delete;
0199 
0200 protected:
0201    TBuffer3DTubeSeg(Int_t type,
0202                     UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0203                     UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0204                     UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0205 
0206 public:
0207    TBuffer3DTubeSeg(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0208                     UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0209                     UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0210 
0211    // SECTION: kShapeSpecific
0212    Double_t fPhiMin;       // Lower phi limit
0213    Double_t fPhiMax;       // Higher phi limit
0214 };
0215 
0216 /** \class TBuffer3DCutTube
0217 Cut tube segment description class - see TBuffer3DTypes for producer classes
0218 */
0219 
0220 class TBuffer3DCutTube : public TBuffer3DTubeSeg
0221 {
0222 private:
0223    // Non-copyable class
0224    TBuffer3DCutTube(const TBuffer3DTubeSeg &) = delete;
0225    TBuffer3DCutTube & operator=(const TBuffer3DTubeSeg &) = delete;
0226 
0227 public:
0228    TBuffer3DCutTube(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
0229                     UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0,
0230                     UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);
0231 
0232    // SECTION: kShapeSpecific
0233    Double_t fLowPlaneNorm[3];  // Normal to lower cut plane
0234    Double_t fHighPlaneNorm[3]; // Normal to highest cut plane
0235 };
0236 
0237 #endif