00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGeoShape
00013 #define ROOT_TGeoShape
00014
00015 #ifndef ROOT_TNamed
00016 #include "TNamed.h"
00017 #endif
00018
00019
00020 class TGeoBoolCombinator;
00021 class TGeoBBox;
00022 class TGeoMatrix;
00023 class TGeoHMatrix;
00024 class TGeoVolume;
00025 class TBuffer3D;
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class TGeoShape : public TNamed
00036 {
00037 private:
00038 static TGeoMatrix *fgTransform;
00039 static Double_t fgEpsMch;
00040 public:
00041 enum EShapeType {
00042 kBitMask32 = 0xffffffff,
00043 kGeoNoShape = 0,
00044 kGeoBad = BIT(0),
00045 kGeoRSeg = BIT(1),
00046 kGeoPhiSeg = BIT(2),
00047 kGeoThetaSeg = BIT(3),
00048 kGeoVisX = BIT(4),
00049 kGeoVisY = BIT(5),
00050 kGeoVisZ = BIT(6),
00051 kGeoRunTimeShape = BIT(7),
00052 kGeoInvalidShape = BIT(8),
00053 kGeoTorus = BIT(9),
00054 kGeoBox = BIT(10),
00055 kGeoPara = BIT(11),
00056 kGeoSph = BIT(12),
00057 kGeoTube = BIT(13),
00058 kGeoTubeSeg = BIT(14),
00059 kGeoCone = BIT(15),
00060 kGeoConeSeg = BIT(16),
00061 kGeoPcon = BIT(17),
00062 kGeoPgon = BIT(18),
00063 kGeoArb8 = BIT(19),
00064 kGeoEltu = BIT(20),
00065 kGeoTrap = BIT(21),
00066 kGeoCtub = BIT(22),
00067 kGeoTrd1 = BIT(23),
00068 kGeoTrd2 = BIT(24),
00069 kGeoComb = BIT(25),
00070 kGeoClosedShape = BIT(26),
00071 kGeoXtru = BIT(27),
00072 kGeoParaboloid = BIT(28),
00073 kGeoHalfSpace = BIT(29),
00074 kGeoHype = BIT(30),
00075 kGeoSavePrimitive = BIT(20)
00076 };
00077
00078 protected :
00079
00080 Int_t fShapeId;
00081 UInt_t fShapeBits;
00082
00083 virtual void FillBuffer3D(TBuffer3D & buffer, Int_t reqSections, Bool_t localFrame) const;
00084 Int_t GetBasicColor() const;
00085 void SetOnBoundary(Bool_t ) {;}
00086 void TransformPoints(Double_t *points, UInt_t NbPoints) const;
00087
00088 public:
00089
00090 TGeoShape();
00091 TGeoShape(const char *name);
00092
00093 virtual ~TGeoShape();
00094
00095
00096 static Double_t Big() {return 1.E30;}
00097 static TGeoMatrix *GetTransform();
00098 static void SetTransform(TGeoMatrix *matrix);
00099 static Double_t Tolerance() {return 1.E-10;}
00100 static Double_t ComputeEpsMch();
00101 static Double_t EpsMch();
00102 virtual Double_t Capacity() const = 0;
00103 virtual void ComputeBBox() = 0;
00104 virtual void ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm) = 0;
00105 virtual Bool_t Contains(Double_t *point) const = 0;
00106 virtual Bool_t CouldBeCrossed(Double_t *point, Double_t *dir) const = 0;
00107 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) = 0;
00108 virtual Double_t DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1,
00109 Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
00110 virtual Double_t DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1,
00111 Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
00112 static Double_t DistToPhiMin(Double_t *point, Double_t *dir, Double_t s1, Double_t c1, Double_t s2, Double_t c2,
00113 Double_t sm, Double_t cm, Bool_t in=kTRUE);
00114 virtual TGeoVolume *Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv,
00115 Double_t start, Double_t step) = 0;
00116 virtual void Draw(Option_t *option="");
00117 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00118 virtual const char *GetAxisName(Int_t iaxis) const = 0;
00119 virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const = 0;
00120 virtual void GetBoundingCylinder(Double_t *param) const = 0;
00121 virtual const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
00122 virtual Int_t GetByteCount() const = 0;
00123 virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const = 0;
00124 virtual Int_t GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const = 0;
00125 Int_t GetId() const {return fShapeId;}
00126 virtual TGeoShape *GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const = 0;
00127 virtual void GetMeshNumbers(Int_t &, Int_t &, Int_t &) const {;}
00128 virtual const char *GetName() const;
00129 virtual Int_t GetNmeshVertices() const {return 0;}
00130 const char *GetPointerName() const;
00131 virtual Bool_t IsAssembly() const {return kFALSE;}
00132 virtual Bool_t IsComposite() const {return kFALSE;}
00133 virtual Bool_t IsCylType() const = 0;
00134 static Bool_t IsCloseToPhi(Double_t epsil, Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
00135 static Bool_t IsCrossingSemiplane(Double_t *point, Double_t *dir, Double_t cphi, Double_t sphi, Double_t &snext, Double_t &rxy);
00136 static Bool_t IsSameWithinTolerance(Double_t a, Double_t b);
00137 static Bool_t IsSegCrossing(Double_t x1, Double_t y1, Double_t x2, Double_t y2,Double_t x3, Double_t y3,Double_t x4, Double_t y4);
00138 static Bool_t IsInPhiRange(Double_t *point, Double_t phi1, Double_t phi2);
00139 virtual Bool_t IsReflected() const {return kFALSE;}
00140 Bool_t IsRunTimeShape() const {return TestShapeBit(kGeoRunTimeShape);}
00141 Bool_t IsValid() const {return !TestShapeBit(kGeoInvalidShape);}
00142 virtual Bool_t IsValidBox() const = 0;
00143 virtual void InspectShape() const = 0;
00144 virtual TBuffer3D *MakeBuffer3D() const {return 0;}
00145 static void NormalPhi(Double_t *point, Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
00146 virtual void Paint(Option_t *option="");
00147 virtual Double_t Safety(Double_t *point, Bool_t in=kTRUE) const = 0;
00148 static Double_t SafetyPhi(Double_t *point, Bool_t in, Double_t phi1, Double_t phi2);
00149 virtual void SetDimensions(Double_t *param) = 0;
00150 void SetId(Int_t id) {fShapeId = id;}
00151 virtual void SetPoints(Double_t *points) const = 0;
00152 virtual void SetPoints(Float_t *points) const = 0;
00153 virtual void SetSegsAndPols(TBuffer3D &buff) const = 0;
00154 void SetRuntime(Bool_t flag=kTRUE) {SetShapeBit(kGeoRunTimeShape, flag);}
00155 Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const;
00156 virtual void Sizeof3D() const = 0;
00157
00158
00159 void SetShapeBit(UInt_t f, Bool_t set);
00160 void SetShapeBit(UInt_t f) { fShapeBits |= f & kBitMask32; }
00161 void ResetShapeBit(UInt_t f) { fShapeBits &= ~(f & kBitMask32); }
00162 Bool_t TestShapeBit(UInt_t f) const { return (Bool_t) ((fShapeBits & f) != 0); }
00163 Int_t TestShapeBits(UInt_t f) const { return (Int_t) (fShapeBits & f); }
00164 void InvertShapeBit(UInt_t f) { fShapeBits ^= f & kBitMask32; }
00165
00166 ClassDef(TGeoShape, 2)
00167 };
00168
00169 #endif
00170