ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //////////////////////////////////////////////////////////////////////////////
20 // //
21 // TGeoBoolNode - Base class for boolean nodes. A boolean node has pointers //
22 // to two shapes having two transformations with respect to the mother //
23 // composite shape they belong to. It represents the boolean operation //
24 // between the two component shapes. //
25 // //
26 //////////////////////////////////////////////////////////////////////////////
27 
28 // forward declarations
29 class TGeoShape;
30 class TGeoMatrix;
31 class TGeoHMatrix;
32 
33 class TGeoBoolNode : public TObject
34 {
35 public:
40 };
41  struct ThreadData_t
42  {
43  Int_t fSelected; // ! selected branch
44 
45  ThreadData_t();
46  ~ThreadData_t();
47  };
48  ThreadData_t& GetThreadData() const;
49  void ClearThreadData() const;
50  void CreateThreadData(Int_t nthreads);
51 private:
52  TGeoBoolNode(const TGeoBoolNode&); // Not implemented
53  TGeoBoolNode& operator=(const TGeoBoolNode&); // Not implemented
54 
55 protected:
56  TGeoShape *fLeft; // shape on the left branch
57  TGeoShape *fRight; // shape on the right branch
58  TGeoMatrix *fLeftMat; // transformation that applies to the left branch
59  TGeoMatrix *fRightMat; // transformation that applies to the right branch
60  Int_t fNpoints; //! number of points on the mesh
61  Double_t *fPoints; //! array of mesh points
62 
63  mutable std::vector<ThreadData_t*> fThreadData; //! Navigation data per thread
64  mutable Int_t fThreadSize; //! Size for the navigation data array
65 // methods
66  Bool_t MakeBranch(const char *expr, Bool_t left);
67 public:
68  // constructors
69  TGeoBoolNode();
70  TGeoBoolNode(const char *expr1, const char *expr2);
71  TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
72 
73  // destructor
74  virtual ~TGeoBoolNode();
75  // methods
76  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
77  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
78  virtual Bool_t Contains(const Double_t *point) const = 0;
79  virtual Int_t DistanceToPrimitive(Int_t px, Int_t py) = 0;
80  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
81  Double_t step=0, Double_t *safe=0) const = 0;
82  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
83  Double_t step=0, Double_t *safe=0) const = 0;
84  virtual EGeoBoolType GetBooleanOperator() const = 0;
85  virtual Int_t GetNpoints() = 0;
86  TGeoMatrix *GetLeftMatrix() const {return fLeftMat;}
87  TGeoMatrix *GetRightMatrix() const {return fRightMat;}
88  TGeoShape *GetLeftShape() const {return fLeft;}
89  TGeoShape *GetRightShape() const {return fRight;}
90  virtual TGeoBoolNode *MakeClone() const = 0;
91  virtual void Paint(Option_t *option);
92  void RegisterMatrices();
94  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
95  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
96  virtual void SetPoints(Double_t *points) const;
97  virtual void SetPoints(Float_t *points) const;
98  void SetSelected(Int_t sel);
99  virtual void Sizeof3D() const;
100 
101  ClassDef(TGeoBoolNode, 1) // a boolean node
102 };
103 
104 //////////////////////////////////////////////////////////////////////////////
105 // //
106 // TGeoUnion - Boolean node representing a union between two components. //
107 // //
108 //////////////////////////////////////////////////////////////////////////////
109 
110 class TGeoUnion : public TGeoBoolNode
111 {
112 public:
113  // constructors
114  TGeoUnion();
115  TGeoUnion(const char *expr1, const char *expr2);
116  TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
117 
118  // destructor
119  virtual ~TGeoUnion();
120  // methods
121  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
122  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
123  virtual Bool_t Contains(const Double_t *point) const;
125  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
126  Double_t step=0, Double_t *safe=0) const;
127  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
128  Double_t step=0, Double_t *safe=0) const;
129  virtual EGeoBoolType GetBooleanOperator() const {return kGeoUnion;}
130  virtual Int_t GetNpoints();
131  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
132  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
133  virtual void Sizeof3D() const;
134 
135  //CS specific
136  virtual TGeoBoolNode *MakeClone() const;
137  virtual void Paint(Option_t *option);
138 
139  ClassDef(TGeoUnion, 1) // union node
140 };
141 
142 //////////////////////////////////////////////////////////////////////////////
143 // //
144 // TGeoIntersection - Boolean node representing an intersection between two //
145 // components. //
146 // //
147 //////////////////////////////////////////////////////////////////////////////
148 
150 {
151 public:
152  // constructors
154  TGeoIntersection(const char *expr1, const char *expr2);
155  TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
156 
157  // destructor
158  virtual ~TGeoIntersection();
159  // methods
160  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
161  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
162  virtual Bool_t Contains(const Double_t *point) const;
164  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
165  Double_t step=0, Double_t *safe=0) const;
166  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
167  Double_t step=0, Double_t *safe=0) const;
169  virtual Int_t GetNpoints();
170  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
171  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
172  virtual void Sizeof3D() const;
173 
174  //CS specific
175  virtual TGeoBoolNode *MakeClone() const;
176  virtual void Paint(Option_t *option);
177 
178  ClassDef(TGeoIntersection, 1) // intersection node
179 };
180 
181 //////////////////////////////////////////////////////////////////////////////
182 // //
183 // TGeoSubtraction - Boolean node representing a subtraction. //
184 // //
185 //////////////////////////////////////////////////////////////////////////////
186 
188 {
189 public:
190  // constructors
191  TGeoSubtraction();
192  TGeoSubtraction(const char *expr1, const char *expr2);
193  TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
194 
195  // destructor
196  virtual ~TGeoSubtraction();
197  // methods
198  virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
199  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
200  virtual Bool_t Contains(const Double_t *point) const;
202  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
203  Double_t step=0, Double_t *safe=0) const;
204  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
205  Double_t step=0, Double_t *safe=0) const;
207  virtual Int_t GetNpoints();
208  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
209  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
210  virtual void Sizeof3D() const;
211 
212  //CS specific
213  virtual TGeoBoolNode *MakeClone() const;
214  virtual void Paint(Option_t *option);
215 
216  ClassDef(TGeoSubtraction, 1) // subtraction node
217 };
218 #endif
219 
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
Computes distance from a given point inside the shape to its boundary.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this subtraction. ...
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
TGeoUnion()
Default constructor.
virtual ~TGeoUnion()
Destructor — deletion of components handled by TGeoManager class.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a subtraction of two shapes.
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:206
std::vector< ThreadData_t * > fThreadData
array of mesh points
Definition: TGeoBoolNode.h:63
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 DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
TGeoIntersection()
Default constructor.
virtual Int_t GetNpoints()=0
TGeoShape * GetLeftShape() const
Definition: TGeoBoolNode.h:88
virtual void Sizeof3D() const
Register size of this 3D object.
virtual TGeoBoolNode * MakeClone() const
Int_t fNpoints
Definition: TGeoBoolNode.h:60
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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.
Float_t py
Definition: hprod.C:33
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
Compute distance from a given point inside to the shape boundary.
virtual TGeoBoolNode * MakeClone() const =0
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual ~TGeoSubtraction()
Destructor — deletion of components handled by TGeoManager class.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
virtual void Sizeof3D() const
Register 3D size of this shape.
TGeoMatrix * fLeftMat
Definition: TGeoBoolNode.h:58
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.
TGeoMatrix * GetRightMatrix() const
Definition: TGeoBoolNode.h:87
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this union.
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
Compute distance from a given point outside to the shape.
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:129
virtual TGeoBoolNode * MakeClone() const
virtual TGeoBoolNode * MakeClone() const
TGeoBoolNode()
Default constructor.
char * out
Definition: TBase64.cxx:29
virtual ~TGeoBoolNode()
Destructor.
ThreadData_t & GetThreadData() const
point * points
Definition: X3DBuffer.c:20
TGeoShape * fRight
Definition: TGeoBoolNode.h:57
TGeoSubtraction()
Default constructor.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this intersection.
TGeoShape * fLeft
Definition: TGeoBoolNode.h:56
Int_t fThreadSize
Navigation data per thread.
Definition: TGeoBoolNode.h:64
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)=0
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TGeoBoolNode & operator=(const TGeoBoolNode &)
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)=0
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a intersection of two shapes.
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TGeoMatrix * GetLeftMatrix() const
Definition: TGeoBoolNode.h:86
Bool_t ReplaceMatrix(TGeoMatrix *mat, TGeoMatrix *newmat)
Replace one of the matrices.
TGeoMatrix * fRightMat
Definition: TGeoBoolNode.h:59
Double_t * fPoints
number of points on the mesh
Definition: TGeoBoolNode.h:61
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
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
Compute distance from a given point inside to the shape boundary.
TGeoShape * GetRightShape() const
Definition: TGeoBoolNode.h:89
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual Bool_t Contains(const Double_t *point) const =0
virtual ~TGeoIntersection()
Destructor — deletion of components handled by TGeoManager class.
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
double Double_t
Definition: RtypesCore.h:55
virtual void SetPoints(Double_t *points) const
Fill buffer with shape vertices.
void dir(char *path=0)
Definition: rootalias.C:30
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
Compute distance from a given outside point to the shape.
virtual Bool_t Contains(const Double_t *point) const
Find if a intersection of two shapes contains a given point.
virtual Bool_t Contains(const Double_t *point) const
Find if a subtraction of two shapes contains a given point.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
Mother of all ROOT objects.
Definition: TObject.h:58
Float_t px
Definition: hprod.C:33
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual Bool_t Contains(const Double_t *point) const
Find if a union of two shapes contains a given point.
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
Compute distance from a given point outside to the shape.
void ClearThreadData() const
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
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
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a union of two shapes.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:168
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0