Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GeometrySimple.hh
Go to the documentation of this file.
1#ifndef G_GEOMETRY_SIMPLE_H
2#define G_GEOMETRY_SIMPLE_H
3
4#include <array>
5#include <vector>
6
7#include "Geometry.hh"
8
9namespace Garfield {
10
11/// "Native" geometry, using simple shapes.
12
13class GeometrySimple : public Geometry {
14 public:
15 /// Constructor
17 /// Destructor
18 virtual ~GeometrySimple() {}
19
20 Medium* GetMedium(const double x, const double y, const double z,
21 const bool tesselated = false) const override;
22
23 size_t GetNumberOfSolids() const override { return m_solids.size(); }
24 Solid* GetSolid(const size_t i) const override;
25 Solid* GetSolid(const size_t i, Medium*& medium) const override;
26
27 /// Add a solid to the geometry, together with the medium inside.
28 void AddSolid(Solid* s, Medium* m);
29 /// Get the solid at a given location (x, y, z).
30 Solid* GetSolid(const double x, const double y, const double z,
31 const bool tesselated = false) const;
32
33 /// Set a background medium.
34 void SetMedium(Medium* medium) { m_medium = medium; }
35
36 /// Reset the geometry.
37 void Clear();
38 /// Print a summary of the solids present in the geometry.
39 void PrintSolids();
40
41 bool IsInside(const double x, const double y, const double z,
42 const bool tesselated = false) const override;
43 /// Determine whether a point is inside the envelope of the geometry.
44 bool IsInBoundingBox(const double x, const double y, const double z) const;
45 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
46 double& ymax, double& zmax) override {
47 xmin = m_bbMin[0];
48 ymin = m_bbMin[1];
49 zmin = m_bbMin[2];
50 xmax = m_bbMax[0];
51 ymax = m_bbMax[1];
52 zmax = m_bbMax[2];
53 return true;
54 }
55
56 /// Switch on/off debugging and warning messages.
57 void EnableDebugging(const bool on = true) { m_debug = on; }
58
59 protected:
60 /// List of solids and associated media.
61 std::vector<std::pair<Solid*, Medium*> > m_solids;
62 /// Background medium.
63 Medium* m_medium = nullptr;
64
65 // Bounding box ranges
66 bool m_hasBoundingBox = false;
67 std::array<double, 3> m_bbMin = {{0., 0., 0.}};
68 std::array<double, 3> m_bbMax = {{0., 0., 0.}};
69
70 /// Switch on/off debugging messages.
71 bool m_debug = false;
72};
73}
74
75#endif
"Native" geometry, using simple shapes.
size_t GetNumberOfSolids() const override
Return the number of solids in the geometry.
void SetMedium(Medium *medium)
Set a background medium.
bool IsInside(const double x, const double y, const double z, const bool tesselated=false) const override
Check if a point is inside the geometry.
Medium * m_medium
Background medium.
std::array< double, 3 > m_bbMin
Medium * GetMedium(const double x, const double y, const double z, const bool tesselated=false) const override
Retrieve the medium at a given point.
std::array< double, 3 > m_bbMax
std::vector< std::pair< Solid *, Medium * > > m_solids
List of solids and associated media.
void EnableDebugging(const bool on=true)
Switch on/off debugging and warning messages.
bool IsInBoundingBox(const double x, const double y, const double z) const
Determine whether a point is inside the envelope of the geometry.
Solid * GetSolid(const size_t i) const override
Get a solid from the list.
void Clear()
Reset the geometry.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box (envelope of the geometry).
void PrintSolids()
Print a summary of the solids present in the geometry.
bool m_debug
Switch on/off debugging messages.
void AddSolid(Solid *s, Medium *m)
Add a solid to the geometry, together with the medium inside.
virtual ~GeometrySimple()
Destructor.
GeometrySimple()
Constructor.
Abstract base class for geometry classes.
Definition: Geometry.hh:13
Abstract base class for media.
Definition: Medium.hh:13
Abstract base class for solids.
Definition: Solid.hh:28