Logo ROOT   6.07/09
Reference Guide
TGeoShape.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Andrei Gheata 31/01/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_TGeoShape
13 #define ROOT_TGeoShape
14 
15 #ifndef ROOT_TNamed
16 #include "TNamed.h"
17 #endif
18 
19 // forward declarations
20 class TGeoBoolCombinator;
21 class TGeoBBox;
22 class TGeoMatrix;
23 class TGeoHMatrix;
24 class TGeoVolume;
25 class TBuffer3D;
26 
27 class TGeoShape : public TNamed
28 {
29 private:
30  static TGeoMatrix *fgTransform; // current transformation matrix that applies to shape
31  static Double_t fgEpsMch; // Machine round-off error
32 public:
33 enum EShapeType {
34  kBitMask32 = 0xffffffff,
36  kGeoBad = BIT(0),
37  kGeoRSeg = BIT(1),
40  kGeoVisX = BIT(4),
41  kGeoVisY = BIT(5),
42  kGeoVisZ = BIT(6),
45  kGeoTorus = BIT(9),
46  kGeoBox = BIT(10),
47  kGeoPara = BIT(11),
48  kGeoSph = BIT(12),
49  kGeoTube = BIT(13),
51  kGeoCone = BIT(15),
53  kGeoPcon = BIT(17),
54  kGeoPgon = BIT(18),
55  kGeoArb8 = BIT(19),
56  kGeoEltu = BIT(20),
57  kGeoTrap = BIT(21),
58  kGeoCtub = BIT(22),
59  kGeoTrd1 = BIT(23),
60  kGeoTrd2 = BIT(24),
61  kGeoComb = BIT(25),
63  kGeoXtru = BIT(27),
66  kGeoHype = BIT(30),
68 };
69  virtual void ClearThreadData() const {}
70  virtual void CreateThreadData(Int_t) {}
71 
72 protected :
73 // data members
74  Int_t fShapeId; // shape id
75  UInt_t fShapeBits; // shape bits
76 // methods
77  virtual void FillBuffer3D(TBuffer3D & buffer, Int_t reqSections, Bool_t localFrame) const;
78  Int_t GetBasicColor() const;
79  void SetOnBoundary(Bool_t /*flag=kTRUE*/) {;}
80  void TransformPoints(Double_t *points, UInt_t NbPoints) const;
81 
82 public:
83  // constructors
84  TGeoShape();
85  TGeoShape(const char *name);
86  // destructor
87  virtual ~TGeoShape();
88  // methods
89 
90  static Double_t Big() {return 1.E30;}
91  static TGeoMatrix *GetTransform();
92  static void SetTransform(TGeoMatrix *matrix);
93  static Double_t Tolerance() {return 1.E-10;}
94  static Double_t ComputeEpsMch();
95  static Double_t EpsMch();
96  virtual void AfterStreamer() {};
97  virtual Double_t Capacity() const = 0;
98  void CheckShape(Int_t testNo, Int_t nsamples=10000, Option_t *option="");
99  virtual void ComputeBBox() = 0;
100  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
101  virtual void ComputeNormal_v(const Double_t *, const Double_t *, Double_t *, Int_t) {}
102  virtual Bool_t Contains(const Double_t *point) const = 0;
103  virtual void Contains_v(const Double_t *, Bool_t *, Int_t) const {}
104  virtual Bool_t CouldBeCrossed(const Double_t *point, const Double_t *dir) const = 0;
105  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) = 0;
106  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
107  Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
108  virtual void DistFromInside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const {}
109  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
110  Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
111  virtual void DistFromOutside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const {}
112  static Double_t DistToPhiMin(const Double_t *point, const Double_t *dir, Double_t s1, Double_t c1, Double_t s2, Double_t c2,
113  Double_t sm, Double_t cm, Bool_t in=kTRUE);
114  virtual TGeoVolume *Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv,
115  Double_t start, Double_t step) = 0;
116  virtual void Draw(Option_t *option=""); // *MENU*
117  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
118  virtual const char *GetAxisName(Int_t iaxis) const = 0;
119  virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const = 0;
120  virtual void GetBoundingCylinder(Double_t *param) const = 0;
121  virtual const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
122  virtual Int_t GetByteCount() const = 0;
123  virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const = 0;
124  virtual Int_t GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const = 0;
125  Int_t GetId() const {return fShapeId;}
126  virtual TGeoShape *GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const = 0;
127  virtual void GetMeshNumbers(Int_t &/*nvert*/, Int_t &/*nsegs*/, Int_t &/*npols*/) const {;}
128  virtual const char *GetName() const;
129  virtual Int_t GetNmeshVertices() const {return 0;}
130  const char *GetPointerName() const;
131  virtual Bool_t IsAssembly() const {return kFALSE;}
132  virtual Bool_t IsComposite() const {return kFALSE;}
133  virtual Bool_t IsCylType() const = 0;
134  static Bool_t IsCloseToPhi(Double_t epsil, const Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
135  static Bool_t IsCrossingSemiplane(const Double_t *point, const Double_t *dir, Double_t cphi, Double_t sphi, Double_t &snext, Double_t &rxy);
138  static Bool_t IsInPhiRange(const Double_t *point, Double_t phi1, Double_t phi2);
139  virtual Bool_t IsReflected() const {return kFALSE;}
140  virtual Bool_t IsVecGeom() const {return kFALSE;}
143  virtual Bool_t IsValidBox() const = 0;
144  virtual void InspectShape() const = 0;
145  virtual TBuffer3D *MakeBuffer3D() const {return 0;}
146  static void NormalPhi(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
147  virtual void Paint(Option_t *option="");
148  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
149  virtual void Safety_v(const Double_t *, const Bool_t *, Double_t *, Int_t) const {}
150  static Double_t SafetyPhi(const Double_t *point, Bool_t in, Double_t phi1, Double_t phi2);
152  virtual void SetDimensions(Double_t *param) = 0;
153  void SetId(Int_t id) {fShapeId = id;}
154  virtual void SetPoints(Double_t *points) const = 0;
155  virtual void SetPoints(Float_t *points) const = 0;
156  virtual void SetSegsAndPols(TBuffer3D &buff) const = 0;
158  Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const;
159  virtual void Sizeof3D() const = 0;
160 
161  //----- bit manipulation
162  void SetShapeBit(UInt_t f, Bool_t set);
163  void SetShapeBit(UInt_t f) { fShapeBits |= f & kBitMask32; }
164  void ResetShapeBit(UInt_t f) { fShapeBits &= ~(f & kBitMask32); }
165  Bool_t TestShapeBit(UInt_t f) const { return (Bool_t) ((fShapeBits & f) != 0); }
166  Int_t TestShapeBits(UInt_t f) const { return (Int_t) (fShapeBits & f); }
167  void InvertShapeBit(UInt_t f) { fShapeBits ^= f & kBitMask32; }
168 
169  ClassDef(TGeoShape, 2) // base class for shapes
170 };
171 
172 #endif
173 
virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const =0
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fill the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections...
Definition: TGeoShape.cxx:591
void CheckShape(Int_t testNo, Int_t nsamples=10000, Option_t *option="")
Test for shape navigation methods.
Definition: TGeoShape.cxx:211
Bool_t IsRunTimeShape() const
Definition: TGeoShape.h:141
virtual void Safety_v(const Double_t *, const Bool_t *, Double_t *, Int_t) const
Definition: TGeoShape.h:149
virtual ~TGeoShape()
Destructor.
Definition: TGeoShape.cxx:198
virtual void SetDimensions(Double_t *param)=0
Box class.
Definition: TGeoBBox.h:19
static Double_t ComputeEpsMch()
Compute machine round-off double precision error as the smallest number that if added to 1...
Definition: TGeoShape.cxx:225
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute mouse actions on this shape.
Definition: TGeoShape.cxx:713
void SetOnBoundary(Bool_t)
Definition: TGeoShape.h:79
static Double_t EpsMch()
static function returning the machine round-off error
Definition: TGeoShape.cxx:242
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0
float Float_t
Definition: RtypesCore.h:53
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)=0
Computes distance from point (px,py) to the object.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
const char Option_t
Definition: RtypesCore.h:62
Geometrical transformation package.
Definition: TGeoMatrix.h:40
virtual void GetBoundingCylinder(Double_t *param) const =0
return c1
Definition: legend1.C:41
virtual void CreateThreadData(Int_t)
Definition: TGeoShape.h:70
Int_t GetBasicColor() const
Get the basic color (0-7).
Definition: TGeoShape.cxx:675
virtual Int_t GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const =0
virtual void ComputeNormal_v(const Double_t *, const Double_t *, Double_t *, Int_t)
Definition: TGeoShape.h:101
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:61
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:410
virtual void ClearThreadData() const
Definition: TGeoShape.h:69
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Bool_t IsCylType() const =0
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const =0
static Double_t SafetyPhi(const Double_t *point, Bool_t in, Double_t phi1, Double_t phi2)
Static method to compute safety w.r.t a phi corner defined by cosines/sines of the angles phi1...
Definition: TGeoShape.cxx:466
Int_t TestShapeBits(UInt_t f) const
Definition: TGeoShape.h:166
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
Definition: TGeoShape.cxx:328
static Double_t Tolerance()
Definition: TGeoShape.h:93
virtual Bool_t IsValidBox() const =0
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const =0
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const =0
static const double x2[5]
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
static Double_t fgEpsMch
Definition: TGeoShape.h:31
virtual void GetMeshNumbers(Int_t &, Int_t &, Int_t &) const
Definition: TGeoShape.h:127
static Bool_t IsCrossingSemiplane(const Double_t *point, const Double_t *dir, Double_t cphi, Double_t sphi, Double_t &snext, Double_t &rxy)
Compute distance from POINT to semiplane defined by PHI angle along DIR.
Definition: TGeoShape.cxx:299
static const double x4[22]
static TGeoMatrix * fgTransform
Definition: TGeoShape.h:30
virtual void DistFromInside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const
Definition: TGeoShape.h:108
void SetId(Int_t id)
Definition: TGeoShape.h:153
XFontStruct * id
Definition: TGX11.cxx:108
static void SetTransform(TGeoMatrix *matrix)
Set current transformation matrix that applies to shape.
Definition: TGeoShape.cxx:546
virtual Bool_t IsVecGeom() const
Definition: TGeoShape.h:140
static Double_t SafetySeg(Double_t r, Double_t z, Double_t r1, Double_t z1, Double_t r2, Double_t z2, Bool_t outer)
Compute distance from point of coordinates (r,z) to segment (r1,z1):(r2,z2)
Definition: TGeoShape.cxx:496
point * points
Definition: X3DBuffer.c:20
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)
Check if segments (A,B) and (C,D) are crossing, where: A(x1,y1), B(x2,y2), C(x3,y3), D(x4,y4)
Definition: TGeoShape.cxx:338
virtual Int_t GetNmeshVertices() const
Definition: TGeoShape.h:129
TGeoShape()
Default constructor.
Definition: TGeoShape.cxx:167
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
Definition: TGeoShape.cxx:554
virtual void AfterStreamer()
Definition: TGeoShape.h:96
Base abstract class for all shapes.
Definition: TGeoShape.h:27
TRandom2 r(17)
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
void ResetShapeBit(UInt_t f)
Definition: TGeoShape.h:164
static Double_t DistToPhiMin(const Double_t *point, const Double_t *dir, Double_t s1, Double_t c1, Double_t s2, Double_t c2, Double_t sm, Double_t cm, Bool_t in=kTRUE)
compute distance from point (inside phi) to both phi planes. Return minimum.
Definition: TGeoShape.cxx:407
virtual TBuffer3D * MakeBuffer3D() const
Definition: TGeoShape.h:145
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Int_t GetByteCount() const =0
static Bool_t IsInPhiRange(const Double_t *point, Double_t phi1, Double_t phi2)
Static method to check if a point is in the phi range (phi1, phi2) [degrees].
Definition: TGeoShape.cxx:285
Generic 3D primitive description class.
Definition: TBuffer3D.h:19
virtual void SetSegsAndPols(TBuffer3D &buff) const =0
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:250
Int_t GetId() const
Definition: TGeoShape.h:125
virtual void InspectShape() const =0
virtual Bool_t IsReflected() const
Definition: TGeoShape.h:139
virtual Bool_t Contains(const Double_t *point) const =0
virtual const char * GetAxisName(Int_t iaxis) const =0
static Bool_t IsCloseToPhi(Double_t epsil, const Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
True if point is closer than epsil to one of the phi planes defined by c1,s1 or c2,s2.
Definition: TGeoShape.cxx:271
return c2
Definition: legend2.C:14
static const double x1[5]
double f(double x)
Int_t fShapeId
Definition: TGeoShape.h:74
double Double_t
Definition: RtypesCore.h:55
virtual void Contains_v(const Double_t *, Bool_t *, Int_t) const
Definition: TGeoShape.h:103
virtual void Sizeof3D() const =0
virtual Bool_t IsComposite() const
Definition: TGeoShape.h:132
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
Definition: TGeoShape.cxx:261
Bool_t IsValid() const
Definition: TGeoShape.h:142
#define snext(osub1, osub2)
Definition: triangle.c:1167
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)=0
virtual void ComputeBBox()=0
const char * GetPointerName() const
Provide a pointer name containing uid.
Definition: TGeoShape.cxx:701
static Double_t Big()
Definition: TGeoShape.h:90
void SetRuntime(Bool_t flag=kTRUE)
Definition: TGeoShape.h:157
#define BIT(n)
Definition: Rtypes.h:120
static TGeoMatrix * GetTransform()
Returns current transformation matrix that applies to shape.
Definition: TGeoShape.cxx:538
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
Definition: TGeoShape.cxx:526
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Bool_t TestShapeBit(UInt_t f) const
Definition: TGeoShape.h:165
virtual void DistFromOutside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const
Definition: TGeoShape.h:111
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const =0
virtual void SetPoints(Double_t *points) const =0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual Bool_t CouldBeCrossed(const Double_t *point, const Double_t *dir) const =0
static void NormalPhi(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
Static method to compute normal to phi planes.
Definition: TGeoShape.cxx:439
virtual Double_t Capacity() const =0
void SetShapeBit(UInt_t f)
Definition: TGeoShape.h:163
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Stub implementation to avoid forcing implementation at this stage.
Definition: TGeoShape.cxx:691
virtual void Paint(Option_t *option="")
Paint this shape.
Definition: TGeoShape.cxx:736
void InvertShapeBit(UInt_t f)
Definition: TGeoShape.h:167
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:723
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Bool_t IsAssembly() const
Definition: TGeoShape.h:131
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322
char name[80]
Definition: TGX11.cxx:109
UInt_t fShapeBits
Definition: TGeoShape.h:75
static const double x3[11]