JG ROOT Tools libraries  version 5.0 - august 2014
RSolidTesselation.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file RSolidTesselation.hh
3  *
4  * Include file for the class RSolidTesselation, and the
5  * related classes RTesselationPoint and RTesselationSegment.
6  */
7 //======================================================================
8 
9 #ifndef R_SOLID_TESSELATION_HH
10 #define R_SOLID_TESSELATION_HH
11 
12 //======================================================================
13 
14 // GRootTools includes
15 #include "RBaseFunctions.hh"
16 #include "RStringFunctions.hh"
17 
18 // ROOT includes
19 #include <TVector3.h>
20 #include <TPolyMarker3D.h>
21 #include <TPolyLine3D.h>
22 #include <TList.h>
23 #include <TMath.h>
24 
25 class RSolidTesselation;
26 class RSphereTesselation;
27 
28 //======================================================================
29 /*! \class RTesselationPoint
30  *
31  * This class defines the information associated to a point in the
32  * tesselation of solids:
33  * - the point position
34  * - the indexes of related neighbours
35  */
37 {
38  //------------------------------------------------------------
39  /*! \object_doc{RTesselationPoint} */
41  //------------------------------------------------------------
42 
43  friend class RSolidTesselation;
44 
45  protected:
46  TVector3 position; ///< Position of the point
47 
48  int neighbour_num; ///< Number of neighbouring points
49  int * neighbour_tab; ///< Array of index of neighbouring points
50 
51  public:
52 
53  //------------------------------------------------------------
54  /** @name Constructors, affectation, destructor */
55  //@{
57  RTesselationPoint ( const RTesselationPoint & original );
58  RTesselationPoint & operator = ( const RTesselationPoint & original );
59  virtual ~RTesselationPoint ( );
60 
61  //@}
62 
63  //------------------------------------------------------------
64  /** @name Data setting */
65  //@{
66  virtual void ResetData ( );
67  virtual void CopyData ( const RTesselationPoint & original );
68 
69  void SetPosition ( const TVector3 & p ); // inline
70  void SetNeighboursNum ( int n ); // inline
71  void SetNeighbour ( int i, int ip ); // inline
72  //@}
73 
74  //------------------------------------------------------------
75  /** @name Points information */
76  //@{
77  const TVector3 & GetPosition ( ) const; // inline
78  TVector3 & GetPosition ( ); // inline
79  double GetX ( ) const; // inline
80  double GetY ( ) const; // inline
81  double GetZ ( ) const; // inline
82  double GetTheta ( bool deg = false ) const;
83  double GetPhi ( bool deg = false ) const;
84 
85  int GetNeighbourNum ( ) const; // inline
86  int GetNeighbourIndex ( int i ) const; // inline
87  const int * GetNeighbourTab ( ) const; // inline
88  int * GetNeighbourTab ( ); // inline
89  //@}
90 
91  //------------------------------------------------------------
92  /** @name ROOT related functions */
93  //@{
94  /*! For ROOT dictionary.*/
96  //@}
97 };
98 
99 
100 //======================================================================
101 /*! \class RTesselationSegment
102  *
103  * This class defines the information associated to a point in the
104  * tesselation of solids:
105  * - the point position
106  * - the angles theta and phi (for convenience)
107  * - the indexes of related neighbours
108  */
110 {
111  //------------------------------------------------------------
112  /*! \object_doc{RTesselationSegment} */
114  //------------------------------------------------------------
115 
116  friend class RSolidTesselation;
117 
118  protected:
119  int pt_index[2]; ///< Indexes of segment points
120 
121  public:
122 
123  //------------------------------------------------------------
124  /** @name Constructors, affectation, destructor */
125  //@{
127  RTesselationSegment ( const RTesselationSegment & original );
129  virtual ~RTesselationSegment ( );
130 
131  //@}
132 
133  //------------------------------------------------------------
134  /** @name Segment data */
135  //@{
136  void SetPindex ( int i0, int i1 ); // inline
137  int GetPindex ( int ip ) const; // inline
138  int GetP0 ( ) const; // inline
139  int GetP1 ( ) const; // inline
140  //@}
141 
142  //------------------------------------------------------------
143  /** @name ROOT related functions */
144  //@{
145  /*! For ROOT dictionary.*/
147  //@}
148 };
149 
150 
151 //======================================================================
152 /*! \class RSolidTesselation
153  *
154  * Base class for representation of a volume by a set of points
155  * that are summits of base triangles.
156  *
157  * This is an abstract class, and the derived class must provide
158  * an initialization function (InitData) that properly defines
159  * the points for a closed volume.
160  */
162 {
163  //------------------------------------------------------------
164  /*! \object_doc{RSolidTesselation} */
166  //------------------------------------------------------------
167 
168  protected:
169  u_short subdiv; ///< Number of subdivisions since initial creation
170  u_int npts; ///< Number of points
171  u_int nseg; ///< Number of segments
172 
173  RTesselationPoint * tab_pts; ///< Array of points
174  RTesselationSegment * tab_seg; ///< Array of segments
175 
176  public:
177 
178  //------------------------------------------------------------
179  /** @name Constructors, affectation, destructor */
180  //@{
181  RSolidTesselation ( );
182  virtual ~RSolidTesselation ( );
183  //@}
184 
185  //------------------------------------------------------------
186  /** @name Tesselation data */
187  //@{
188  virtual void ResetData ( );
189 
190  /*! Function setting the initial points before division.*/
191  virtual void InitData ( ) = 0;
192 
193  /*! Function sub-dividing the current discretization of the volume.
194  * The function should return the new number of points.
195  */
196  virtual int SubDivide ( ) = 0;
197  virtual u_short GetDivision ( ) const; // inline
198 
199  int GetNpoints ( ) const; // inline
200  int GetNsegments ( ) const; // inline
201 
202  const RTesselationPoint & GetPoint ( int ip ) const; // inline
203  const RTesselationSegment & GetSegment ( int is ) const; // inline
204  //@}
205 
206  //------------------------------------------------------------
207  /** @name ROOT related functions */
208  //@{
209  TPolyMarker3D * CreatePoints3D ( ) const;
210  TPolyLine3D * CreateSegment3D ( int is ) const;
211  TList * CreateLines3D ( const TAttLine latt = TAttLine(kRed+1,2,1 ) ) const;
212 
213  /*! For ROOT dictionary.*/
215  //@}
216 };
217 
218 //----------------------------------------------------------------------
219 // Inline functions
220 #include "icc/RSolidTesselation.icc"
221 
222 
223 //======================================================================
224 
225 #endif
GObject(RTesselationPoint)
double GetTheta(bool deg=false) const
Definition: RSolidTesselation.cpp:106
int GetP0() const
Definition: RSolidTesselation.icc:108
ClassDef(RTesselationPoint, 0)
int GetPindex(int ip) const
Definition: RSolidTesselation.icc:104
double GetPhi(bool deg=false) const
Definition: RSolidTesselation.cpp:119
void SetNeighbour(int i, int ip)
Definition: RSolidTesselation.icc:23
RTesselationSegment * tab_seg
Array of segments.
Definition: RSolidTesselation.hh:174
int GetNeighbourNum() const
Definition: RSolidTesselation.icc:33
RTesselationSegment()
Definition: RSolidTesselation.icc:75
void SetPosition(const TVector3 &p)
Definition: RSolidTesselation.icc:16
virtual ~RSolidTesselation()
Definition: RSolidTesselation.cpp:173
void SetNeighboursNum(int n)
Definition: RSolidTesselation.cpp:89
void SetPindex(int i0, int i1)
Definition: RSolidTesselation.icc:98
u_int npts
Number of points.
Definition: RSolidTesselation.hh:170
RTesselationPoint & operator=(const RTesselationPoint &original)
Definition: RSolidTesselation.cpp:46
int GetNsegments() const
Definition: RSolidTesselation.icc:129
double GetY() const
Definition: RSolidTesselation.icc:62
virtual ~RTesselationPoint()
Definition: RSolidTesselation.cpp:54
TVector3 position
Position of the point.
Definition: RSolidTesselation.hh:46
virtual void CopyData(const RTesselationPoint &original)
Definition: RSolidTesselation.cpp:73
RTesselationSegment & operator=(const RTesselationSegment &original)
Definition: RSolidTesselation.icc:87
Definition: RSolidTesselation.hh:161
double GetZ() const
Definition: RSolidTesselation.icc:66
int pt_index[2]
Indexes of segment points.
Definition: RSolidTesselation.hh:119
GObject(RTesselationSegment)
TPolyLine3D * CreateSegment3D(int is) const
Definition: RSolidTesselation.cpp:218
RSolidTesselation()
Definition: RSolidTesselation.cpp:162
virtual u_short GetDivision() const
Definition: RSolidTesselation.icc:121
virtual void ResetData()
Definition: RSolidTesselation.cpp:64
virtual int SubDivide()=0
double GetX() const
Definition: RSolidTesselation.icc:58
TList * CreateLines3D(const TAttLine latt=TAttLine(kRed+1, 2, 1)) const
Definition: RSolidTesselation.cpp:238
int GetNeighbourIndex(int i) const
Definition: RSolidTesselation.icc:39
ClassDef(RSolidTesselation, 0)
const int * GetNeighbourTab() const
Definition: RSolidTesselation.icc:44
GObjectV(RSolidTesselation)
Definition: RSphereTesselation.hh:31
RTesselationPoint()
Definition: RSolidTesselation.cpp:27
int GetP1() const
Definition: RSolidTesselation.icc:112
const RTesselationPoint & GetPoint(int ip) const
Definition: RSolidTesselation.icc:136
const TVector3 & GetPosition() const
Definition: RSolidTesselation.icc:27
TPolyMarker3D * CreatePoints3D() const
Definition: RSolidTesselation.cpp:198
int GetNpoints() const
Definition: RSolidTesselation.icc:125
virtual void ResetData()
Definition: RSolidTesselation.cpp:183
Definition: RSolidTesselation.hh:109
Definition: RSolidTesselation.hh:36
virtual void InitData()=0
RTesselationPoint * tab_pts
Array of points.
Definition: RSolidTesselation.hh:173
virtual ~RTesselationSegment()
Definition: RSolidTesselation.icc:91
u_int nseg
Number of segments.
Definition: RSolidTesselation.hh:171
int neighbour_num
Number of neighbouring points.
Definition: RSolidTesselation.hh:48
u_short subdiv
Number of subdivisions since initial creation.
Definition: RSolidTesselation.hh:169
ClassDef(RTesselationSegment, 0)
int * neighbour_tab
Array of index of neighbouring points.
Definition: RSolidTesselation.hh:49
const RTesselationSegment & GetSegment(int is) const
Definition: RSolidTesselation.icc:142