TGeoBoolNode.h

Go to the documentation of this file.
00001 // @(#):$Id: TGeoBoolNode.h 32690 2010-03-21 08:47:56Z brun $
00002 // Author: Andrei Gheata   30/05/02
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 // TGeoBoolNode - Base class for boolean nodes. A boolean node has pointers //
00022 //  to two shapes having two transformations with respect to the mother     //
00023 //  composite shape they belong to. It represents the boolean operation     //
00024 //  between the two component shapes.                                       //
00025 //                                                                          //
00026 //////////////////////////////////////////////////////////////////////////////
00027 
00028 // forward declarations
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&); // Not implemented
00043    TGeoBoolNode& operator=(const TGeoBoolNode&); // Not implemented
00044 
00045 protected:
00046    Int_t             fSelected;       // ! selected branch
00047    TGeoShape        *fLeft;           // shape on the left branch
00048    TGeoShape        *fRight;          // shape on the right branch
00049    TGeoMatrix       *fLeftMat;        // transformation that applies to the left branch
00050    TGeoMatrix       *fRightMat;       // transformation that applies to the right branch
00051    Int_t             fNpoints;        //! number of points on the mesh
00052    Double_t         *fPoints;         //! array of mesh points
00053 // methods
00054    Bool_t            MakeBranch(const char *expr, Bool_t left);
00055 public:
00056    // constructors
00057    TGeoBoolNode();
00058    TGeoBoolNode(const char *expr1, const char *expr2);
00059    TGeoBoolNode(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00060 
00061    // destructor
00062    virtual ~TGeoBoolNode();
00063    // methods
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)              // a boolean node
00088 };
00089 
00090 //////////////////////////////////////////////////////////////////////////////
00091 //                                                                          //
00092 // TGeoUnion - Boolean node representing a union between two components.    //
00093 //                                                                          //
00094 //////////////////////////////////////////////////////////////////////////////
00095 
00096 class TGeoUnion : public TGeoBoolNode
00097 {
00098 public:
00099    // constructors
00100    TGeoUnion();
00101    TGeoUnion(const char *expr1, const char *expr2);
00102    TGeoUnion(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00103 
00104    // destructor
00105    virtual ~TGeoUnion();
00106    // methods
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    //CS specific
00122    virtual void      Paint(Option_t *option);
00123 
00124    ClassDef(TGeoUnion, 1)              // union node
00125 };
00126 
00127 //////////////////////////////////////////////////////////////////////////////
00128 //                                                                          //
00129 // TGeoIntersection - Boolean node representing an intersection between two //
00130 // components.                                                              //
00131 //                                                                          //
00132 //////////////////////////////////////////////////////////////////////////////
00133 
00134 class TGeoIntersection : public TGeoBoolNode
00135 {
00136 public:
00137    // constructors
00138    TGeoIntersection();
00139    TGeoIntersection(const char *expr1, const char *expr2);
00140    TGeoIntersection(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00141 
00142    // destructor
00143    virtual ~TGeoIntersection();
00144    // methods
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    //CS specific
00160    virtual void      Paint(Option_t *option);
00161 
00162    ClassDef(TGeoIntersection, 1)              // intersection node
00163 };
00164 
00165 //////////////////////////////////////////////////////////////////////////////
00166 //                                                                          //
00167 // TGeoSubtraction - Boolean node representing a subtraction.               //
00168 //                                                                          //
00169 //////////////////////////////////////////////////////////////////////////////
00170 
00171 class TGeoSubtraction : public TGeoBoolNode
00172 {
00173 public:
00174    // constructors
00175    TGeoSubtraction();
00176    TGeoSubtraction(const char *expr1, const char *expr2);
00177    TGeoSubtraction(TGeoShape *left, TGeoShape *right, TGeoMatrix *lmat=0, TGeoMatrix *rmat=0);
00178 
00179    // destructor
00180    virtual ~TGeoSubtraction();
00181    // methods
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    //CS specific
00197    virtual void      Paint(Option_t *option);
00198 
00199    ClassDef(TGeoSubtraction, 1)              // subtraction node
00200 };
00201 #endif
00202 

Generated on Tue Jul 5 14:12:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1