14 std::cerr <<
m_className <<
"::AddSolid: Null pointer.\n";
19 const unsigned int nMedia =
m_media.size();
20 unsigned int n = nMedia;
21 const int id = m->
GetId();
22 for (
unsigned int i = 0; i < nMedia; ++i) {
23 if (
id ==
m_media[i]->GetId()) {
29 if (n == nMedia)
m_media.push_back(m);
32 double xmin, ymin, zmin;
33 double xmax, ymax, zmax;
35 std::cerr <<
m_className <<
"::AddSolid: Solid has no bounding box.\n";
57 m_solids.emplace_back(std::make_pair(s, n));
61 const double z)
const {
63 if (solid.first->IsInside(x, y, z))
return solid.first;
69 const double z)
const {
71 if (solid.first->IsInside(x, y, z)) {
72 if (solid.second < 0)
return nullptr;
82 <<
" Requested solid " << i <<
" does not exist.\n";
92 <<
" Requested solid " << i <<
" does not exist.\n";
103 <<
" Requested medium " << i <<
" does not exist.\n";
116 const unsigned int nSolids =
m_solids.size();
118 std::cout <<
" 1 solid\n";
120 std::cout <<
" " << nSolids <<
" solids\n";
123 std::cout <<
" Index Type Medium\n";
124 for (
unsigned int i = 0; i < nSolids; ++i) {
125 std::cout <<
" " << i <<
" ";
128 }
else if (
m_solids[i].first->IsTube()) {
129 std::cout <<
"tube ";
130 }
else if (
m_solids[i].first->IsSphere()) {
131 std::cout <<
"sphere ";
133 std::cout <<
"unknown ";
140 const double z)
const {
143 for (
const auto& solid :
m_solids) {
144 if (solid.first->IsInside(x, y, z))
return true;
150 const double z)
const {
154 <<
" Bounding box is not defined.\n";
Abstract base class for geometry classes.
Solid * GetSolid(const unsigned int i) const override
Get a solid from the list.
bool IsInside(const double x, const double y, const double z) const override
Check if a point is inside the geometry.
std::vector< std::pair< Solid *, int > > m_solids
List of solids.
Medium * GetMedium(const double x, const double y, const double z) const override
Retrieve the medium at a given point.
bool IsInBoundingBox(const double x, const double y, const double z) const
std::vector< Medium * > m_media
List of media.
void Clear()
Reset 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.
GeometrySimple()
Constructor.
Abstract base class for media.
int GetId() const
Return the id number of the class instance.
Abstract base class for solids.
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const =0
Return the bounding box of the solid.