Logo ROOT   6.08/07
Reference Guide
TGeoBoolNode.h
Go to the documentation of this file.
1 // @(#):$Id$
2 // Author: Andrei Gheata 30/05/02
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_TGeoBoolNode
13 #define ROOT_TGeoBoolNode
14 
15 #ifndef ROOT_TObject
16 #include "TObject.h"
17 #endif
18 
19 // forward declarations
20 class TGeoShape;
21 class TGeoMatrix;
22 class TGeoHMatrix;
23 
24 class TGeoBoolNode : public TObject
25 {
26 public:
31 };
32  struct ThreadData_t
33  {
34  Int_t fSelected; // ! selected branch
35 
36  ThreadData_t();
37  ~ThreadData_t();
38  };
39  ThreadData_t& GetThreadData() const;
40  void ClearThreadData() const;
41  void CreateThreadData(Int_t nthreads);
42 private:
43  TGeoBoolNode(const TGeoBoolNode&); // Not implemented
44  TGeoBoolNode& operator=(const TGeoBoolNode&); // Not implemented
45 
46 protected:
47  TGeoShape *fLeft; // shape on the left branch
48  TGeoShape *fRight; // shape on the right branch
49  TGeoMatrix *fLeftMat; // transformation that applies to the left branch
50  TGeoMatrix *fRightMat; // transformation that applies to the right branch
51  Int_t fNpoints; //! number of points on the mesh
52  Double_t *fPoints; //! array of mesh points
53 
54  mutable std::vector<ThreadData_t*> fThreadData; //! Navigation data per thread
55  mutable Int_t fThreadSize; //! Size for the navigation data array
56 // methods
57  Bool_t MakeBranch(const char *expr, Bool_t left);
58 public:
59  // constructors
60  TGeoBoolNode();
61  TGeoBoolNode(const char *expr1, const char *expr2);
62  TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
63 
64  // destructor
65  virtual ~TGeoBoolNode();
66  // methods
67  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
68  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
69  virtual Bool_t Contains(const Double_t *point) const = 0;
70  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py) = 0;
71  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
72  Double_t step=0, Double_t *safe=0) const = 0;
73  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
74  Double_t step=0, Double_t *safe=0) const = 0;
75  virtual EGeoBoolType GetBooleanOperator() const = 0;
76  virtual Int_t GetNpoints() = 0;
77  TGeoMatrix *GetLeftMatrix() const {return fLeftMat;}
78  TGeoMatrix *GetRightMatrix() const {return fRightMat;}
79  TGeoShape *GetLeftShape() const {return fLeft;}
80  TGeoShape *GetRightShape() const {return fRight;}
81  virtual TGeoBoolNode *MakeClone() const = 0;
82  virtual void Paint(Option_t *option);
83  void RegisterMatrices();
85  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
86  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
87  virtual void SetPoints(Double_t *points) const;
88  virtual void SetPoints(Float_t *points) const;
89  void SetSelected(Int_t sel);
90  virtual void Sizeof3D() const;
91 
92  ClassDef(TGeoBoolNode, 1) // a boolean node
93 };
94 
95 //////////////////////////////////////////////////////////////////////////////
96 // //
97 // TGeoUnion - Boolean node representing a union between two components. //
98 // //
99 //////////////////////////////////////////////////////////////////////////////
100 
101 class TGeoUnion : public TGeoBoolNode
102 {
103 public:
104  // constructors
105  TGeoUnion();
106  TGeoUnion(const char *expr1, const char *expr2);
107  TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
108 
109  // destructor
110  virtual ~TGeoUnion();
111  // methods
112  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
113  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
114  virtual Bool_t Contains(const Double_t *point) const;
115  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
116  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
117  Double_t step=0, Double_t *safe=0) const;
118  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
119  Double_t step=0, Double_t *safe=0) const;
120  virtual EGeoBoolType GetBooleanOperator() const {return kGeoUnion;}
121  virtual Int_t GetNpoints();
122  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
123  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
124  virtual void Sizeof3D() const;
125 
126  //CS specific
127  virtual TGeoBoolNode *MakeClone() const;
128  virtual void Paint(Option_t *option);
129 
130  ClassDef(TGeoUnion, 1) // union node
131 };
132 
133 //////////////////////////////////////////////////////////////////////////////
134 // //
135 // TGeoIntersection - Boolean node representing an intersection between two //
136 // components. //
137 // //
138 //////////////////////////////////////////////////////////////////////////////
139 
141 {
142 public:
143  // constructors
145  TGeoIntersection(const char *expr1, const char *expr2);
146  TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
147 
148  // destructor
149  virtual ~TGeoIntersection();
150  // methods
151  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
152  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
153  virtual Bool_t Contains(const Double_t *point) const;
154  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
155  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
156  Double_t step=0, Double_t *safe=0) const;
157  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
158  Double_t step=0, Double_t *safe=0) const;
160  virtual Int_t GetNpoints();
161  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
162  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
163  virtual void Sizeof3D() const;
164 
165  //CS specific
166  virtual TGeoBoolNode *MakeClone() const;
167  virtual void Paint(Option_t *option);
168 
169  ClassDef(TGeoIntersection, 1) // intersection node
170 };
171 
172 //////////////////////////////////////////////////////////////////////////////
173 // //
174 // TGeoSubtraction - Boolean node representing a subtraction. //
175 // //
176 //////////////////////////////////////////////////////////////////////////////
177 
179 {
180 public:
181  // constructors
182  TGeoSubtraction();
183  TGeoSubtraction(const char *expr1, const char *expr2);
184  TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
185 
186  // destructor
187  virtual ~TGeoSubtraction();
188  // methods
189  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
190  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
191  virtual Bool_t Contains(const Double_t *point) const;
192  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
193  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
194  Double_t step=0, Double_t *safe=0) const;
195  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
196  Double_t step=0, Double_t *safe=0) const;
198  virtual Int_t GetNpoints();
199  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
200  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
201  virtual void Sizeof3D() const;
202 
203  //CS specific
204  virtual TGeoBoolNode *MakeClone() const;
205  virtual void Paint(Option_t *option);
206 
207  ClassDef(TGeoSubtraction, 1) // subtraction node
208 };
209 #endif
210 
TGeoShape * GetLeftShape() const
Definition: TGeoBoolNode.h:79
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Geometrical transformation package.
Definition: TGeoMatrix.h:40
std::vector< ThreadData_t * > fThreadData
array of mesh points
Definition: TGeoBoolNode.h:54
void SetSelected(Int_t sel)
Set the selected branch.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual Int_t GetNpoints()=0
Int_t fNpoints
Definition: TGeoBoolNode.h:51
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:410
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetPoints(Double_t *points) const
Fill buffer with shape vertices.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const =0
virtual EGeoBoolType GetBooleanOperator() const =0
void RegisterMatrices()
Register all matrices of the boolean node and descendents.
virtual TGeoBoolNode * MakeClone() const =0
TGeoMatrix * fLeftMat
Definition: TGeoBoolNode.h:49
Bool_t MakeBranch(const char *expr, Bool_t left)
Size for the navigation data array.
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:159
TGeoMatrix * GetLeftMatrix() const
Definition: TGeoBoolNode.h:77
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:197
TGeoBoolNode()
Default constructor.
virtual ~TGeoBoolNode()
Destructor.
point * points
Definition: X3DBuffer.c:20
TGeoShape * fRight
Definition: TGeoBoolNode.h:48
Base abstract class for all shapes.
Definition: TGeoShape.h:27
TGeoShape * fLeft
Definition: TGeoBoolNode.h:47
Int_t fThreadSize
Navigation data per thread.
Definition: TGeoBoolNode.h:55
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)=0
TGeoBoolNode & operator=(const TGeoBoolNode &)
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)=0
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
Bool_t ReplaceMatrix(TGeoMatrix *mat, TGeoMatrix *newmat)
Replace one of the matrices.
TGeoMatrix * fRightMat
Definition: TGeoBoolNode.h:50
Double_t * fPoints
number of points on the mesh
Definition: TGeoBoolNode.h:52
virtual Bool_t Contains(const Double_t *point) const =0
ThreadData_t & GetThreadData() const
double Double_t
Definition: RtypesCore.h:55
virtual void Sizeof3D() const
Register size of this 3D object.
TGeoMatrix * GetRightMatrix() const
Definition: TGeoBoolNode.h:78
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
Mother of all ROOT objects.
Definition: TObject.h:37
Base class for Boolean operations between two shapes.
Definition: TGeoBoolNode.h:24
void ClearThreadData() const
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const =0
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
TGeoShape * GetRightShape() const
Definition: TGeoBoolNode.h:80
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:120
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0