Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGeometry.h
Go to the documentation of this file.
1 // @(#)root/g3d:$Id$
2 // Author: Rene Brun 22/09/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGeometry
13 #define ROOT_TGeometry
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGeometry //
19 // //
20 // Structure for Matrices, Shapes and Nodes. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TNamed.h"
25 #include "THashList.h"
26 
27 const Int_t kMAXLEVELS = 20;
28 const Int_t kVectorSize = 3;
29 const Int_t kMatrixSize = kVectorSize*kVectorSize;
30 
31 class TNode;
32 class TBrowser;
33 class TMaterial;
34 class TRotMatrix;
35 class TShape;
36 class TObjArray;
37 
38 
39 class TGeometry : public TNamed {
40 
41 private:
42  THashList *fMaterials; //->Collection of materials
43  THashList *fMatrices; //->Collection of rotation matrices
44  THashList *fShapes; //->Collection of shapes
45  TList *fNodes; //->Collection of nodes
46  TRotMatrix *fMatrix; //!Pointers to current rotation matrices
47  TNode *fCurrentNode; //!Pointer to current node
48  TMaterial **fMaterialPointer; //!Pointers to materials
49  TRotMatrix **fMatrixPointer; //!Pointers to rotation matrices
50  TShape **fShapePointer; //!Pointers to shapes
51  Float_t fBomb; //Bomb factor for exploded geometry
52  Int_t fGeomLevel; //!
53  Double_t fX; //!
54  Double_t fY; //! The global translation of the current node
55  Double_t fZ; //!
56  Double_t fTranslation[kMAXLEVELS][kVectorSize];//!
57  Double_t fRotMatrix[kMAXLEVELS][kMatrixSize]; //!
58  Bool_t fIsReflection[kMAXLEVELS]; //!
59 
60 protected:
61  TGeometry(const TGeometry&);
62  TGeometry& operator=(const TGeometry&);
63 
64 public:
65  TGeometry();
66  TGeometry(const char *name, const char *title);
67  virtual ~TGeometry();
68  virtual void Browse(TBrowser *b);
69  virtual void cd(const char *path=0);
70  virtual void Draw(Option_t *option="");
71  virtual TObject *FindObject(const char *name) const;
72  virtual TObject *FindObject(const TObject *obj) const;
73  Float_t GetBomb() const {return fBomb;}
74  Int_t GeomLevel() const {return fGeomLevel;}
75  THashList *GetListOfShapes() const {return fShapes;}
76  TList *GetListOfNodes() const {return fNodes;}
77  THashList *GetListOfMaterials() const {return fMaterials;}
78  THashList *GetListOfMatrices() const {return fMatrices;}
79  TNode *GetCurrentNode() const {return fCurrentNode;}
80  TMaterial *GetMaterial(const char *name) const;
81  TMaterial *GetMaterialByNumber(Int_t number) const;
82  TNode *GetNode(const char *name) const;
83  TShape *GetShape(const char *name) const;
84  TShape *GetShapeByNumber(Int_t number) const;
85  TRotMatrix *GetRotMatrix(const char *name) const;
86  TRotMatrix *GetRotMatrixByNumber(Int_t number) const;
87  TRotMatrix *GetCurrentMatrix() const;
88  TRotMatrix *GetCurrentPosition(Double_t *x,Double_t *y,Double_t *z) const;
89  TRotMatrix *GetCurrentPosition(Float_t *x,Float_t *y,Float_t *z) const;
90  Bool_t GetCurrentReflection() const;
91  Bool_t IsFolder() const {return kTRUE;}
92  virtual void Local2Master(Double_t *local, Double_t *master);
93  virtual void Local2Master(Float_t *local, Float_t *master);
94  virtual void ls(Option_t *option="rsn2") const;
95  virtual void Master2Local(Double_t *master, Double_t *local);
96  virtual void Master2Local(Float_t *master, Float_t *local);
97  virtual void Node(const char *name, const char *title, const char *shapename, Double_t x=0, Double_t y=0, Double_t z=0
98  , const char *matrixname="", Option_t *option="");
99  virtual Int_t PushLevel(){return fGeomLevel++;}
100  virtual Int_t PopLevel(){return fGeomLevel>0?fGeomLevel--:0;}
101  virtual void RecursiveRemove(TObject *obj);
102  virtual void SetBomb(Float_t bomb=1.4) {fBomb = bomb;}
103  virtual void SetCurrentNode(TNode *node) {fCurrentNode = node;}
104  virtual void SetGeomLevel(Int_t level=0){fGeomLevel=level;}
105  virtual void SetMatrix(TRotMatrix *matrix=0){fMatrix = matrix;}
106  virtual void SetPosition(TRotMatrix *matrix, Double_t x=0,Double_t y=0,Double_t z=0);
107  virtual void SetPosition(TRotMatrix *matrix, Float_t x,Float_t y,Float_t z);
108  virtual void SetPosition(Double_t x,Double_t y,Double_t z);
109  virtual void SetPosition(Float_t x,Float_t y,Float_t z);
110  virtual void UpdateMatrix(TNode *node);
111  virtual void UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0);
112  virtual void UpdateTempMatrix(Double_t x, Double_t y, Double_t z, Double_t *matrix,Bool_t isReflection=kFALSE);
113 
114  static TObjArray *Get(const char *name);
115  static void UpdateTempMatrix(Double_t *dx1,Double_t *rmat1,
116  Double_t x, Double_t y, Double_t z, Double_t *matrix,
117  Double_t *dxnew, Double_t *rmatnew);
118 
119  ClassDef(TGeometry,2) //Structure for Matrices, Shapes and Nodes
120 };
121 
122 
123 inline TRotMatrix *TGeometry::GetCurrentMatrix() const
124 {
125  return fMatrix;
126 }
127 inline TRotMatrix *TGeometry::GetCurrentPosition(Double_t *x,Double_t *y,Double_t *z) const
128 {
129  *x = fX; *y = fY; *z = fZ; return GetCurrentMatrix();
130 }
131 inline TRotMatrix *TGeometry::GetCurrentPosition(Float_t *x,Float_t *y,Float_t *z) const
132 {
133  *x = Float_t(fX); *y = Float_t(fY); *z = Float_t(fZ); return GetCurrentMatrix();
134 }
135 inline Bool_t TGeometry::GetCurrentReflection() const
136 {
137  return fIsReflection[fGeomLevel];
138 }
139 inline void TGeometry::SetPosition(Double_t x,Double_t y,Double_t z)
140 {
141  fX = x; fY = y; fZ = z;
142 }
143 inline void TGeometry::SetPosition(Float_t x,Float_t y,Float_t z)
144 {
145  fX = x; fY = y; fZ = z;
146 }
147 inline void TGeometry::SetPosition(TRotMatrix *matrix, Double_t x,Double_t y,Double_t z)
148 {
149  SetMatrix(matrix);
150  SetPosition(x,y,z);
151 }
152 inline void TGeometry::SetPosition(TRotMatrix *matrix, Float_t x,Float_t y,Float_t z)
153 {
154  SetMatrix(matrix);
155  SetPosition(x,y,z);
156 }
157 
158 R__EXTERN TGeometry *gGeometry;
159 
160 #endif