Geant4_10
UPolycone.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * This Software is part of the AIDA Unified Solids Library package *
4 // * See: https://aidasoft.web.cern.ch/USolids *
5 // ********************************************************************
6 //
7 // $Id:$
8 //
9 // --------------------------------------------------------------------
10 //
11 // UPolycone
12 //
13 // Class description:
14 //
15 // Class implementing a CSG-like type "PCON".
16 //
17 // UPolycone( const G4String& name,
18 // G4double phiStart, // initial phi starting angle
19 // G4double phiTotal, // total phi angle
20 // G4int numZPlanes, // number of z planes
21 // const G4double zPlane[], // position of z planes
22 // const G4double rInner[], // tangent distance to inner surface
23 // const G4double rOuter[]) // tangent distance to outer surface
24 //
25 // Alternative constructor, but limited to increasing-only Z sections:
26 //
27 // UPolycone( const G4String& name,
28 // G4double phiStart, // initial phi starting angle
29 // G4double phiTotal, // total phi angle
30 // G4int numRZ, // number corners in r,z space
31 // const G4double r[], // r coordinate of these corners
32 // const G4double z[]) // z coordinate of these corners
33 //
34 // 19.04.13 Marek Gayer
35 // Created from original implementation in Geant4
36 // --------------------------------------------------------------------
37 
38 #ifndef UPolycone_hh
39 #define UPolycone_hh
40 
41 #include "VUSolid.hh"
42 
43 #include "UPolyconeSide.hh"
44 #include "UVCSGfaceted.hh"
45 #include "UVoxelizer.hh"
46 
47 #include "UCons.hh"
48 #include "UTubs.hh"
49 
50 class UEnclosingCylinder;
51 class UReduciblePolygon;
53 {
54  public:
59 
60  double fStartAngle;
61  double fOpeningAngle;
63  std::vector<double> fZValues;
64  std::vector<double> Rmin;
65  std::vector<double> Rmax;
66 };
67 
68 class UPolycone : public VUSolid
69 {
70 
71  public: // with description
72 
73  void Init(
74  double phiStart, // initial phi starting angle
75  double phiTotal, // total phi angle
76  int numZPlanes, // number of z planes
77  const double zPlane[], // position of z planes
78  const double rInner[], // tangent distance to inner surface
79  const double rOuter[]);
80 
81  UPolycone(const std::string& name) : VUSolid(name)
82  {
83  }
84 
85  UPolycone(const std::string& name,
86  double phiStart, // initial phi starting angle
87  double phiTotal, // total phi angle
88  int numZPlanes, // number of z planes
89  const double zPlane[], // position of z planes
90  const double rInner[], // tangent distance to inner surface
91  const double rOuter[]); // tangent distance to outer surface
92 
93 
94  UPolycone(const std::string& name,
95  double phiStart, // initial phi starting angle
96  double phiTotal, // total phi angle
97  int numRZ, // number corners in r,z space
98  const double r[], // r coordinate of these corners
99  const double z[]); // z coordinate of these corners
100 
101 
102  virtual ~UPolycone();
103 
104  void Reset();
105 
106 // inline void SetOriginalParameters(UPolyconeHistorical* pars);
107 
108 // inline void SetOriginalParameters();
109 
110  std::ostream& StreamInfo(std::ostream& os) const;
111 
112  VUSolid::EnumInside Inside(const UVector3& p) const;
113 
114  double DistanceToIn(const UVector3& p, const UVector3& v, double aPstep = UUtils::kInfinity) const;
115 
116  double SafetyFromInside(const UVector3& aPoint,
117  bool aAccurate = false) const;
118  double SafetyFromOutside(const UVector3& aPoint,
119  bool aAccurate = false) const;
120 
121  double DistanceToOut(const UVector3& aPoint,
122  const UVector3& aDirection,
123  UVector3& aNormalVector,
124  bool& aConvex,
125  double aPstep = UUtils::kInfinity) const;
126 
127  bool Normal(const UVector3& aPoint, UVector3& aNormal) const;
128  // virtual void Extent ( EAxisType aAxis, double &aMin, double &aMax ) const;
129  void Extent(UVector3& aMin, UVector3& aMax) const;
130  double Capacity();
131  double SurfaceArea();
133 
134  void ComputeBBox(UBBox* /*aBox*/, bool /*aStore = false*/) {}
135 
136  //G4Visualisation
137  void GetParametersList(int /*aNumber*/, double* /*aArray*/) const {}
138  VUSolid* Clone() const;
139 
140  UPolycone(const UPolycone& source);
141  UPolycone& operator=(const UPolycone& source);
142  // Copy constructor and assignment operator.
143  void CopyStuff(const UPolycone& source);
144  UVector3 GetPointOnSurface() const;
145 
146 // Methods for random point generation
147 
148  UVector3 GetPointOnCone(double fRmin1, double fRmax1,
149  double fRmin2, double fRmax2,
150  double zOne, double zTwo,
151  double& totArea) const;
152 
153  UVector3 GetPointOnTubs(double fRMin, double fRMax,
154  double zOne, double zTwo,
155  double& totArea) const;
156 
157  UVector3 GetPointOnCut(double fRMin1, double fRMax1,
158  double fRMin2, double fRMax2,
159  double zOne, double zTwo,
160  double& totArea) const;
161 
162  UVector3 GetPointOnRing(double fRMin, double fRMax,
163  double fRMin2, double fRMax2,
164  double zOne) const;
165 
166  inline double GetStartPhi() const
167  {
168  return startPhi;
169  }
170 
171  inline double GetEndPhi() const
172  {
173  return endPhi;
174  }
175 
176  inline bool IsOpen() const
177  {
178  return phiIsOpen;
179  }
180 
181  inline bool IsGeneric() const
182  {
183  return false;
184  }
185 
186  inline int GetNumRZCorner() const
187  {
188  return numCorner;
189  }
190 
191  inline UPolyconeSideRZ GetCorner(int index) const
192  {
193  return corners[index];
194  }
195 
197  {
198  return fOriginalParameters;
199  }
200 
202  {
203  if (!pars)
204  // UException("UPolycone3::SetOriginalParameters()", "GeomSolids0002",
205  // FatalException, "NULL pointer to parameters!");
206  *fOriginalParameters = *pars;
207  }
208 
209  protected: // without description
210 
211 // int fNumSides;
213  // Here are our parameters
214 
215  double startPhi; // Starting phi value (0 < phiStart < 2pi)
216  double endPhi; // end phi value (0 < endPhi-phiStart < 2pi)
217  bool phiIsOpen; // true if there is a phi segment
218  int numCorner; // number RZ points
219  UPolyconeSideRZ* corners; // corner r,z points
220  UPolyconeHistorical* fOriginalParameters; // original input parameters
221  double fCubicVolume; // Cubic Volume
222  double fSurfaceArea; // Surface Area
223 
224  inline void SetOriginalParameters()
225  {
226  int numPlanes = (int)numCorner / 2;
227 
229 
230  fOriginalParameters->fZValues.resize(numPlanes);
231  fOriginalParameters->Rmin.resize(numPlanes);
232  fOriginalParameters->Rmax.resize(numPlanes);
233 
234  for (int j = 0; j < numPlanes; j++)
235  {
236  fOriginalParameters->fZValues[j] = corners[numPlanes + j].z;
237  fOriginalParameters->Rmax[j] = corners[numPlanes + j].r;
238  fOriginalParameters->Rmin[j] = corners[numPlanes - 1 - j].r;
239  }
240 
243  fOriginalParameters->fNumZPlanes = numPlanes;
244  }
245 
247 
249  {
250  VUSolid* solid;// true if all points in section are concave in regards to whole polycone, will be determined
251  double shift;
252  bool tubular;
253 // double left, right;
254  bool convex; // TURE if all points in section are concave in regards to whole polycone, will be determined, currently not implemented
255  };
256 
257  std::vector<double> fZs; // z coordinates of given sections
258  std::vector<UPolyconeSection> fSections;
260 
261  inline VUSolid::EnumInside InsideSection(int index, const UVector3& p) const;
262 
263  inline double SafetyFromInsideSection(int index, const UVector3& p) const
264  {
265  const UPolyconeSection& section = fSections[index];
266  UVector3 ps(p.x, p.y, p.z - section.shift);
267  double res = section.solid->SafetyFromInside(ps, true);
268  return res;
269  }
270 
271  inline double SafetyFromOutsideSection(int index, const UVector3& p) const
272  {
273  const UPolyconeSection& section = fSections[index];
274  UVector3 ps(p.x, p.y, p.z - section.shift);
275  double res = section.solid->SafetyFromOutside(ps, true);
276  return res;
277  }
278 
279  bool NormalSection(int index, const UVector3& p, UVector3& n) const
280  {
281  const UPolyconeSection& section = fSections[index];
282  UVector3 ps(p.x, p.y, p.z - section.shift);
283  bool res = section.solid->Normal(ps, n);
284  return res;
285  }
286 
287  inline int GetSection(double z) const
288  {
289  int section = UVoxelizer::BinarySearch(fZs, z);
290  if (section < 0) section = 0;
291  else if (section > fMaxSection) section = fMaxSection;
292  return section;
293  }
294 };
295 
296 #endif
double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
Definition: UPolycone.cc:490
std::vector< double > Rmin
Definition: UPolycone.hh:64
UPolyconeSideRZ GetCorner(int index) const
Definition: UPolycone.hh:191
std::vector< double > fZValues
Definition: UPolycone.hh:63
Int_t index
Definition: macro.C:9
double GetEndPhi() const
Definition: UPolycone.hh:171
UVector3 GetPointOnTubs(double fRMin, double fRMax, double zOne, double zTwo, double &totArea) const
Definition: UPolycone.cc:948
double SafetyFromInsideSection(int index, const UVector3 &p) const
Definition: UPolycone.hh:263
void SetOriginalParameters(UPolyconeHistorical *pars)
Definition: UPolycone.hh:201
bool NormalSection(int index, const UVector3 &p, UVector3 &n) const
Definition: UPolycone.hh:279
int GetSection(double z) const
Definition: UPolycone.hh:287
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
double fCubicVolume
Definition: UPolycone.hh:221
UPolyconeHistorical * GetOriginalParameters() const
Definition: UPolycone.hh:196
const char * p
Definition: xmltok.h:285
void CopyStuff(const UPolycone &source)
Definition: UPolycone.cc:1251
std::vector< UPolyconeSection > fSections
Definition: UPolycone.hh:258
UVector3 GetPointOnCut(double fRMin1, double fRMax1, double fRMin2, double fRMax2, double zOne, double zTwo, double &totArea) const
Definition: UPolycone.cc:1055
const XML_Char * name
Definition: expat.h:151
std::ostream & StreamInfo(std::ostream &os) const
Definition: UPolycone.cc:335
UPolyconeHistorical & operator=(const UPolyconeHistorical &right)
Definition: UPolycone.cc:1194
virtual bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const =0
bool IsOpen() const
Definition: UPolycone.hh:176
double x
Definition: UVector3.hh:136
int numCorner
Definition: UPolycone.hh:218
VUSolid::EnumInside Inside(const UVector3 &p) const
Definition: UPolycone.cc:441
void GetParametersList(int, double *) const
Definition: UPolycone.hh:137
std::vector< double > Rmax
Definition: UPolycone.hh:65
int fMaxSection
Definition: UPolycone.hh:259
bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const
Definition: UPolycone.cc:668
Char_t n[5]
static int BinarySearch(const std::vector< T > &vec, T value)
Definition: UVoxelizer.hh:58
double SafetyFromOutsideSection(int index, const UVector3 &p) const
Definition: UPolycone.hh:271
bool phiIsOpen
Definition: UPolycone.hh:217
UVector3 GetPointOnSurface() const
Definition: UPolycone.cc:1075
void Init(double phiStart, double phiTotal, int numZPlanes, const double zPlane[], const double rInner[], const double rOuter[])
Definition: UPolycone.cc:107
double endPhi
Definition: UPolycone.hh:216
UPolyconeHistorical * fOriginalParameters
Definition: UPolycone.hh:220
UPolyconeSideRZ * corners
Definition: UPolycone.hh:219
UGeometryType GetEntityType() const
Definition: UPolycone.cc:1274
void Reset()
Definition: UPolycone.cc:1492
EnumInside
Definition: VUSolid.hh:23
tuple v
Definition: test.py:18
double SurfaceArea()
Definition: UPolycone.cc:777
virtual double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const =0
double Capacity()
Definition: UPolycone.cc:760
jump r
Definition: plot.C:36
void SetOriginalParameters()
Definition: UPolycone.hh:224
VUSolid::EnumInside InsideSection(int index, const UVector3 &p) const
Definition: UPolycone.cc:373
virtual double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const =0
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UPolycone.cc:639
double fSurfaceArea
Definition: UPolycone.hh:222
double GetStartPhi() const
Definition: UPolycone.hh:166
VUSolid * Clone() const
Definition: UPolycone.cc:1218
double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UPolycone.cc:606
tuple z
Definition: test.py:28
std::string UGeometryType
Definition: UTypes.hh:70
UVector3 GetPointOnRing(double fRMin, double fRMax, double fRMin2, double fRMax2, double zOne) const
Definition: UPolycone.cc:1007
UVector3 GetPointOnCone(double fRmin1, double fRmax1, double fRmin2, double fRmax2, double zOne, double zTwo, double &totArea) const
Definition: UPolycone.cc:844
virtual ~UPolycone()
Definition: UPolycone.cc:324
UPolycone & operator=(const UPolycone &source)
Definition: UPolycone.cc:1234
int GetNumRZCorner() const
Definition: UPolycone.hh:186
double z
Definition: UVector3.hh:138
double startPhi
Definition: UPolycone.hh:215
std::vector< double > fZs
Definition: UPolycone.hh:257
UEnclosingCylinder * enclosingCylinder
Definition: UPolycone.hh:246
void Extent(UVector3 &aMin, UVector3 &aMax) const
Definition: UPolycone.cc:753
double DistanceToOut(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
Definition: UPolycone.cc:532
double y
Definition: UVector3.hh:137
UPolycone(const std::string &name)
Definition: UPolycone.hh:81
void ComputeBBox(UBBox *, bool)
Definition: UPolycone.hh:134
bool IsGeneric() const
Definition: UPolycone.hh:181