ROOT logo
// @(#)root/geom:$Id: TGeoShape.h 41234 2011-10-06 15:48:52Z agheata $
// Author: Andrei Gheata   31/01/02

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGeoShape
#define ROOT_TGeoShape

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

// forward declarations
class TGeoBoolCombinator;
class TGeoBBox;
class TGeoMatrix;
class TGeoHMatrix;
class TGeoVolume;
class TBuffer3D;

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// TGeoShape - base class for geometric shapes. Provides virtual methods  //
//   for point and segment classification that has to be implemented by   //
//   all classes inheriting from it.                                      //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

class TGeoShape : public TNamed
{
private:
   static TGeoMatrix     *fgTransform;  // current transformation matrix that applies to shape
   static Double_t        fgEpsMch;     // Machine round-off error
public:
enum EShapeType {
   kBitMask32  = 0xffffffff,
   kGeoNoShape = 0,
   kGeoBad     = BIT(0),
   kGeoRSeg    = BIT(1),
   kGeoPhiSeg  = BIT(2),
   kGeoThetaSeg = BIT(3),
   kGeoVisX    = BIT(4),
   kGeoVisY    = BIT(5),
   kGeoVisZ    = BIT(6),
   kGeoRunTimeShape = BIT(7),
   kGeoInvalidShape = BIT(8),
   kGeoTorus   = BIT(9),
   kGeoBox     = BIT(10),
   kGeoPara    = BIT(11),
   kGeoSph     = BIT(12),
   kGeoTube    = BIT(13),
   kGeoTubeSeg = BIT(14), 
   kGeoCone    = BIT(15),
   kGeoConeSeg = BIT(16),
   kGeoPcon    = BIT(17),
   kGeoPgon    = BIT(18),
   kGeoArb8    = BIT(19),
   kGeoEltu    = BIT(20),
   kGeoTrap    = BIT(21),
   kGeoCtub    = BIT(22),
   kGeoTrd1    = BIT(23),
   kGeoTrd2    = BIT(24),
   kGeoComb    = BIT(25),
   kGeoClosedShape = BIT(26),
   kGeoXtru    = BIT(27),
   kGeoParaboloid = BIT(28),
   kGeoHalfSpace  = BIT(29),
   kGeoHype    = BIT(30),
   kGeoSavePrimitive = BIT(20)
};
   virtual void  ClearThreadData() const {}

protected :
// data members
   Int_t                 fShapeId;   // shape id
   UInt_t                fShapeBits; // shape bits
// methods
   virtual void          FillBuffer3D(TBuffer3D & buffer, Int_t reqSections, Bool_t localFrame) const;
   Int_t                 GetBasicColor() const;
   void                  SetOnBoundary(Bool_t /*flag=kTRUE*/) {;}
   void                  TransformPoints(Double_t *points, UInt_t NbPoints) const;

public:
   // constructors
   TGeoShape();
   TGeoShape(const char *name);
   // destructor
   virtual ~TGeoShape();
   // methods

   static Double_t       Big() {return 1.E30;}
   static TGeoMatrix    *GetTransform();
   static void           SetTransform(TGeoMatrix *matrix);
   static Double_t       Tolerance() {return 1.E-10;}
   static Double_t       ComputeEpsMch();
   static Double_t       EpsMch();
   virtual Double_t      Capacity() const                        = 0;
   void                  CheckShape(Int_t testNo, Int_t nsamples=10000, Option_t *option="");
   virtual void          ComputeBBox()                           = 0;
   virtual void          ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm) = 0;
   virtual Bool_t        Contains(Double_t *point) const         = 0;
   virtual Bool_t        CouldBeCrossed(Double_t *point, Double_t *dir) const = 0;
   virtual Int_t         DistancetoPrimitive(Int_t px, Int_t py) = 0;
   virtual Double_t      DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1, 
                                   Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
   virtual Double_t      DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1, 
                                   Double_t step=TGeoShape::Big(), Double_t *safe=0) const = 0;
   static Double_t       DistToPhiMin(Double_t *point, 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);
   virtual TGeoVolume   *Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, 
                                Double_t start, Double_t step)   = 0; 
   virtual void          Draw(Option_t *option=""); // *MENU*
   virtual void          ExecuteEvent(Int_t event, Int_t px, Int_t py);
   virtual const char   *GetAxisName(Int_t iaxis) const = 0;
   virtual Double_t      GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const = 0;
   virtual void          GetBoundingCylinder(Double_t *param) const = 0;
   virtual const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
   virtual Int_t         GetByteCount() const                          = 0;
   virtual Bool_t        GetPointsOnSegments(Int_t npoints, Double_t *array) const = 0;
   virtual Int_t         GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const = 0;
   Int_t                 GetId() const  {return fShapeId;}
   virtual TGeoShape    *GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const  = 0;
   virtual void          GetMeshNumbers(Int_t &/*nvert*/, Int_t &/*nsegs*/, Int_t &/*npols*/) const {;}
   virtual const char   *GetName() const;
   virtual Int_t         GetNmeshVertices() const {return 0;}
   const char           *GetPointerName() const;
   virtual Bool_t        IsAssembly() const {return kFALSE;}
   virtual Bool_t        IsComposite() const {return kFALSE;}
   virtual Bool_t        IsCylType() const = 0;
   static  Bool_t        IsCloseToPhi(Double_t epsil, Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
   static  Bool_t        IsCrossingSemiplane(Double_t *point, Double_t *dir, Double_t cphi, Double_t sphi, Double_t &snext, Double_t &rxy);
   static  Bool_t        IsSameWithinTolerance(Double_t a, Double_t b);
   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);
   static  Bool_t        IsInPhiRange(Double_t *point, Double_t phi1, Double_t phi2);
   virtual Bool_t        IsReflected() const {return kFALSE;}
   Bool_t                IsRunTimeShape() const {return TestShapeBit(kGeoRunTimeShape);}
   Bool_t                IsValid() const {return !TestShapeBit(kGeoInvalidShape);}
   virtual Bool_t        IsValidBox() const                      = 0; 
   virtual void          InspectShape() const                    = 0;
   virtual TBuffer3D    *MakeBuffer3D() const {return 0;}
   static void           NormalPhi(Double_t *point, Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2);
   virtual void          Paint(Option_t *option="");
   virtual Double_t      Safety(Double_t *point, Bool_t in=kTRUE) const = 0;
   static  Double_t      SafetyPhi(Double_t *point, Bool_t in, Double_t phi1, Double_t phi2);
   virtual void          SetDimensions(Double_t *param)          = 0;
   void                  SetId(Int_t id) {fShapeId = id;}
   virtual void          SetPoints(Double_t *points) const         = 0;
   virtual void          SetPoints(Float_t *points) const          = 0;
   virtual void          SetSegsAndPols(TBuffer3D &buff) const   = 0;
   void                  SetRuntime(Bool_t flag=kTRUE) {SetShapeBit(kGeoRunTimeShape, flag);}
   Int_t                 ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const;
   virtual void          Sizeof3D() const                        = 0;

   //----- bit manipulation
   void     SetShapeBit(UInt_t f, Bool_t set);
   void     SetShapeBit(UInt_t f) { fShapeBits |= f & kBitMask32; }
   void     ResetShapeBit(UInt_t f) { fShapeBits &= ~(f & kBitMask32); }
   Bool_t   TestShapeBit(UInt_t f) const { return (Bool_t) ((fShapeBits & f) != 0); }
   Int_t    TestShapeBits(UInt_t f) const { return (Int_t) (fShapeBits & f); }
   void     InvertShapeBit(UInt_t f) { fShapeBits ^= f & kBitMask32; }
   
   ClassDef(TGeoShape, 2)           // base class for shapes
};

#endif

 TGeoShape.h:1
 TGeoShape.h:2
 TGeoShape.h:3
 TGeoShape.h:4
 TGeoShape.h:5
 TGeoShape.h:6
 TGeoShape.h:7
 TGeoShape.h:8
 TGeoShape.h:9
 TGeoShape.h:10
 TGeoShape.h:11
 TGeoShape.h:12
 TGeoShape.h:13
 TGeoShape.h:14
 TGeoShape.h:15
 TGeoShape.h:16
 TGeoShape.h:17
 TGeoShape.h:18
 TGeoShape.h:19
 TGeoShape.h:20
 TGeoShape.h:21
 TGeoShape.h:22
 TGeoShape.h:23
 TGeoShape.h:24
 TGeoShape.h:25
 TGeoShape.h:26
 TGeoShape.h:27
 TGeoShape.h:28
 TGeoShape.h:29
 TGeoShape.h:30
 TGeoShape.h:31
 TGeoShape.h:32
 TGeoShape.h:33
 TGeoShape.h:34
 TGeoShape.h:35
 TGeoShape.h:36
 TGeoShape.h:37
 TGeoShape.h:38
 TGeoShape.h:39
 TGeoShape.h:40
 TGeoShape.h:41
 TGeoShape.h:42
 TGeoShape.h:43
 TGeoShape.h:44
 TGeoShape.h:45
 TGeoShape.h:46
 TGeoShape.h:47
 TGeoShape.h:48
 TGeoShape.h:49
 TGeoShape.h:50
 TGeoShape.h:51
 TGeoShape.h:52
 TGeoShape.h:53
 TGeoShape.h:54
 TGeoShape.h:55
 TGeoShape.h:56
 TGeoShape.h:57
 TGeoShape.h:58
 TGeoShape.h:59
 TGeoShape.h:60
 TGeoShape.h:61
 TGeoShape.h:62
 TGeoShape.h:63
 TGeoShape.h:64
 TGeoShape.h:65
 TGeoShape.h:66
 TGeoShape.h:67
 TGeoShape.h:68
 TGeoShape.h:69
 TGeoShape.h:70
 TGeoShape.h:71
 TGeoShape.h:72
 TGeoShape.h:73
 TGeoShape.h:74
 TGeoShape.h:75
 TGeoShape.h:76
 TGeoShape.h:77
 TGeoShape.h:78
 TGeoShape.h:79
 TGeoShape.h:80
 TGeoShape.h:81
 TGeoShape.h:82
 TGeoShape.h:83
 TGeoShape.h:84
 TGeoShape.h:85
 TGeoShape.h:86
 TGeoShape.h:87
 TGeoShape.h:88
 TGeoShape.h:89
 TGeoShape.h:90
 TGeoShape.h:91
 TGeoShape.h:92
 TGeoShape.h:93
 TGeoShape.h:94
 TGeoShape.h:95
 TGeoShape.h:96
 TGeoShape.h:97
 TGeoShape.h:98
 TGeoShape.h:99
 TGeoShape.h:100
 TGeoShape.h:101
 TGeoShape.h:102
 TGeoShape.h:103
 TGeoShape.h:104
 TGeoShape.h:105
 TGeoShape.h:106
 TGeoShape.h:107
 TGeoShape.h:108
 TGeoShape.h:109
 TGeoShape.h:110
 TGeoShape.h:111
 TGeoShape.h:112
 TGeoShape.h:113
 TGeoShape.h:114
 TGeoShape.h:115
 TGeoShape.h:116
 TGeoShape.h:117
 TGeoShape.h:118
 TGeoShape.h:119
 TGeoShape.h:120
 TGeoShape.h:121
 TGeoShape.h:122
 TGeoShape.h:123
 TGeoShape.h:124
 TGeoShape.h:125
 TGeoShape.h:126
 TGeoShape.h:127
 TGeoShape.h:128
 TGeoShape.h:129
 TGeoShape.h:130
 TGeoShape.h:131
 TGeoShape.h:132
 TGeoShape.h:133
 TGeoShape.h:134
 TGeoShape.h:135
 TGeoShape.h:136
 TGeoShape.h:137
 TGeoShape.h:138
 TGeoShape.h:139
 TGeoShape.h:140
 TGeoShape.h:141
 TGeoShape.h:142
 TGeoShape.h:143
 TGeoShape.h:144
 TGeoShape.h:145
 TGeoShape.h:146
 TGeoShape.h:147
 TGeoShape.h:148
 TGeoShape.h:149
 TGeoShape.h:150
 TGeoShape.h:151
 TGeoShape.h:152
 TGeoShape.h:153
 TGeoShape.h:154
 TGeoShape.h:155
 TGeoShape.h:156
 TGeoShape.h:157
 TGeoShape.h:158
 TGeoShape.h:159
 TGeoShape.h:160
 TGeoShape.h:161
 TGeoShape.h:162
 TGeoShape.h:163
 TGeoShape.h:164
 TGeoShape.h:165
 TGeoShape.h:166
 TGeoShape.h:167
 TGeoShape.h:168
 TGeoShape.h:169
 TGeoShape.h:170
 TGeoShape.h:171
 TGeoShape.h:172