Logo ROOT  
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&) = delete;
45
46protected:
47 TGeoShape *fLeft{nullptr}; // shape on the left branch
48 TGeoShape *fRight{nullptr}; // shape on the right branch
49 TGeoMatrix *fLeftMat{nullptr}; // transformation that applies to the left branch
50 TGeoMatrix *fRightMat{nullptr}; // transformation that applies to the right branch
51 Int_t fNpoints{0}; //! number of points on the mesh
52 Double_t *fPoints{nullptr}; //! array of mesh points
53
54 mutable std::vector<ThreadData_t*> fThreadData; //! Navigation data per thread
55 mutable Int_t fThreadSize{0}; //! 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 void AssignPoints(Int_t npoints, Double_t *points);
60
61public:
62 // constructors
64 TGeoBoolNode(const char *expr1, const char *expr2);
65 TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
66
67 // destructor
68 virtual ~TGeoBoolNode();
69 // methods
70 virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
71 virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
72 virtual Bool_t Contains(const Double_t *point) const = 0;
73 virtual Int_t DistanceToPrimitive(Int_t px, Int_t py) = 0;
74 virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
75 Double_t step=0, Double_t *safe=nullptr) const = 0;
76 virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
77 Double_t step=0, Double_t *safe=nullptr) const = 0;
78 virtual EGeoBoolType GetBooleanOperator() const = 0;
79 virtual Int_t GetNpoints() = 0;
82 TGeoShape *GetLeftShape() const {return fLeft;}
83 TGeoShape *GetRightShape() const {return fRight;}
84 virtual TGeoBoolNode *MakeClone() const = 0;
85 void Paint(Option_t *option) override;
86 void RegisterMatrices();
88 virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
89 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
90 virtual void SetPoints(Double_t *points) const;
91 virtual void SetPoints(Float_t *points) const;
92 void SetSelected(Int_t sel);
93 virtual void Sizeof3D() const;
94
95 ClassDefOverride(TGeoBoolNode, 1) // a boolean node
96};
97
98//////////////////////////////////////////////////////////////////////////////
99// //
100// TGeoUnion - Boolean node representing a union between two components. //
101// //
102//////////////////////////////////////////////////////////////////////////////
103
105{
106public:
107 // constructors
108 TGeoUnion();
109 TGeoUnion(const char *expr1, const char *expr2);
110 TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
111
112 // destructor
113 virtual ~TGeoUnion();
114 // methods
115 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override;
116 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
117 Bool_t Contains(const Double_t *point) const override;
118 Int_t DistanceToPrimitive(Int_t px, Int_t py) override;
119 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
120 Double_t step = 0, Double_t *safe = nullptr) const override;
121 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
122 Double_t step = 0, Double_t *safe=nullptr) const override;
123 EGeoBoolType GetBooleanOperator() const override {return kGeoUnion;}
124 Int_t GetNpoints() override;
125 Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override;
126 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
127 void Sizeof3D() const override;
128
129 //CS specific
130 TGeoBoolNode *MakeClone() const override;
131 void Paint(Option_t *option) override;
132
133 ClassDefOverride(TGeoUnion, 1) // union node
134};
135
136//////////////////////////////////////////////////////////////////////////////
137// //
138// TGeoIntersection - Boolean node representing an intersection between two //
139// components. //
140// //
141//////////////////////////////////////////////////////////////////////////////
142
144{
145public:
146 // constructors
148 TGeoIntersection(const char *expr1, const char *expr2);
149 TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
150
151 // destructor
152 virtual ~TGeoIntersection();
153 // methods
154 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override;
155 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
156 Bool_t Contains(const Double_t *point) const override;
157 Int_t DistanceToPrimitive(Int_t px, Int_t py) override;
158 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
159 Double_t step = 0, Double_t *safe = nullptr) const override;
160 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
161 Double_t step = 0, Double_t *safe = nullptr) const override;
163 Int_t GetNpoints() override;
164 Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override;
165 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
166 void Sizeof3D() const override;
167
168 //CS specific
169 TGeoBoolNode *MakeClone() const override;
170 void Paint(Option_t *option) override;
171
172 ClassDefOverride(TGeoIntersection, 1) // intersection node
173};
174
175//////////////////////////////////////////////////////////////////////////////
176// //
177// TGeoSubtraction - Boolean node representing a subtraction. //
178// //
179//////////////////////////////////////////////////////////////////////////////
180
182{
183public:
184 // constructors
186 TGeoSubtraction(const char *expr1, const char *expr2);
187 TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
188
189 // destructor
190 virtual ~TGeoSubtraction();
191 // methods
192 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override;
193 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
194 Bool_t Contains(const Double_t *point) const override;
195 Int_t DistanceToPrimitive(Int_t px, Int_t py) override;
196 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
197 Double_t step = 0, Double_t *safe = nullptr) const override;
198 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
199 Double_t step = 0, Double_t *safe = nullptr) const override;
201 Int_t GetNpoints() override;
202 Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override;
203 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
204 void Sizeof3D() const override;
205
206 //CS specific
207 TGeoBoolNode *MakeClone() const override;
208 void Paint(Option_t *option) override;
209
210 ClassDefOverride(TGeoSubtraction, 1) // subtraction node
211};
212
213#endif
int Int_t
Definition: RtypesCore.h:43
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDefOverride(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 ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0
Int_t fNpoints
Definition: TGeoBoolNode.h:51
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 AssignPoints(Int_t npoints, Double_t *points)
Set fPoints array.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
TGeoMatrix * GetRightMatrix() const
Definition: TGeoBoolNode.h:81
TGeoShape * GetLeftShape() const
Definition: TGeoBoolNode.h:82
void Paint(Option_t *option) override
Special schema for feeding the 3D buffers to the painter client.
TGeoMatrix * GetLeftMatrix() const
Definition: TGeoBoolNode.h:80
TGeoBoolNode(const TGeoBoolNode &)=delete
virtual void SetPoints(Double_t *points) const
Fill buffer with shape vertices.
Int_t fThreadSize
Navigation data per thread.
Definition: TGeoBoolNode.h:55
TGeoBoolNode & operator=(const TGeoBoolNode &)=delete
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
Double_t * fPoints
number of points on the mesh
Definition: TGeoBoolNode.h:52
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const =0
TGeoShape * GetRightShape() const
Definition: TGeoBoolNode.h:83
TGeoBoolNode()
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=nullptr) const =0
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
Int_t DistanceToPrimitive(Int_t px, Int_t py) override
Compute minimum distance to shape vertices.
TGeoBoolNode * MakeClone() const override
Make a clone of this. Pointers are preserved.
TGeoIntersection()
Default constructor.
void Sizeof3D() const override
Register 3D size of this shape.
virtual ~TGeoIntersection()
Destructor — deletion of components handled by TGeoManager class.
void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override
Compute bounding box corresponding to a intersection of two shapes.
EGeoBoolType GetBooleanOperator() const override
Definition: TGeoBoolNode.h:162
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const override
Compute distance from a given point outside to the shape.
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
Compute safety distance for a union node;.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const override
Compute distance from a given point inside to the shape boundary.
void Paint(Option_t *option) override
Paint method.
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
Bool_t Contains(const Double_t *point) const override
Find if a intersection of two shapes contains a given point.
Int_t GetNpoints() override
Returns number of vertices for the composite shape described by this intersection.
Geometrical transformation package.
Definition: TGeoMatrix.h:41
Base abstract class for all shapes.
Definition: TGeoShape.h:26
TGeoSubtraction()
Default constructor.
void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override
Compute bounding box corresponding to a subtraction of two shapes.
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
Compute safety distance for a union node;.
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
TGeoBoolNode * MakeClone() const override
Make a clone of this. Pointers are preserved.
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const override
Compute distance from a given point outside to the shape.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Bool_t Contains(const Double_t *point) const override
Find if a subtraction of two shapes contains a given point.
void Sizeof3D() const override
Register 3D size of this shape.
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const override
Compute distance from a given point inside to the shape boundary.
void Paint(Option_t *option) override
Paint method.
Int_t DistanceToPrimitive(Int_t px, Int_t py) override
Compute minimum distance to shape vertices.
virtual ~TGeoSubtraction()
Destructor — deletion of components handled by TGeoManager class.
Int_t GetNpoints() override
Returns number of vertices for the composite shape described by this subtraction.
EGeoBoolType GetBooleanOperator() const override
Definition: TGeoBoolNode.h:200
Int_t DistanceToPrimitive(Int_t px, Int_t py) override
Compute minimum distance to shape vertices.
TGeoBoolNode * MakeClone() const override
Make a clone of this. Pointers are preserved.
void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override
Compute bounding box corresponding to a union of two shapes.
Int_t GetNpoints() override
Returns number of vertices for the composite shape described by this union.
virtual ~TGeoUnion()
Destructor — deletion of components handled by TGeoManager class.
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const override
Compute distance from a given outside point to the shape.
Bool_t Contains(const Double_t *point) const override
Find if a union of two shapes contains a given point.
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
Compute safety distance for a union node;.
EGeoBoolType GetBooleanOperator() const override
Definition: TGeoBoolNode.h:123
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=nullptr) const override
Computes distance from a given point inside the shape to its boundary.
TGeoUnion()
Default constructor.
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
void Paint(Option_t *option) override
Paint method.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void Sizeof3D() const override
Register 3D size of this shape.
Mother of all ROOT objects.
Definition: TObject.h:37