Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
SolidSphere.hh
Go to the documentation of this file.
1#ifndef G_SOLID_SPHERE_H
2#define G_SOLID_SPHERE_H
3
4#include <mutex>
5
6#include "Solid.hh"
7
8namespace Garfield {
9
10/// Sphere.
11
12class SolidSphere : public Solid {
13 public:
14 /// Constructor from centre and outer radius.
15 SolidSphere(const double cx, const double cy, const double cz,
16 const double r);
17 /// Constructor from centre and inner/outer radii.
18 SolidSphere(const double cx, const double cy, const double cz,
19 const double rmin, const double rmax);
20 /// Destructor
22
23 bool IsInside(const double x, const double y, const double z,
24 const bool tesselated) const override;
25 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
26 double& ymax, double& zmax) const override;
27 bool IsSphere() const override { return true; }
28
29 /// Set the radius of the sphere.
30 void SetRadius(const double r);
31 /// Set the inner and outer radius of the sphere.
32 void SetRadii(const double rmin, const double rmax);
33
34 double GetRadius() const override { return m_rMax; }
35 double GetInnerRadius() const override { return m_rMin; }
36 double GetOuterRadius() const override { return m_rMax; }
37
38 /// When calculating surface panels, the sphere is approximated by a set of
39 /// parallelograms, much the same way maps are drawn ("UV sphere").
40 /// N specifies the number of meridians and also the number of parallels.
41 void SetMeridians(const unsigned int n);
42
43 bool SolidPanels(std::vector<Panel>& panels) override;
44 void SetDiscretisationLevel(const double dis) override { m_dis = dis; }
45 double GetDiscretisationLevel(const Panel& panel) override;
46
47 void Cut(const double x0, const double y0, const double z0,
48 const double xn, const double yn, const double zn,
49 std::vector<Panel>& panels) override;
50
51 private:
52 /// Mutex.
53 std::mutex m_mutex;
54
55 /// Inner and outer radii.
56 double m_rMin = 0., m_rMax = 1.;
57
58 /// Number of meridians.
59 unsigned int m_n = 10;
60
61 /// Discretisation level.
62 double m_dis = -1.;
63
64 /// Surface panels.
65 std::vector<Panel> m_panelsO;
66 std::vector<Panel> m_panelsI;
67
68 void UpdatePanels();
69 void MakePanels(const int vol, const double r, const bool out,
70 std::vector<Panel>& panels) const;
71};
72}
73
74#endif
bool IsInside(const double x, const double y, const double z, const bool tesselated) const override
void SetDiscretisationLevel(const double dis) override
Set the discretisation level (for all panels).
~SolidSphere()
Destructor.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
Return the bounding box of the solid.
double GetOuterRadius() const override
Return the outer radius.
void SetRadii(const double rmin, const double rmax)
Set the inner and outer radius of the sphere.
double GetInnerRadius() const override
Return the inner radius.
void SetRadius(const double r)
Set the radius of the sphere.
void Cut(const double x0, const double y0, const double z0, const double xn, const double yn, const double zn, std::vector< Panel > &panels) override
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretisation level of a panel.
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
bool IsSphere() const override
Return true if the solid is a sphere.
SolidSphere(const double cx, const double cy, const double cz, const double r)
Constructor from centre and outer radius.
double GetRadius() const override
Return the radius.
void SetMeridians(const unsigned int n)
Solid()=delete
Default constructor.
Surface panel.
Definition Solid.hh:11