ROOT  6.06/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 ////////////////////////////////////////////////////////////////////////////
28 // //
29 // TGeoShape - base class for geometric shapes. Provides virtual methods //
30 // for point and segment classification that has to be implemented by //
31 // all classes inheriting from it. //
32 // //
33 ////////////////////////////////////////////////////////////////////////////
34 
35 class TGeoShape : public TNamed
36 {
37 private:
38  static TGeoMatrix *fgTransform; // current transformation matrix that applies to shape
39  static Double_t fgEpsMch; // Machine round-off error
40 public:
41 enum EShapeType {
42  kBitMask32 = 0xffffffff,
44  kGeoBad = BIT(0),
45  kGeoRSeg = BIT(1),
48  kGeoVisX = BIT(4),
49  kGeoVisY = BIT(5),
50  kGeoVisZ = BIT(6),
53  kGeoTorus = BIT(9),
54  kGeoBox = BIT(10),
55  kGeoPara = BIT(11),
56  kGeoSph = BIT(12),
57  kGeoTube = BIT(13),
59  kGeoCone = BIT(15),
61  kGeoPcon = BIT(17),
62  kGeoPgon = BIT(18),
63  kGeoArb8 = BIT(19),
64  kGeoEltu = BIT(20),
65  kGeoTrap = BIT(21),
66  kGeoCtub = BIT(22),
67  kGeoTrd1 = BIT(23),
68  kGeoTrd2 = BIT(24),
69  kGeoComb = BIT(25),
71  kGeoXtru = BIT(27),
74  kGeoHype = BIT(30),
76 };
77  virtual void ClearThreadData() const {}
78  virtual void CreateThreadData(Int_t) {}
79 
80 protected :
81 // data members
82  Int_t fShapeId; // shape id
83  UInt_t fShapeBits; // shape bits
84 // methods
85  virtual void FillBuffer3D(TBuffer3D & buffer, Int_t reqSections, Bool_t localFrame) const;
86  Int_t GetBasicColor() const;
87  void SetOnBoundary(Bool_t /*flag=kTRUE*/) {;}
88  void TransformPoints(Double_t *points, UInt_t NbPoints) const;
89 
90 public:
91  // constructors
92  TGeoShape();
93  TGeoShape(const char *name);
94  // destructor
95  virtual ~TGeoShape();
96  // methods
97 
98  static Double_t Big() {return 1.E30;}
99  static TGeoMatrix *GetTransform();
100  static void SetTransform(TGeoMatrix *matrix);
101  static Double_t Tolerance() {return 1.E-10;}
102  static Double_t ComputeEpsMch();
103  static Double_t EpsMch();
104  virtual void AfterStreamer() {};
105  virtual Double_t Capacity() const = 0;
106  void CheckShape(Int_t testNo, Int_t nsamples=10000, Option_t *option="");
107  virtual void ComputeBBox() = 0;
108  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) = 0;
109  virtual void ComputeNormal_v(const Double_t *, const Double_t *, Double_t *, Int_t) {}
110  virtual Bool_t Contains(const Double_t *point) const = 0;
111  virtual void Contains_v(const Double_t *, Bool_t *, Int_t) const {}
112  virtual Bool_t CouldBeCrossed(const Double_t *point, const Double_t *dir) const = 0;
113  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) = 0;
114  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
115  Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
116  virtual void DistFromInside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const {}
117  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
118  Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
119  virtual void DistFromOutside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const {}
120  static Double_t DistToPhiMin(const Double_t *point, const Double_t *dir, Double_t s1, Double_t c1, Double_t s2, Double_t c2,
121  Double_t sm, Double_t cm, Bool_t in=kTRUE);
122  virtual TGeoVolume *Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv,
123  Double_t start, Double_t step) = 0;
124  virtual void Draw(Option_t *option=""); // *MENU*
125  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
126  virtual const char *GetAxisName(Int_t iaxis) const = 0;
127  virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const = 0;
128  virtual void GetBoundingCylinder(Double_t *param) const = 0;
129  virtual const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
130  virtual Int_t GetByteCount() const = 0;
131  virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const = 0;
132  virtual Int_t GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const = 0;
133  Int_t GetId() const {return fShapeId;}
134  virtual TGeoShape *GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const = 0;
135  virtual void GetMeshNumbers(Int_t &/*nvert*/, Int_t &/*nsegs*/, Int_t &/*npols*/) const {;}
136  virtual const char *GetName() const;
137  virtual Int_t GetNmeshVertices() const {return 0;}
138  const char *GetPointerName() const;
139  virtual Bool_t IsAssembly() const {return kFALSE;}
140  virtual Bool_t IsComposite() const {return kFALSE;}
141  virtual Bool_t IsCylType() const = 0;
142  static Bool_t IsCloseToPhi(Double_t epsil, const Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
143  static Bool_t IsCrossingSemiplane(const Double_t *point, const Double_t *dir, Double_t cphi, Double_t sphi, Double_t &snext, Double_t &rxy);
146  static Bool_t IsInPhiRange(const Double_t *point, Double_t phi1, Double_t phi2);
147  virtual Bool_t IsReflected() const {return kFALSE;}
150  virtual Bool_t IsValidBox() const = 0;
151  virtual void InspectShape() const = 0;
152  virtual TBuffer3D *MakeBuffer3D() const {return 0;}
153  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);
154  virtual void Paint(Option_t *option="");
155  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const = 0;
156  virtual void Safety_v(const Double_t *, const Bool_t *, Double_t *, Int_t) const {}
157  static Double_t SafetyPhi(const Double_t *point, Bool_t in, Double_t phi1, Double_t phi2);
159  virtual void SetDimensions(Double_t *param) = 0;
160  void SetId(Int_t id) {fShapeId = id;}
161  virtual void SetPoints(Double_t *points) const = 0;
162  virtual void SetPoints(Float_t *points) const = 0;
163  virtual void SetSegsAndPols(TBuffer3D &buff) const = 0;
165  Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const;
166  virtual void Sizeof3D() const = 0;
167 
168  //----- bit manipulation
169  void SetShapeBit(UInt_t f, Bool_t set);
170  void SetShapeBit(UInt_t f) { fShapeBits |= f & kBitMask32; }
171  void ResetShapeBit(UInt_t f) { fShapeBits &= ~(f & kBitMask32); }
172  Bool_t TestShapeBit(UInt_t f) const { return (Bool_t) ((fShapeBits & f) != 0); }
173  Int_t TestShapeBits(UInt_t f) const { return (Int_t) (fShapeBits & f); }
174  void InvertShapeBit(UInt_t f) { fShapeBits ^= f & kBitMask32; }
175 
176  ClassDef(TGeoShape, 2) // base class for shapes
177 };
178 
179 #endif
180 
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:587
void CheckShape(Int_t testNo, Int_t nsamples=10000, Option_t *option="")
Test for shape navigation methods.
Definition: TGeoShape.cxx:208
Bool_t IsRunTimeShape() const
Definition: TGeoShape.h:148
virtual void Sizeof3D() const =0
virtual void Safety_v(const Double_t *, const Bool_t *, Double_t *, Int_t) const
Definition: TGeoShape.h:156
virtual ~TGeoShape()
Destructor.
Definition: TGeoShape.cxx:195
virtual void SetDimensions(Double_t *param)=0
#define snext(osub1, osub2)
Definition: triangle.c:1167
static Double_t ComputeEpsMch()
Compute machine round-off double precision error as the smallest number that if added to 1...
Definition: TGeoShape.cxx:222
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute mouse actions on this shape.
Definition: TGeoShape.cxx:709
void SetOnBoundary(Bool_t)
Definition: TGeoShape.h:87
static Double_t EpsMch()
static function returning the machine round-off error
Definition: TGeoShape.cxx:239
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.
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t GetByteCount() const =0
TCanvas * c1
Definition: legend1.C:2
virtual void CreateThreadData(Int_t)
Definition: TGeoShape.h:78
Int_t GetBasicColor() const
Get the basic color (0-7).
Definition: TGeoShape.cxx:671
#define BIT(n)
Definition: Rtypes.h:120
virtual void ComputeNormal_v(const Double_t *, const Double_t *, Double_t *, Int_t)
Definition: TGeoShape.h:109
virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const =0
virtual void ClearThreadData() const
Definition: TGeoShape.h:77
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const =0
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
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:463
Int_t TestShapeBits(UInt_t f) const
Definition: TGeoShape.h:173
virtual void GetBoundingCylinder(Double_t *param) const =0
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
Definition: TGeoShape.cxx:325
static Double_t Tolerance()
Definition: TGeoShape.h:101
virtual Bool_t Contains(const Double_t *point) 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:39
virtual void GetMeshNumbers(Int_t &, Int_t &, Int_t &) const
Definition: TGeoShape.h: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)
Compute distance from POINT to semiplane defined by PHI angle along DIR.
Definition: TGeoShape.cxx:296
static const double x4[22]
virtual void DistFromInside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const
Definition: TGeoShape.h:116
void SetId(Int_t id)
Definition: TGeoShape.h:160
XFontStruct * id
Definition: TGX11.cxx:108
virtual void SetSegsAndPols(TBuffer3D &buff) const =0
static void SetTransform(TGeoMatrix *matrix)
Set current transformation matrix that applies to shape.
Definition: TGeoShape.cxx:542
virtual Bool_t IsValidBox() const =0
virtual void SetPoints(Double_t *points) const =0
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:493
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:335
virtual Int_t GetNmeshVertices() const
Definition: TGeoShape.h:137
TGeoShape()
Default constructor.
Definition: TGeoShape.cxx:164
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
Definition: TGeoShape.cxx:550
virtual Bool_t CouldBeCrossed(const Double_t *point, const Double_t *dir) const =0
virtual void AfterStreamer()
Definition: TGeoShape.h:104
ROOT::R::TRInterface & r
Definition: Object.C:4
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
void ResetShapeBit(UInt_t f)
Definition: TGeoShape.h:171
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:404
virtual TBuffer3D * MakeBuffer3D() const
Definition: TGeoShape.h:152
unsigned int UInt_t
Definition: RtypesCore.h:42
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:282
Generic 3D primitive description class.
Definition: TBuffer3D.h:19
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 const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:247
static TGeoMatrix * fgTransform
Definition: TGeoShape.h:38
virtual const char * GetAxisName(Int_t iaxis) const =0
Int_t GetId() const
Definition: TGeoShape.h:133
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
virtual Bool_t IsReflected() const
Definition: TGeoShape.h:147
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:268
return c2
Definition: legend2.C:14
static const double x1[5]
double f(double x)
Int_t fShapeId
Definition: TGeoShape.h:82
double Double_t
Definition: RtypesCore.h:55
virtual void Contains_v(const Double_t *, Bool_t *, Int_t) const
Definition: TGeoShape.h:111
virtual Bool_t IsComposite() const
Definition: TGeoShape.h:140
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
Definition: TGeoShape.cxx:258
Bool_t IsValid() const
Definition: TGeoShape.h:149
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:697
static Double_t Big()
Definition: TGeoShape.h:98
void SetRuntime(Bool_t flag=kTRUE)
Definition: TGeoShape.h:164
virtual Double_t Capacity() const =0
#define name(a, b)
Definition: linkTestLib0.cpp:5
static TGeoMatrix * GetTransform()
Returns current transformation matrix that applies to shape.
Definition: TGeoShape.cxx:534
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
Definition: TGeoShape.cxx:522
Bool_t TestShapeBit(UInt_t f) const
Definition: TGeoShape.h:172
virtual void DistFromOutside_v(const Double_t *, const Double_t *, Double_t *, Int_t, Double_t *) const
Definition: TGeoShape.h:119
virtual void InspectShape() const =0
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) 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:436
void SetShapeBit(UInt_t f)
Definition: TGeoShape.h:170
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Stub implementation to avoid forcing implementation at this stage.
Definition: TGeoShape.cxx:687
virtual void Paint(Option_t *option="")
Paint this shape.
Definition: TGeoShape.cxx:732
virtual Int_t GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const =0
void InvertShapeBit(UInt_t f)
Definition: TGeoShape.h:174
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:719
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Bool_t IsAssembly() const
Definition: TGeoShape.h:139
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
virtual Bool_t IsCylType() const =0
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322
UInt_t fShapeBits
Definition: TGeoShape.h:83
static const double x3[11]