ROOT logo
// @(#)root/base:$Id: TBuffer3D.h,v 1.00 
// Author: Olivier Couet   05/05/04

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TBuffer3D
#define ROOT_TBuffer3D

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TBuffer3D                                                            //
//                                                                      //
// Generic 3D primitive description class - see TBuffer3DTypes for      //
// producer classes                                                     //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif

class TBuffer3D : public TObject
{
private:
   const Int_t fType;        // Primitive type - predefined ones in TBuffer3DTypes.h
                                
   UInt_t    fNbPnts;        // Number of points describing the shape
   UInt_t    fNbSegs;        // Number of segments describing the shape
   UInt_t    fNbPols;        // Number of polygons describing the shape
   
   UInt_t    fPntsCapacity;  // Current capacity of fPnts space
   UInt_t    fSegsCapacity;  // Current capacity of fSegs space
   UInt_t    fPolsCapacity;  // Current capacity of fSegs space
      
   UInt_t    fSections;      // Section validity flags

   void Init();   

   // Non-copyable class
   TBuffer3D(const TBuffer3D &);
   const TBuffer3D & operator=(const TBuffer3D &);

   //CS specific
   static UInt_t fgCSLevel;
   ///////////////////////////////
public:
   //CS specific
   enum EBoolOpCode {kCSUnion, kCSIntersection, kCSDifference, kCSNoOp};

   static UInt_t GetCSLevel();
   static void IncCSLevel();
   static UInt_t DecCSLevel();
   ///////////////////////////////

   enum ESection { kNone            = BIT(0),
                   kCore            = BIT(1),
                   kBoundingBox     = BIT(2),
                   kShapeSpecific   = BIT(3),
                   kRawSizes        = BIT(4), 
                   kRaw             = BIT(5),
                   kAll             = kCore|kBoundingBox|kShapeSpecific|kRawSizes|kRaw 
   };
   
   TBuffer3D(Int_t type, 
             UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
             UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
             UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0); 
   virtual  ~TBuffer3D();

   // Section validity flags
   void   SetSectionsValid(UInt_t mask)     { fSections |= mask & kAll; }
   void   ClearSectionsValid();
   Bool_t SectionsValid(UInt_t mask) const   { return (Bool_t) (GetSections(mask) == mask); }
   UInt_t GetSections(UInt_t mask)   const   { return (UInt_t) (fSections & mask); }
      
   // Convenience functions
   void   SetLocalMasterIdentity();                  // Set fLocalMaster in kCore to identity
   void   SetAABoundingBox(const Double_t origin[3], // Set fBBVertex in kBoundingBox to axis aligned BB
                           const Double_t halfLengths[3]); 

   // SECTION: kRawSize get/set
   Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity,
                      UInt_t reqSegs, UInt_t reqSegsCapacity, 
                      UInt_t reqPols, UInt_t reqPolsCapacity);
   
   UInt_t NbPnts() const { return fNbPnts; }   
   UInt_t NbSegs() const { return fNbSegs; }      
   UInt_t NbPols() const { return fNbPols; }  

   // SECTION: kCore
   Int_t  Type() const { return fType; }

   TObject    *fID;              // ID/object generating buffer - see TVirtualViewer3D for setting
   Int_t       fColor;           // Color index
   Short_t     fTransparency;    // Percentage transparency [0,100]
   Bool_t      fLocalFrame;      // True = Local, False = Master reference frame
   Bool_t      fReflection;      // Matrix is reflection - TODO: REMOVE when OGL viewer rewokred to local frame
   Double_t    fLocalMaster[16]; // Local->Master Matrix - identity if master frame

   // SECTION: kBoundingBox
   //
   // Local frame (fLocalFrame true) axis aligned
   // Master frame (fLocalFrame false) orientated
   // Could be more compact (2 and 3 verticies respectively) and rest
   // calculated as needed - but not worth it
   //   7-------6
   //  /|      /|
   // 3-------2 |
   // | 4-----|-5
   // |/      |/
   // 0-------1 
   //
   Double_t    fBBVertex[8][3];  // 8 verticies defining bounding box. 

   // SECTION: kShapeSpecific - none for base class

   // SECTION: kRaw
   Double_t *fPnts;              // x0, y0, z0, x1, y1, z1, ..... ..... ....
   Int_t    *fSegs;              // c0, p0, q0, c1, p1, q1, ..... ..... ....  
   Int_t    *fPols;              // c0, n0, s0, s1, ... sn, c1, n1, s0, ... sn


   // OUTPUT SECTION, filled by viewer as response
   mutable UInt_t fPhysicalID;   // Unique replica ID.


   ClassDef(TBuffer3D,0)     // 3D primitives description
};

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TBuffer3DSphere                                                      //
//                                                                      //
// Sphere description class - see TBuffer3DTypes for producer classes   //
// Supports hollow and cut spheres.                                     //
//////////////////////////////////////////////////////////////////////////

class TBuffer3DSphere : public TBuffer3D
{
private:
   // Non-copyable class
   TBuffer3DSphere(const TBuffer3DSphere &);
   const TBuffer3DSphere & operator=(const TBuffer3DSphere &);
   
public:
   TBuffer3DSphere(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
                   UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
                   UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);

   Bool_t IsSolidUncut() const;

   // SECTION: kShapeSpecific
   Double_t fRadiusInner;  
   Double_t fRadiusOuter;  
   Double_t fThetaMin;     // Lower theta limit (orientation?)
   Double_t fThetaMax;     // Higher theta limit (orientation?)
   Double_t fPhiMin;       // Lower phi limit (orientation?)
   Double_t fPhiMax;       // Higher phi limit (orientation?)
};

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TBuffer3DTube                                                        //
//                                                                      //
// Complete tube description class - see TBuffer3DTypes for producer    // 
// classes                                                              //
//////////////////////////////////////////////////////////////////////////

class TBuffer3DTube : public TBuffer3D
{
private:
   // Non-copyable class
   TBuffer3DTube(const TBuffer3DTube &);
   const TBuffer3DTube & operator=(const TBuffer3DTube &);

protected:
   TBuffer3DTube(Int_t type,
                 UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
                 UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
                 UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);

public:
   TBuffer3DTube(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
                 UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
                 UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);

   // SECTION: kShapeSpecific
   Double_t fRadiusInner;  // Inner radius
   Double_t fRadiusOuter;  // Outer radius
   Double_t fHalfLength;   // Half length (dz)           
};

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TBuffer3DTubeSeg                                                     //
//                                                                      //
// Tube segment description class - see TBuffer3DTypes for producer     //
// classes                                                              //
//////////////////////////////////////////////////////////////////////////

class TBuffer3DTubeSeg : public TBuffer3DTube
{
private:
   // Non-copyable class
   TBuffer3DTubeSeg(const TBuffer3DTubeSeg &);
   const TBuffer3DTubeSeg & operator=(const TBuffer3DTubeSeg &);

protected:
   TBuffer3DTubeSeg(Int_t type,
                    UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
                    UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
                    UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);

public:
   TBuffer3DTubeSeg(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
                    UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
                    UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);

   // SECTION: kShapeSpecific
   Double_t fPhiMin;       // Lower phi limit
   Double_t fPhiMax;       // Higher phi limit
};

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TBuffer3DCutTube                                                     //
//                                                                      //
// Cut tube segment description class - see TBuffer3DTypes for producer //
// classes                                                              //
//////////////////////////////////////////////////////////////////////////

class TBuffer3DCutTube : public TBuffer3DTubeSeg
{
private:
   // Non-copyable class
   TBuffer3DCutTube(const TBuffer3DTubeSeg &);
   const TBuffer3DCutTube & operator=(const TBuffer3DTubeSeg &);

public:
   TBuffer3DCutTube(UInt_t reqPnts = 0, UInt_t reqPntsCapacity = 0,
                    UInt_t reqSegs = 0, UInt_t reqSegsCapacity = 0, 
                    UInt_t reqPols = 0, UInt_t reqPolsCapacity = 0);

   // SECTION: kShapeSpecific
   Double_t fLowPlaneNorm[3];  // Normal to lower cut plane 
   Double_t fHighPlaneNorm[3]; // Normal to highet cut plane 
};

#endif
 TBuffer3D.h:1
 TBuffer3D.h:2
 TBuffer3D.h:3
 TBuffer3D.h:4
 TBuffer3D.h:5
 TBuffer3D.h:6
 TBuffer3D.h:7
 TBuffer3D.h:8
 TBuffer3D.h:9
 TBuffer3D.h:10
 TBuffer3D.h:11
 TBuffer3D.h:12
 TBuffer3D.h:13
 TBuffer3D.h:14
 TBuffer3D.h:15
 TBuffer3D.h:16
 TBuffer3D.h:17
 TBuffer3D.h:18
 TBuffer3D.h:19
 TBuffer3D.h:20
 TBuffer3D.h:21
 TBuffer3D.h:22
 TBuffer3D.h:23
 TBuffer3D.h:24
 TBuffer3D.h:25
 TBuffer3D.h:26
 TBuffer3D.h:27
 TBuffer3D.h:28
 TBuffer3D.h:29
 TBuffer3D.h:30
 TBuffer3D.h:31
 TBuffer3D.h:32
 TBuffer3D.h:33
 TBuffer3D.h:34
 TBuffer3D.h:35
 TBuffer3D.h:36
 TBuffer3D.h:37
 TBuffer3D.h:38
 TBuffer3D.h:39
 TBuffer3D.h:40
 TBuffer3D.h:41
 TBuffer3D.h:42
 TBuffer3D.h:43
 TBuffer3D.h:44
 TBuffer3D.h:45
 TBuffer3D.h:46
 TBuffer3D.h:47
 TBuffer3D.h:48
 TBuffer3D.h:49
 TBuffer3D.h:50
 TBuffer3D.h:51
 TBuffer3D.h:52
 TBuffer3D.h:53
 TBuffer3D.h:54
 TBuffer3D.h:55
 TBuffer3D.h:56
 TBuffer3D.h:57
 TBuffer3D.h:58
 TBuffer3D.h:59
 TBuffer3D.h:60
 TBuffer3D.h:61
 TBuffer3D.h:62
 TBuffer3D.h:63
 TBuffer3D.h:64
 TBuffer3D.h:65
 TBuffer3D.h:66
 TBuffer3D.h:67
 TBuffer3D.h:68
 TBuffer3D.h:69
 TBuffer3D.h:70
 TBuffer3D.h:71
 TBuffer3D.h:72
 TBuffer3D.h:73
 TBuffer3D.h:74
 TBuffer3D.h:75
 TBuffer3D.h:76
 TBuffer3D.h:77
 TBuffer3D.h:78
 TBuffer3D.h:79
 TBuffer3D.h:80
 TBuffer3D.h:81
 TBuffer3D.h:82
 TBuffer3D.h:83
 TBuffer3D.h:84
 TBuffer3D.h:85
 TBuffer3D.h:86
 TBuffer3D.h:87
 TBuffer3D.h:88
 TBuffer3D.h:89
 TBuffer3D.h:90
 TBuffer3D.h:91
 TBuffer3D.h:92
 TBuffer3D.h:93
 TBuffer3D.h:94
 TBuffer3D.h:95
 TBuffer3D.h:96
 TBuffer3D.h:97
 TBuffer3D.h:98
 TBuffer3D.h:99
 TBuffer3D.h:100
 TBuffer3D.h:101
 TBuffer3D.h:102
 TBuffer3D.h:103
 TBuffer3D.h:104
 TBuffer3D.h:105
 TBuffer3D.h:106
 TBuffer3D.h:107
 TBuffer3D.h:108
 TBuffer3D.h:109
 TBuffer3D.h:110
 TBuffer3D.h:111
 TBuffer3D.h:112
 TBuffer3D.h:113
 TBuffer3D.h:114
 TBuffer3D.h:115
 TBuffer3D.h:116
 TBuffer3D.h:117
 TBuffer3D.h:118
 TBuffer3D.h:119
 TBuffer3D.h:120
 TBuffer3D.h:121
 TBuffer3D.h:122
 TBuffer3D.h:123
 TBuffer3D.h:124
 TBuffer3D.h:125
 TBuffer3D.h:126
 TBuffer3D.h:127
 TBuffer3D.h:128
 TBuffer3D.h:129
 TBuffer3D.h:130
 TBuffer3D.h:131
 TBuffer3D.h:132
 TBuffer3D.h:133
 TBuffer3D.h:134
 TBuffer3D.h:135
 TBuffer3D.h:136
 TBuffer3D.h:137
 TBuffer3D.h:138
 TBuffer3D.h:139
 TBuffer3D.h:140
 TBuffer3D.h:141
 TBuffer3D.h:142
 TBuffer3D.h:143
 TBuffer3D.h:144
 TBuffer3D.h:145
 TBuffer3D.h:146
 TBuffer3D.h:147
 TBuffer3D.h:148
 TBuffer3D.h:149
 TBuffer3D.h:150
 TBuffer3D.h:151
 TBuffer3D.h:152
 TBuffer3D.h:153
 TBuffer3D.h:154
 TBuffer3D.h:155
 TBuffer3D.h:156
 TBuffer3D.h:157
 TBuffer3D.h:158
 TBuffer3D.h:159
 TBuffer3D.h:160
 TBuffer3D.h:161
 TBuffer3D.h:162
 TBuffer3D.h:163
 TBuffer3D.h:164
 TBuffer3D.h:165
 TBuffer3D.h:166
 TBuffer3D.h:167
 TBuffer3D.h:168
 TBuffer3D.h:169
 TBuffer3D.h:170
 TBuffer3D.h:171
 TBuffer3D.h:172
 TBuffer3D.h:173
 TBuffer3D.h:174
 TBuffer3D.h:175
 TBuffer3D.h:176
 TBuffer3D.h:177
 TBuffer3D.h:178
 TBuffer3D.h:179
 TBuffer3D.h:180
 TBuffer3D.h:181
 TBuffer3D.h:182
 TBuffer3D.h:183
 TBuffer3D.h:184
 TBuffer3D.h:185
 TBuffer3D.h:186
 TBuffer3D.h:187
 TBuffer3D.h:188
 TBuffer3D.h:189
 TBuffer3D.h:190
 TBuffer3D.h:191
 TBuffer3D.h:192
 TBuffer3D.h:193
 TBuffer3D.h:194
 TBuffer3D.h:195
 TBuffer3D.h:196
 TBuffer3D.h:197
 TBuffer3D.h:198
 TBuffer3D.h:199
 TBuffer3D.h:200
 TBuffer3D.h:201
 TBuffer3D.h:202
 TBuffer3D.h:203
 TBuffer3D.h:204
 TBuffer3D.h:205
 TBuffer3D.h:206
 TBuffer3D.h:207
 TBuffer3D.h:208
 TBuffer3D.h:209
 TBuffer3D.h:210
 TBuffer3D.h:211
 TBuffer3D.h:212
 TBuffer3D.h:213
 TBuffer3D.h:214
 TBuffer3D.h:215
 TBuffer3D.h:216
 TBuffer3D.h:217
 TBuffer3D.h:218
 TBuffer3D.h:219
 TBuffer3D.h:220
 TBuffer3D.h:221
 TBuffer3D.h:222
 TBuffer3D.h:223
 TBuffer3D.h:224
 TBuffer3D.h:225
 TBuffer3D.h:226
 TBuffer3D.h:227
 TBuffer3D.h:228
 TBuffer3D.h:229
 TBuffer3D.h:230
 TBuffer3D.h:231
 TBuffer3D.h:232
 TBuffer3D.h:233
 TBuffer3D.h:234
 TBuffer3D.h:235
 TBuffer3D.h:236
 TBuffer3D.h:237
 TBuffer3D.h:238
 TBuffer3D.h:239
 TBuffer3D.h:240
 TBuffer3D.h:241
 TBuffer3D.h:242
 TBuffer3D.h:243
 TBuffer3D.h:244
 TBuffer3D.h:245
 TBuffer3D.h:246
 TBuffer3D.h:247
 TBuffer3D.h:248
 TBuffer3D.h:249
 TBuffer3D.h:250
 TBuffer3D.h:251
 TBuffer3D.h:252
 TBuffer3D.h:253
 TBuffer3D.h:254