'''
ZapMeNot - a point kernel photon shielding library
Copyright (C) 2019-2025 C. Alan Ford
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import numbers
import importlib
pyvista_spec = importlib.util.find_spec("pyvista")
pyvista_found = pyvista_spec is not None
if pyvista_found:
import pyvista
[docs]
class Detector:
"""A location used to calculate exposure
Parameters
----------
x : float
X coordinate of detector location in cartesian coordinates
y : float
Y coordinate of detector location in cartesian coordinates
z : float
Z coordinate of detector location in cartesian coordinates
"""
'''
Attributes
----------
_location
'''
def __init__(self, x, y, z):
if isinstance(x, numbers.Number) and \
isinstance(y, numbers.Number) and \
isinstance(z, numbers.Number):
self.x = x
self.y = y
self.z = z
self._location = (x, y, z)
else:
raise ValueError("Invalid coordinates:" + str(x) + ", " + str(y) +
", " + str(z))
@property
def location(self):
""":class:`tuple` : The detector location in cartesian coordinates"""
return self._location
[docs]
def draw(self):
"""Creates a display object
Returns
-------
:class:`pyvista.PolyData`
A degenerate line object representing the detector.
"""
if pyvista_found:
# this returns a degenerate line, equivalent to a point
return pyvista.Line((self.x, self.y, self.z),
(self.x, self.y, self.z))