11 const double lx,
const double ly,
const double lz)
12 :
Solid(cx, cy, cz,
"SolidBox"), m_lX(lx), m_lY(ly), m_lZ(lz) {}
15 const double lx,
const double ly,
const double lz,
16 const double dx,
const double dy,
const double dz)
23 double u = x, v = y, w = z;
27 if (fabs(u) > m_lX || fabs(v) > m_lY || fabs(w) > m_lZ) {
29 std::cout <<
"SolidBox::IsInside: (" << x <<
", " << y <<
", " << z
36 std::cout <<
"SolidBox::IsInside: (" << x <<
", " << y <<
", " << z
44 double& xmax,
double& ymax,
double& zmax)
const {
55 const double dd = sqrt(m_lX * m_lX + m_lY * m_lY + m_lZ * m_lZ);
69 std::cerr <<
"SolidBox::SetHalfLengthX: Half-length must be > 0.\n";
77 std::cerr <<
"SolidBox::SetHalfLengthY: Half-length must be > 0.\n";
85 std::cerr <<
"SolidBox::SetHalfLengthZ: Half-length must be > 0.\n";
90 const auto id =
GetId();
91 const auto nPanels = panels.size();
97 if (m_lY > 0 && m_lZ > 0) {
98 ToGlobal(-m_lX, -m_lY, -m_lZ, xv0, yv0, zv0);
99 ToGlobal(-m_lX, +m_lY, -m_lZ, xv1, yv1, zv1);
100 ToGlobal(-m_lX, +m_lY, +m_lZ, xv2, yv2, zv2);
101 ToGlobal(-m_lX, -m_lY, +m_lZ, xv3, yv3, zv3);
107 newpanel.
xv = {xv0, xv1, xv2, xv3};
108 newpanel.
yv = {yv0, yv1, yv2, yv3};
109 newpanel.
zv = {zv0, zv1, zv2, zv3};
112 panels.push_back(std::move(newpanel));
115 if (m_lX > 0 && m_lY > 0 && m_lZ > 0) {
116 ToGlobal(+m_lX, -m_lY, -m_lZ, xv0, yv0, zv0);
117 ToGlobal(+m_lX, +m_lY, -m_lZ, xv1, yv1, zv1);
118 ToGlobal(+m_lX, +m_lY, +m_lZ, xv2, yv2, zv2);
119 ToGlobal(+m_lX, -m_lY, +m_lZ, xv3, yv3, zv3);
124 newpanel.
xv = {xv0, xv1, xv2, xv3};
125 newpanel.
yv = {yv0, yv1, yv2, yv3};
126 newpanel.
zv = {zv0, zv1, zv2, zv3};
129 panels.push_back(std::move(newpanel));
132 if (m_lX > 0 && m_lZ > 0) {
133 ToGlobal(-m_lX, -m_lY, -m_lZ, xv0, yv0, zv0);
134 ToGlobal(+m_lX, -m_lY, -m_lZ, xv1, yv1, zv1);
135 ToGlobal(+m_lX, -m_lY, +m_lZ, xv2, yv2, zv2);
136 ToGlobal(-m_lX, -m_lY, +m_lZ, xv3, yv3, zv3);
141 newpanel.
xv = {xv0, xv1, xv2, xv3};
142 newpanel.
yv = {yv0, yv1, yv2, yv3};
143 newpanel.
zv = {zv0, zv1, zv2, zv3};
146 panels.push_back(std::move(newpanel));
149 if (m_lX > 0 && m_lY > 0 && m_lZ > 0) {
150 ToGlobal(-m_lX, +m_lY, -m_lZ, xv0, yv0, zv0);
151 ToGlobal(+m_lX, +m_lY, -m_lZ, xv1, yv1, zv1);
152 ToGlobal(+m_lX, +m_lY, +m_lZ, xv2, yv2, zv2);
153 ToGlobal(-m_lX, +m_lY, +m_lZ, xv3, yv3, zv3);
158 newpanel.
xv = {xv0, xv1, xv2, xv3};
159 newpanel.
yv = {yv0, yv1, yv2, yv3};
160 newpanel.
zv = {zv0, zv1, zv2, zv3};
163 panels.push_back(std::move(newpanel));
166 if (m_lX > 0 && m_lY > 0) {
167 ToGlobal(-m_lX, -m_lY, -m_lZ, xv0, yv0, zv0);
168 ToGlobal(-m_lX, +m_lY, -m_lZ, xv1, yv1, zv1);
169 ToGlobal(+m_lX, +m_lY, -m_lZ, xv2, yv2, zv2);
170 ToGlobal(+m_lX, -m_lY, -m_lZ, xv3, yv3, zv3);
175 newpanel.
xv = {xv0, xv1, xv2, xv3};
176 newpanel.
yv = {yv0, yv1, yv2, yv3};
177 newpanel.
zv = {zv0, zv1, zv2, zv3};
180 panels.push_back(std::move(newpanel));
183 if (m_lX > 0 && m_lY > 0 && m_lZ > 0) {
184 ToGlobal(-m_lX, -m_lY, +m_lZ, xv0, yv0, zv0);
185 ToGlobal(-m_lX, +m_lY, +m_lZ, xv1, yv1, zv1);
186 ToGlobal(+m_lX, +m_lY, +m_lZ, xv2, yv2, zv2);
187 ToGlobal(+m_lX, -m_lY, +m_lZ, xv3, yv3, zv3);
192 newpanel.
xv = {xv0, xv1, xv2, xv3};
193 newpanel.
yv = {yv0, yv1, yv2, yv3};
194 newpanel.
zv = {zv0, zv1, zv2, zv3};
197 panels.push_back(std::move(newpanel));
200 std::cout <<
"SolidBox::SolidPanels: " << panels.size() - nPanels
208 double u = 0., v = 0., w = 0.;
211 if (u > std::max(std::abs(v), std::abs(w))) {
213 }
else if (u < -std::max(std::abs(v), std::abs(w))) {
215 }
else if (v > std::max(std::abs(u), std::abs(w))) {
217 }
else if (v < -std::max(std::abs(u), std::abs(w))) {
219 }
else if (w > std::max(std::abs(u), std::abs(v))) {
221 }
else if (w < -std::max(std::abs(u), std::abs(v))) {
225 std::cout <<
m_className <<
"::GetDiscretisationLevel:\n"
226 <<
" Found no match for the panel; return first value.\n";
void SetHalfLengthX(const double lx)
SolidBox(const double cx, const double cy, const double cz, const double lx, const double ly, const double lz)
Constructor from centre and half-widths.
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
void SetHalfLengthZ(const double lz)
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
Return the bounding box of the solid.
bool IsInside(const double x, const double y, const double z) const override
Check whether a given point is inside the solid.
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretization level of a panel.
void SetHalfLengthY(const double ly)
Abstract base class for solids.
void VectorToLocal(const double x, const double y, const double z, double &u, double &v, double &w)
Transform a vector from global to local coordinates.
double m_cTheta
Polar angle.
unsigned int GetId() const
Get the ID of the solid.
void ToLocal(const double x, const double y, const double z, double &u, double &v, double &w) const
void SetDirection(const double dx, const double dy, const double dz)
void ToGlobal(const double u, const double v, const double w, double &x, double &y, double &z) const
double m_cX
Centre of the solid.
double m_cPhi
Azimuthal angle.
std::string m_className
Class name.
std::vector< double > zv
Z-coordinates of vertices.
int volume
Reference to solid to which the panel belongs.
double a
Perpendicular vector.
double colour
Colour index.
std::vector< double > xv
X-coordinates of vertices.
std::vector< double > yv
Y-coordinates of vertices.