Logo ROOT   6.18/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
20class TGeoShape;
21class TGeoMatrix;
22class TGeoHMatrix;
23
24class TGeoBoolNode : public TObject
25{
26public:
31};
33 {
34 Int_t fSelected; // ! selected branch
35
38 };
40 void ClearThreadData() const;
41 void CreateThreadData(Int_t nthreads);
42private:
43 TGeoBoolNode(const TGeoBoolNode&); // Not implemented
44 TGeoBoolNode& operator=(const TGeoBoolNode&); // Not implemented
45
46protected:
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);
59public:
60 // constructors
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;
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
103{
104public:
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{
143public:
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{
181public:
182 // constructors
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
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
point * points
Definition: X3DBuffer.c:22
Base class for Boolean operations between two shapes.
Definition: TGeoBoolNode.h:25
virtual void Sizeof3D() const
Register size of this 3D object.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0
Int_t fNpoints
Definition: TGeoBoolNode.h:51
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
Bool_t MakeBranch(const char *expr, Bool_t left)
Mutex for thread data access.
TGeoMatrix * fLeftMat
Definition: TGeoBoolNode.h:49
void ClearThreadData() const
TGeoShape * fLeft
Definition: TGeoBoolNode.h:47
Bool_t ReplaceMatrix(TGeoMatrix *mat, TGeoMatrix *newmat)
Replace one of the matrices.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)=0
virtual EGeoBoolType GetBooleanOperator() const =0
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
TGeoMatrix * GetRightMatrix() const
Definition: TGeoBoolNode.h:79
TGeoShape * GetLeftShape() const
Definition: TGeoBoolNode.h:80
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
TGeoMatrix * GetLeftMatrix() const
Definition: TGeoBoolNode.h:78
TGeoBoolNode(const TGeoBoolNode &)
TGeoBoolNode & operator=(const TGeoBoolNode &)
virtual void SetPoints(Double_t *points) const
Fill buffer with shape vertices.
Int_t fThreadSize
Navigation data per thread.
Definition: TGeoBoolNode.h:55
std::mutex fMutex
Size for the navigation data array.
Definition: TGeoBoolNode.h:56
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
std::vector< ThreadData_t * > fThreadData
array of mesh points
Definition: TGeoBoolNode.h:54
void RegisterMatrices()
Register all matrices of the boolean node and descendents.
virtual Bool_t Contains(const Double_t *point) const =0
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)=0
TGeoShape * fRight
Definition: TGeoBoolNode.h:48
virtual ~TGeoBoolNode()
Destructor.
virtual Int_t GetNpoints()=0
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
Double_t * fPoints
number of points on the mesh
Definition: TGeoBoolNode.h:52
TGeoShape * GetRightShape() const
Definition: TGeoBoolNode.h:81
TGeoBoolNode()
Default constructor.
TGeoMatrix * fRightMat
Definition: TGeoBoolNode.h:50
ThreadData_t & GetThreadData() const
virtual TGeoBoolNode * MakeClone() const =0
void SetSelected(Int_t sel)
Set the selected branch.
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition: TGeoMatrix.h:421
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.
TGeoIntersection()
Default constructor.
virtual Bool_t Contains(const Double_t *point) const
Find if a intersection of two shapes contains a given point.
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 EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:160
virtual ~TGeoIntersection()
Destructor — deletion of components handled by TGeoManager class.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual void Paint(Option_t *option)
Paint method.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
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 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a intersection of two shapes.
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this intersection.
virtual TGeoBoolNode * MakeClone() const
Make a clone of this. Pointers are preserved.
Geometrical transformation package.
Definition: TGeoMatrix.h:41
Base abstract class for all shapes.
Definition: TGeoShape.h:26
TGeoSubtraction()
Default constructor.
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 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 Bool_t Contains(const Double_t *point) const
Find if a subtraction of two shapes contains a given point.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
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.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:198
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual TGeoBoolNode * MakeClone() const
Make a clone of this. Pointers are preserved.
virtual void Paint(Option_t *option)
Paint method.
virtual ~TGeoSubtraction()
Destructor — deletion of components handled by TGeoManager class.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this subtraction.
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 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 Paint(Option_t *option)
Paint method.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual ~TGeoUnion()
Destructor — deletion of components handled by TGeoManager class.
virtual TGeoBoolNode * MakeClone() const
Make a clone of this. Pointers are preserved.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this union.
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 EGeoBoolType GetBooleanOperator() const
Definition: TGeoBoolNode.h:121
TGeoUnion()
Default constructor.
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 union of two shapes contains a given point.
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 Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
virtual void Sizeof3D() const
Register 3D size of this shape.
Mother of all ROOT objects.
Definition: TObject.h:37