#ifndef ROOT_TGeoBoolNode
#define ROOT_TGeoBoolNode
#ifndef ROOT_TObject
#include "TObject.h"
#endif
class TGeoShape;
class TGeoMatrix;
class TGeoHMatrix;
class TGeoBoolNode : public TObject
{
public:
enum EGeoBoolType {
kGeoUnion,
kGeoIntersection,
kGeoSubtraction
};
struct ThreadData_t
{
Int_t fSelected;
ThreadData_t();
~ThreadData_t();
};
ThreadData_t& GetThreadData() const;
void ClearThreadData() const;
void CreateThreadData(Int_t nthreads);
private:
TGeoBoolNode(const TGeoBoolNode&);
TGeoBoolNode& operator=(const TGeoBoolNode&);
protected:
TGeoShape *fLeft;
TGeoShape *fRight;
TGeoMatrix *fLeftMat;
TGeoMatrix *fRightMat;
Int_t fNpoints;
Double_t *fPoints;
mutable std::vector<ThreadData_t*> fThreadData;
mutable Int_t fThreadSize;
Bool_t MakeBranch(const char *expr, Bool_t left);
public:
TGeoBoolNode();
TGeoBoolNode(const char *expr1, const char *expr2);
TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
virtual ~TGeoBoolNode();
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
virtual Bool_t Contains(const Double_t *point) const = 0;
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py) = 0;
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;
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;
virtual Int_t GetNpoints() = 0;
TGeoMatrix *GetLeftMatrix() const {return fLeftMat;}
TGeoMatrix *GetRightMatrix() const {return fRightMat;}
TGeoShape *GetLeftShape() const {return fLeft;}
TGeoShape *GetRightShape() const {return fRight;}
virtual TGeoBoolNode *MakeClone() const = 0;
virtual void Paint(Option_t *option);
void RegisterMatrices();
Bool_t ReplaceMatrix(TGeoMatrix *mat, TGeoMatrix *newmat);
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void SetPoints(Double_t *points) const;
virtual void SetPoints(Float_t *points) const;
void SetSelected(Int_t sel);
virtual void Sizeof3D() const;
ClassDef(TGeoBoolNode, 1)
};
class TGeoUnion : public TGeoBoolNode
{
public:
TGeoUnion();
TGeoUnion(const char *expr1, const char *expr2);
TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
virtual ~TGeoUnion();
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
virtual Bool_t Contains(const Double_t *point) const;
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
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;
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;
virtual EGeoBoolType GetBooleanOperator() const {return kGeoUnion;}
virtual Int_t GetNpoints();
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void Sizeof3D() const;
virtual TGeoBoolNode *MakeClone() const;
virtual void Paint(Option_t *option);
ClassDef(TGeoUnion, 1)
};
class TGeoIntersection : public TGeoBoolNode
{
public:
TGeoIntersection();
TGeoIntersection(const char *expr1, const char *expr2);
TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
virtual ~TGeoIntersection();
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
virtual Bool_t Contains(const Double_t *point) const;
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
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;
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;
virtual EGeoBoolType GetBooleanOperator() const {return kGeoIntersection;}
virtual Int_t GetNpoints();
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void Sizeof3D() const;
virtual TGeoBoolNode *MakeClone() const;
virtual void Paint(Option_t *option);
ClassDef(TGeoIntersection, 1)
};
class TGeoSubtraction : public TGeoBoolNode
{
public:
TGeoSubtraction();
TGeoSubtraction(const char *expr1, const char *expr2);
TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
virtual ~TGeoSubtraction();
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
virtual Bool_t Contains(const Double_t *point) const;
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py);
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;
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;
virtual EGeoBoolType GetBooleanOperator() const {return kGeoSubtraction;}
virtual Int_t GetNpoints();
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void Sizeof3D() const;
virtual TGeoBoolNode *MakeClone() const;
virtual void Paint(Option_t *option);
ClassDef(TGeoSubtraction, 1)
};
#endif