Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TObject.h"
16
17#include <mutex>
18#include <vector>
19
20// forward declarations
21class TGeoShape;
22class TGeoMatrix;
23class TGeoHMatrix;
24
25class TGeoBoolNode : public TObject {
26public:
28 struct ThreadData_t {
29 Int_t fSelected; // ! selected branch
30
33 };
35 void ClearThreadData() const;
36 void CreateThreadData(Int_t nthreads);
37
38private:
39 TGeoBoolNode(const TGeoBoolNode &) = delete;
41
42protected:
43 TGeoShape *fLeft{nullptr}; // shape on the left branch
44 TGeoShape *fRight{nullptr}; // shape on the right branch
45 TGeoMatrix *fLeftMat{nullptr}; // transformation that applies to the left branch
46 TGeoMatrix *fRightMat{nullptr}; // transformation that applies to the right branch
47 Int_t fNpoints{0}; //! number of points on the mesh
48 Double_t *fPoints{nullptr}; //! array of mesh points
49
50 mutable std::vector<ThreadData_t *> fThreadData; //! Navigation data per thread
51 mutable Int_t fThreadSize{0}; //! Size for the navigation data array
52 mutable std::mutex fMutex; //! Mutex for thread data access
53 // methods
54 Bool_t MakeBranch(const char *expr, Bool_t left);
55 void AssignPoints(Int_t npoints, Double_t *points);
56
57public:
58 // constructors
60 TGeoBoolNode(const char *expr1, const char *expr2);
61 TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
62
63 // destructor
64 ~TGeoBoolNode() override;
65 // methods
66 virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
67 virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
68 virtual Bool_t Contains(const Double_t *point) const = 0;
69 virtual Int_t DistanceToPrimitive(Int_t px, Int_t py) = 0;
70 virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
71 Double_t *safe = nullptr) const = 0;
72 virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
73 Double_t *safe = nullptr) const = 0;
74 virtual EGeoBoolType GetBooleanOperator() const = 0;
75 virtual Int_t GetNpoints() = 0;
76 TGeoMatrix *GetLeftMatrix() const { return fLeftMat; }
77 TGeoMatrix *GetRightMatrix() const { return fRightMat; }
78 TGeoShape *GetLeftShape() const { return fLeft; }
79 TGeoShape *GetRightShape() const { return fRight; }
80 virtual TGeoBoolNode *MakeClone() const = 0;
81 void Paint(Option_t *option) override;
82 void RegisterMatrices();
84 virtual Double_t Safety(const Double_t *point, Bool_t in = kTRUE) const = 0;
85 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
86 virtual void SetPoints(Double_t *points) const;
87 virtual void SetPoints(Float_t *points) const;
88 void SetSelected(Int_t sel);
89 virtual void Sizeof3D() const;
90
91 ClassDefOverride(TGeoBoolNode, 1) // a boolean node
92};
93
94//////////////////////////////////////////////////////////////////////////////
95// //
96// TGeoUnion - Boolean node representing a union between two components. //
97// //
98//////////////////////////////////////////////////////////////////////////////
99
100class TGeoUnion : public TGeoBoolNode {
101public:
102 // constructors
103 TGeoUnion();
104 TGeoUnion(const char *expr1, const char *expr2);
105 TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
106
107 // destructor
108 ~TGeoUnion() override;
109 // methods
110 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override;
111 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
112 Bool_t Contains(const Double_t *point) const override;
113 Int_t DistanceToPrimitive(Int_t px, Int_t py) override;
114 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
115 Double_t *safe = nullptr) const override;
116 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
117 Double_t *safe = nullptr) const override;
118 EGeoBoolType GetBooleanOperator() const override { return kGeoUnion; }
119 Int_t GetNpoints() override;
120 Double_t Safety(const Double_t *point, Bool_t in = kTRUE) const override;
121 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
122 void Sizeof3D() const override;
123
124 // CS specific
125 TGeoBoolNode *MakeClone() const override;
126 void Paint(Option_t *option) override;
127
128 ClassDefOverride(TGeoUnion, 1) // union node
129};
130
131//////////////////////////////////////////////////////////////////////////////
132// //
133// TGeoIntersection - Boolean node representing an intersection between two //
134// components. //
135// //
136//////////////////////////////////////////////////////////////////////////////
137
139public:
140 // constructors
142 TGeoIntersection(const char *expr1, const char *expr2);
143 TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
144
145 // destructor
146 ~TGeoIntersection() override;
147 // methods
148 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override;
149 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
150 Bool_t Contains(const Double_t *point) const override;
151 Int_t DistanceToPrimitive(Int_t px, Int_t py) override;
152 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
153 Double_t *safe = nullptr) const override;
154 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
155 Double_t *safe = nullptr) const override;
157 Int_t GetNpoints() override;
158 Double_t Safety(const Double_t *point, Bool_t in = kTRUE) const override;
159 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
160 void Sizeof3D() const override;
161
162 // CS specific
163 TGeoBoolNode *MakeClone() const override;
164 void Paint(Option_t *option) override;
165
166 ClassDefOverride(TGeoIntersection, 1) // intersection node
167};
168
169//////////////////////////////////////////////////////////////////////////////
170// //
171// TGeoSubtraction - Boolean node representing a subtraction. //
172// //
173//////////////////////////////////////////////////////////////////////////////
174
176public:
177 // constructors
179 TGeoSubtraction(const char *expr1, const char *expr2);
180 TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat = nullptr, TGeoMatrix *rmat = nullptr);
181
182 // destructor
183 ~TGeoSubtraction() override;
184 // methods
185 void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) override;
186 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
187 Bool_t Contains(const Double_t *point) const override;
188 Int_t DistanceToPrimitive(Int_t px, Int_t py) override;
189 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
190 Double_t *safe = nullptr) const override;
191 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = 0,
192 Double_t *safe = nullptr) const override;
194 Int_t GetNpoints() override;
195 Double_t Safety(const Double_t *point, Bool_t in = kTRUE) const override;
196 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
197 void Sizeof3D() const override;
198
199 // CS specific
200 TGeoBoolNode *MakeClone() const override;
201 void Paint(Option_t *option) override;
202
203 ClassDefOverride(TGeoSubtraction, 1) // subtraction node
204};
205
206#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Base class for Boolean operations between two shapes.
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
Bool_t MakeBranch(const char *expr, Bool_t left)
Mutex for thread data access.
TGeoMatrix * fLeftMat
void ClearThreadData() const
std::vector< ThreadData_t * > fThreadData
array of mesh points
~TGeoBoolNode() override
Destructor.
TGeoShape * fLeft
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
TGeoShape * GetLeftShape() const
void Paint(Option_t *option) override
Special schema for feeding the 3D buffers to the painter client.
TGeoMatrix * GetLeftMatrix() const
TGeoBoolNode(const TGeoBoolNode &)=delete
virtual void SetPoints(Double_t *points) const
Fill buffer with shape vertices.
Int_t fThreadSize
Navigation data per thread.
TGeoBoolNode & operator=(const TGeoBoolNode &)=delete
std::mutex fMutex
Size for the navigation data array.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
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
virtual Int_t GetNpoints()=0
Double_t * fPoints
number of points on the mesh
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
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
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:458
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.
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
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.
~TGeoIntersection() override
Destructor — deletion of components handled by TGeoManager class.
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:38
Base abstract class for all shapes.
Definition TGeoShape.h:25
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.
~TGeoSubtraction() override
Destructor — deletion of components handled by TGeoManager class.
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.
Int_t GetNpoints() override
Returns number of vertices for the composite shape described by this subtraction.
EGeoBoolType GetBooleanOperator() const override
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.
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
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() override
Destructor — deletion of components handled by TGeoManager class.
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:41