Logo ROOT   6.14/05
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 #include <mutex>
16 
17 #include "TObject.h"
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  mutable std::mutex fMutex; //! Mutex for thread data access
57 // methods
58  Bool_t MakeBranch(const char *expr, Bool_t left);
59 public:
60  // constructors
61  TGeoBoolNode();
62  TGeoBoolNode(const char *expr1, const char *expr2);
63  TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
64 
65  // destructor
66  virtual ~TGeoBoolNode();
67  // methods
68  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
69  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
70  virtual Bool_t Contains(const Double_t *point) const = 0;
71  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py) = 0;
72  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
73  Double_t step=0, Double_t *safe=0) const = 0;
74  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
75  Double_t step=0, Double_t *safe=0) const = 0;
76  virtual EGeoBoolType GetBooleanOperator() const = 0;
77  virtual Int_t GetNpoints() = 0;
78  TGeoMatrix *GetLeftMatrix() const {return fLeftMat;}
79  TGeoMatrix *GetRightMatrix() const {return fRightMat;}
80  TGeoShape *GetLeftShape() const {return fLeft;}
81  TGeoShape *GetRightShape() const {return fRight;}
82  virtual TGeoBoolNode *MakeClone() const = 0;
83  virtual void Paint(Option_t *option);
84  void RegisterMatrices();
86  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
87  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
88  virtual void SetPoints(Double_t *points) const;
89  virtual void SetPoints(Float_t *points) const;
90  void SetSelected(Int_t sel);
91  virtual void Sizeof3D() const;
92 
93  ClassDef(TGeoBoolNode, 1) // a boolean node
94 };
95 
96 //////////////////////////////////////////////////////////////////////////////
97 // //
98 // TGeoUnion - Boolean node representing a union between two components. //
99 // //
100 //////////////////////////////////////////////////////////////////////////////
101 
102 class TGeoUnion : public TGeoBoolNode
103 {
104 public:
105  // constructors
106  TGeoUnion();
107  TGeoUnion(const char *expr1, const char *expr2);
108  TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
109 
110  // destructor
111  virtual ~TGeoUnion();
112  // methods
113  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
114  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
115  virtual Bool_t Contains(const Double_t *point) const;
116  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
117  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
118  Double_t step=0, Double_t *safe=0) const;
119  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
120  Double_t step=0, Double_t *safe=0) const;
121  virtual EGeoBoolType GetBooleanOperator() const {return kGeoUnion;}
122  virtual Int_t GetNpoints();
123  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
124  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
125  virtual void Sizeof3D() const;
126 
127  //CS specific
128  virtual TGeoBoolNode *MakeClone() const;
129  virtual void Paint(Option_t *option);
130 
131  ClassDef(TGeoUnion, 1) // union node
132 };
133 
134 //////////////////////////////////////////////////////////////////////////////
135 // //
136 // TGeoIntersection - Boolean node representing an intersection between two //
137 // components. //
138 // //
139 //////////////////////////////////////////////////////////////////////////////
140 
142 {
143 public:
144  // constructors
146  TGeoIntersection(const char *expr1, const char *expr2);
147  TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
148 
149  // destructor
150  virtual ~TGeoIntersection();
151  // methods
152  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
153  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
154  virtual Bool_t Contains(const Double_t *point) const;
155  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
156  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
157  Double_t step=0, Double_t *safe=0) const;
158  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
159  Double_t step=0, Double_t *safe=0) const;
161  virtual Int_t GetNpoints();
162  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
163  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
164  virtual void Sizeof3D() const;
165 
166  //CS specific
167  virtual TGeoBoolNode *MakeClone() const;
168  virtual void Paint(Option_t *option);
169 
170  ClassDef(TGeoIntersection, 1) // intersection node
171 };
172 
173 //////////////////////////////////////////////////////////////////////////////
174 // //
175 // TGeoSubtraction - Boolean node representing a subtraction. //
176 // //
177 //////////////////////////////////////////////////////////////////////////////
178 
180 {
181 public:
182  // constructors
183  TGeoSubtraction();
184  TGeoSubtraction(const char *expr1, const char *expr2);
185  TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
186 
187  // destructor
188  virtual ~TGeoSubtraction();
189  // methods
190  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
191  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
192  virtual Bool_t Contains(const Double_t *point) const;
193  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
194  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
195  Double_t step=0, Double_t *safe=0) const;
196  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
197  Double_t step=0, Double_t *safe=0) const;
199  virtual Int_t GetNpoints();
200  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
201  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
202  virtual void Sizeof3D() const;
203 
204  //CS specific
205  virtual TGeoBoolNode *MakeClone() const;
206  virtual void Paint(Option_t *option);
207 
208  ClassDef(TGeoSubtraction, 1) // subtraction node
209 };
210 #endif
211 
TGeoShape * GetLeftShape() const
Definition: TGeoBoolNode.h:80
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:420
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
std::mutex fMutex
Size for the navigation data array.
Definition: TGeoBoolNode.h:56
TGeoMatrix * fLeftMat
Definition: TGeoBoolNode.h:49
Bool_t MakeBranch(const char *expr, Bool_t left)
Mutex for thread data access.
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:160
TGeoMatrix * GetLeftMatrix() const
Definition: TGeoBoolNode.h:78
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:198
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:25
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:79
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
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
const Bool_t kTRUE
Definition: RtypesCore.h:87
TGeoShape * GetRightShape() const
Definition: TGeoBoolNode.h:81
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:121
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0