00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #ifndef ROOT_TGeoBoolNode
00013 #define ROOT_TGeoBoolNode
00014 
00015 #ifndef ROOT_TObject
00016 #include "TObject.h"
00017 #endif
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 class TGeoShape;
00030 class TGeoMatrix;
00031 class TGeoHMatrix;
00032 
00033 class TGeoBoolNode : public TObject
00034 {
00035 public:
00036 enum EGeoBoolType {
00037    kGeoUnion,
00038    kGeoIntersection,
00039    kGeoSubtraction
00040 };
00041 private:
00042    TGeoBoolNode(const TGeoBoolNode&); 
00043    TGeoBoolNode& operator=(const TGeoBoolNode&); 
00044 
00045 protected:
00046    Int_t             fSelected;       
00047    TGeoShape        *fLeft;           
00048    TGeoShape        *fRight;          
00049    TGeoMatrix       *fLeftMat;        
00050    TGeoMatrix       *fRightMat;       
00051    Int_t             fNpoints;        
00052    Double_t         *fPoints;         
00053 
00054    Bool_t            MakeBranch(const char *expr, Bool_t left);
00055 public:
00056    
00057    TGeoBoolNode();
00058    TGeoBoolNode(const char *expr1, const char *expr2);
00059    TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00060 
00061    
00062    virtual ~TGeoBoolNode();
00063    
00064    virtual void      ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin) = 0;
00065    virtual void      ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm) = 0;
00066    virtual Bool_t    Contains(Double_t *point) const         = 0;
00067    virtual Int_t     DistanceToPrimitive(Int_t px, Int_t py) = 0;
00068    virtual Double_t  DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1,
00069                                Double_t step=0, Double_t *safe=0) const = 0;
00070    virtual Double_t  DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1,
00071                                Double_t step=0, Double_t *safe=0) const = 0;
00072    virtual EGeoBoolType GetBooleanOperator() const = 0;
00073    virtual Int_t     GetNpoints() = 0;
00074    TGeoMatrix       *GetLeftMatrix() const {return fLeftMat;}
00075    TGeoMatrix       *GetRightMatrix() const {return fRightMat;}
00076    TGeoShape        *GetLeftShape() const {return fLeft;}
00077    TGeoShape        *GetRightShape() const {return fRight;}
00078    virtual void      Paint(Option_t *option);
00079    void              RegisterMatrices();
00080    virtual Double_t  Safety(Double_t *point, Bool_t in=kTRUE) const = 0;
00081    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00082    virtual void      SetPoints(Double_t *points) const;
00083    virtual void      SetPoints(Float_t *points)  const;
00084    void              SetSelected(Int_t sel) {fSelected = sel;}
00085    virtual void      Sizeof3D() const;
00086 
00087    ClassDef(TGeoBoolNode, 1)              
00088 };
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 class TGeoUnion : public TGeoBoolNode
00097 {
00098 public:
00099    
00100    TGeoUnion();
00101    TGeoUnion(const char *expr1, const char *expr2);
00102    TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00103 
00104    
00105    virtual ~TGeoUnion();
00106    
00107    virtual void      ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
00108    virtual void      ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm);
00109    virtual Bool_t    Contains(Double_t *point) const;
00110    virtual Int_t     DistanceToPrimitive(Int_t px, Int_t py);
00111    virtual Double_t  DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1,
00112                                Double_t step=0, Double_t *safe=0) const;
00113    virtual Double_t  DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1,
00114                                Double_t step=0, Double_t *safe=0) const;
00115    virtual EGeoBoolType GetBooleanOperator() const {return kGeoUnion;}
00116    virtual Int_t     GetNpoints();
00117    virtual Double_t  Safety(Double_t *point, Bool_t in=kTRUE) const;
00118    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00119    virtual void      Sizeof3D() const;
00120 
00121    
00122    virtual void      Paint(Option_t *option);
00123 
00124    ClassDef(TGeoUnion, 1)              
00125 };
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 class TGeoIntersection : public TGeoBoolNode
00135 {
00136 public:
00137    
00138    TGeoIntersection();
00139    TGeoIntersection(const char *expr1, const char *expr2);
00140    TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00141 
00142    
00143    virtual ~TGeoIntersection();
00144    
00145    virtual void      ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
00146    virtual void      ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm);
00147    virtual Bool_t    Contains(Double_t *point) const;
00148    virtual Int_t     DistanceToPrimitive(Int_t px, Int_t py);
00149    virtual Double_t  DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1,
00150                                Double_t step=0, Double_t *safe=0) const;
00151    virtual Double_t  DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1,
00152                                Double_t step=0, Double_t *safe=0) const;
00153    virtual EGeoBoolType GetBooleanOperator() const {return kGeoIntersection;}
00154    virtual Int_t     GetNpoints();
00155    virtual Double_t  Safety(Double_t *point, Bool_t in=kTRUE) const;
00156    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00157    virtual void      Sizeof3D() const;
00158 
00159    
00160    virtual void      Paint(Option_t *option);
00161 
00162    ClassDef(TGeoIntersection, 1)              
00163 };
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 class TGeoSubtraction : public TGeoBoolNode
00172 {
00173 public:
00174    
00175    TGeoSubtraction();
00176    TGeoSubtraction(const char *expr1, const char *expr2);
00177    TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00178 
00179    
00180    virtual ~TGeoSubtraction();
00181    
00182    virtual void      ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin);
00183    virtual void      ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm);
00184    virtual Bool_t    Contains(Double_t *point) const;
00185    virtual Int_t     DistanceToPrimitive(Int_t px, Int_t py);
00186    virtual Double_t  DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1,
00187                                Double_t step=0, Double_t *safe=0) const;
00188    virtual Double_t  DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1,
00189                                Double_t step=0, Double_t *safe=0) const;
00190    virtual EGeoBoolType GetBooleanOperator() const {return kGeoSubtraction;}
00191    virtual Int_t     GetNpoints();
00192    virtual Double_t  Safety(Double_t *point, Bool_t in=kTRUE) const;
00193    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00194    virtual void      Sizeof3D() const;
00195 
00196    
00197    virtual void      Paint(Option_t *option);
00198 
00199    ClassDef(TGeoSubtraction, 1)              
00200 };
00201 #endif
00202