Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGeoXtru.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Mihaela Gheata 24/01/04
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_TGeoXtru
13 #define ROOT_TGeoXtru
14 
15 #include <mutex>
16 
17 #include "TGeoBBox.h"
18 
19 class TGeoPolygon;
20 
21 class TGeoXtru : public TGeoBBox
22 {
23 public:
24  struct ThreadData_t
25  {
26  Int_t fSeg; // !current segment [0,fNvert-1]
27  Int_t fIz; // !current z plane [0,fNz-1]
28  Double_t *fXc; // ![fNvert] current X positions for polygon vertices
29  Double_t *fYc; // ![fNvert] current Y positions for polygon vertices
30  TGeoPolygon *fPoly; // !polygon defining section shape
31 
32  ThreadData_t();
33  ~ThreadData_t();
34  };
35  ThreadData_t& GetThreadData() const;
36  virtual void ClearThreadData() const;
37  virtual void CreateThreadData(Int_t nthreads);
38 
39 protected:
40  // data members
41  Int_t fNvert; // number of vertices of the 2D polygon (at least 3)
42  Int_t fNz; // number of z planes (at least two)
43  Double_t fZcurrent; // current Z position
44  Double_t *fX; //[fNvert] X positions for polygon vertices
45  Double_t *fY; //[fNvert] Y positions for polygon vertices
46  Double_t *fZ; //[fNz] array of Z planes positions
47  Double_t *fScale; //[fNz] array of scale factors (for each Z)
48  Double_t *fX0; //[fNz] array of X offsets (for each Z)
49  Double_t *fY0; //[fNz] array of Y offsets (for each Z)
50 
51  mutable std::vector<ThreadData_t*> fThreadData; //! Navigation data per thread
52  mutable Int_t fThreadSize; //! size of thread-specific array
53  mutable std::mutex fMutex; //! mutex for thread data
54 
55  TGeoXtru(const TGeoXtru&);
56  TGeoXtru& operator=(const TGeoXtru&);
57 
58  // methods
59  Double_t DistToPlane(const Double_t *point, const Double_t *dir, Int_t iz, Int_t ivert, Double_t stepmax, Bool_t in) const;
60  void GetPlaneVertices(Int_t iz, Int_t ivert, Double_t *vert) const;
61  void GetPlaneNormal(const Double_t *vert, Double_t *norm) const;
62  Bool_t IsPointInsidePlane(const Double_t *point, Double_t *vert, Double_t *norm) const;
63  Double_t SafetyToSector(const Double_t *point, Int_t iz, Double_t safmin, Bool_t in);
64  void SetIz(Int_t iz);
65  void SetSeg(Int_t iseg);
66 
67 public:
68  // constructors
69  TGeoXtru();
70  TGeoXtru(Int_t nz);
71  TGeoXtru(Double_t *param);
72  // destructor
73  virtual ~TGeoXtru();
74  // methods
75  virtual Double_t Capacity() const;
76  virtual void ComputeBBox();
77  virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm);
78  virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize);
79  virtual Bool_t Contains(const Double_t *point) const;
80  virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const;
81  Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv);
82  virtual void DefineSection(Int_t snum, Double_t z, Double_t x0=0., Double_t y0=0., Double_t scale=1.);
83  virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1,
84  Double_t step=TGeoShape::Big(), Double_t *safe=0) const;
85  virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const;
86  virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1,
87  Double_t step=TGeoShape::Big(), Double_t *safe=0) const;
88  virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const;
89  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
90  void DrawPolygon(Option_t *option="");
91  virtual const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
92 // virtual Int_t GetByteCount() const {return 60+12*fNz;}
93  Int_t GetNz() const {return fNz;}
94  Int_t GetNvert() const {return fNvert;}
95  Double_t GetX(Int_t i) const {return (i<fNvert&&i>-1 &&fX!=0) ? fX[i] : -1.0E10;}
96  Double_t GetY(Int_t i) const {return (i<fNvert&&i>-1 &&fY!=0) ? fY[i] : -1.0E10;}
97  Double_t GetXOffset(Int_t i) const {return (i<fNz&&i>-1 && fX0!=0) ? fX0[i] : 0.0;}
98  Double_t GetYOffset(Int_t i) const {return (i<fNz&&i>-1 && fY0!=0) ? fY0[i] : 0.0;}
99  Double_t GetScale(Int_t i) const {return (i<fNz&&i>-1 && fScale!=0) ? fScale[i] : 1.0;}
100  Double_t *GetZ() const {return fZ;}
101  Double_t GetZ(Int_t ipl) const;
102  virtual TGeoShape *GetMakeRuntimeShape(TGeoShape * /*mother*/, TGeoMatrix * /*mat*/) const {return 0;}
103  virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const;
104  virtual Int_t GetNmeshVertices() const;
105  virtual void InspectShape() const;
106  virtual TBuffer3D *MakeBuffer3D() const;
107  Double_t &Z(Int_t ipl) {return fZ[ipl];}
108  virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
109  virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const;
110  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
111  void SetCurrentZ(Double_t z, Int_t iz);
112  void SetCurrentVertices(Double_t x0, Double_t y0, Double_t scale);
113  virtual void SetDimensions(Double_t *param);
114  virtual void SetPoints(Double_t *points) const;
115  virtual void SetPoints(Float_t *points) const;
116  virtual void SetSegsAndPols(TBuffer3D &buff) const;
117  virtual void Sizeof3D() const;
118 
119  ClassDef(TGeoXtru, 3) // extruded polygon class
120 };
121 
122 #endif