TGeometry.h

Go to the documentation of this file.
00001 // @(#)root/g3d:$Id: TGeometry.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Rene Brun   22/09/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGeometry
00013 #define ROOT_TGeometry
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGeometry                                                            //
00019 //                                                                      //
00020 // Structure for Matrices, Shapes and Nodes.                            //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TNamed
00025 #include "TNamed.h"
00026 #endif
00027 #ifndef ROOT_THashList
00028 #include "THashList.h"
00029 #endif
00030 
00031 const Int_t kMAXLEVELS = 20;
00032 const Int_t kVectorSize = 3;
00033 const Int_t kMatrixSize = kVectorSize*kVectorSize;
00034 
00035 class TNode;
00036 class TBrowser;
00037 class TMaterial;
00038 class TRotMatrix;
00039 class TShape;
00040 class TObjArray;
00041 
00042 
00043 class TGeometry : public TNamed {
00044 
00045 private:
00046    THashList        *fMaterials;          //->Collection of materials
00047    THashList        *fMatrices;           //->Collection of rotation matrices
00048    THashList        *fShapes;             //->Collection of shapes
00049    TList            *fNodes;              //->Collection of nodes
00050    TRotMatrix       *fMatrix;             //!Pointers to current rotation matrices
00051    TNode            *fCurrentNode;        //!Pointer to current node
00052    TMaterial       **fMaterialPointer;    //!Pointers to materials
00053    TRotMatrix      **fMatrixPointer;      //!Pointers to rotation matrices
00054    TShape          **fShapePointer;       //!Pointers to shapes
00055    Float_t          fBomb;                //Bomb factor for exploded geometry
00056    Int_t            fGeomLevel;           //!
00057    Double_t         fX;                   //!
00058    Double_t         fY;                   //! The global translation of the current node
00059    Double_t         fZ;                   //!
00060    Double_t         fTranslation[kMAXLEVELS][kVectorSize];//!
00061    Double_t         fRotMatrix[kMAXLEVELS][kMatrixSize];  //!
00062    Bool_t           fIsReflection[kMAXLEVELS];            //!
00063 
00064 protected:
00065    TGeometry(const TGeometry&);
00066    TGeometry& operator=(const TGeometry&);
00067 
00068 public:
00069    TGeometry();
00070    TGeometry(const char *name, const char *title);
00071    virtual           ~TGeometry();
00072    virtual void      Browse(TBrowser *b);
00073    virtual void      cd(const char *path=0);
00074    virtual void      Draw(Option_t *option="");
00075    virtual TObject  *FindObject(const char *name) const;
00076    virtual TObject  *FindObject(const TObject *obj) const;
00077    Float_t           GetBomb() const {return fBomb;}
00078    Int_t             GeomLevel() const {return fGeomLevel;}
00079    THashList        *GetListOfShapes() const  {return fShapes;}
00080    TList            *GetListOfNodes()  const   {return fNodes;}
00081    THashList        *GetListOfMaterials() const {return fMaterials;}
00082    THashList        *GetListOfMatrices() const {return fMatrices;}
00083    TNode            *GetCurrentNode()  const {return fCurrentNode;}
00084    TMaterial        *GetMaterial(const char *name) const;
00085    TMaterial        *GetMaterialByNumber(Int_t number) const;
00086    TNode            *GetNode(const char *name) const;
00087    TShape           *GetShape(const char *name) const;
00088    TShape           *GetShapeByNumber(Int_t number) const;
00089    TRotMatrix       *GetRotMatrix(const char *name) const;
00090    TRotMatrix       *GetRotMatrixByNumber(Int_t number) const;
00091    TRotMatrix       *GetCurrentMatrix() const;
00092    TRotMatrix       *GetCurrentPosition(Double_t *x,Double_t *y,Double_t *z) const;
00093    TRotMatrix       *GetCurrentPosition(Float_t *x,Float_t *y,Float_t *z) const;
00094    Bool_t            GetCurrentReflection() const;
00095    Bool_t            IsFolder() const {return kTRUE;}
00096    virtual void      Local2Master(Double_t *local, Double_t *master);
00097    virtual void      Local2Master(Float_t *local, Float_t *master);
00098    virtual void      ls(Option_t *option="rsn2") const;
00099    virtual void      Master2Local(Double_t *master, Double_t *local);
00100    virtual void      Master2Local(Float_t *master, Float_t *local);
00101    virtual void      Node(const char *name, const char *title, const char *shapename, Double_t x=0, Double_t y=0, Double_t z=0
00102                         , const char *matrixname="", Option_t *option="");
00103    virtual Int_t     PushLevel(){return fGeomLevel++;}
00104    virtual Int_t     PopLevel(){return fGeomLevel>0?fGeomLevel--:0;}
00105    virtual void      RecursiveRemove(TObject *obj);
00106    virtual void      SetBomb(Float_t bomb=1.4) {fBomb = bomb;}
00107    virtual void      SetCurrentNode(TNode *node) {fCurrentNode = node;}
00108    virtual void      SetGeomLevel(Int_t level=0){fGeomLevel=level;}
00109    virtual void      SetMatrix(TRotMatrix *matrix=0){fMatrix = matrix;}
00110    virtual void      SetPosition(TRotMatrix *matrix, Double_t x=0,Double_t y=0,Double_t z=0);
00111    virtual void      SetPosition(TRotMatrix *matrix, Float_t x,Float_t y,Float_t z);
00112    virtual void      SetPosition(Double_t x,Double_t y,Double_t z);
00113    virtual void      SetPosition(Float_t x,Float_t y,Float_t z);
00114    virtual void      UpdateMatrix(TNode *node);
00115    virtual void      UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0);
00116    virtual void      UpdateTempMatrix(Double_t x, Double_t y, Double_t z, Double_t *matrix,Bool_t isReflection=kFALSE);
00117 
00118    static TObjArray *Get(const char *name);
00119    static void       UpdateTempMatrix(Double_t *dx1,Double_t *rmat1,
00120                                       Double_t x, Double_t y, Double_t z, Double_t *matrix,
00121                                       Double_t *dxnew, Double_t *rmatnew);
00122 
00123    ClassDef(TGeometry,2)  //Structure for Matrices, Shapes and Nodes
00124 };
00125 
00126 
00127 inline TRotMatrix *TGeometry::GetCurrentMatrix() const
00128 {
00129    return fMatrix;
00130 }
00131 inline TRotMatrix *TGeometry::GetCurrentPosition(Double_t *x,Double_t *y,Double_t *z) const
00132 {
00133    *x = fX; *y = fY; *z = fZ; return GetCurrentMatrix();
00134 }
00135 inline TRotMatrix *TGeometry::GetCurrentPosition(Float_t *x,Float_t *y,Float_t *z) const
00136 {
00137    *x = Float_t(fX); *y = Float_t(fY); *z = Float_t(fZ); return GetCurrentMatrix();
00138 }
00139 inline Bool_t TGeometry::GetCurrentReflection() const
00140 {
00141    return fIsReflection[fGeomLevel];
00142 }
00143 inline void TGeometry::SetPosition(Double_t x,Double_t y,Double_t z)
00144 {
00145    fX = x; fY = y; fZ = z;
00146 }
00147 inline void TGeometry::SetPosition(Float_t x,Float_t y,Float_t z)
00148 {
00149    fX = x; fY = y; fZ = z;
00150 }
00151 inline void TGeometry::SetPosition(TRotMatrix *matrix, Double_t x,Double_t y,Double_t z)
00152 {
00153    SetMatrix(matrix);
00154    SetPosition(x,y,z);
00155 }
00156 inline void TGeometry::SetPosition(TRotMatrix *matrix, Float_t x,Float_t y,Float_t z)
00157 {
00158    SetMatrix(matrix);
00159    SetPosition(x,y,z);
00160 }
00161 
00162 R__EXTERN TGeometry *gGeometry;
00163 
00164 #endif

Generated on Tue Jul 5 14:16:19 2011 for ROOT_528-00b_version by  doxygen 1.5.1