44 #ifndef EGS_ISOTROPIC_SOURCE_
45 #define EGS_ISOTROPIC_SOURCE_
57 #ifdef BUILD_ISOTROPIC_SOURCE_DLL
58 #define EGS_ISOTROPIC_SOURCE_EXPORT __declspec(dllexport)
60 #define EGS_ISOTROPIC_SOURCE_EXPORT __declspec(dllimport)
62 #define EGS_ISOTROPIC_SOURCE_LOCAL
66 #ifdef HAVE_VISIBILITY
67 #define EGS_ISOTROPIC_SOURCE_EXPORT __attribute__ ((visibility ("default")))
68 #define EGS_ISOTROPIC_SOURCE_LOCAL __attribute__ ((visibility ("hidden")))
70 #define EGS_ISOTROPIC_SOURCE_EXPORT
71 #define EGS_ISOTROPIC_SOURCE_LOCAL
268 geom(geometry), regions(0), min_theta(85.), max_theta(95.),
269 buf_1(1), buf_2(-1), min_phi(0), max_phi(2*M_PI),
270 nrs(0), gc(IncludeAll), media(0), nms(0), gcm(IncludeSelected) {
282 if (!geom->deref()) {
286 if (nrs > 0 && regions) {
289 if (nms > 0 && media) {
300 x = shape->getRandomPoint(rndm);
303 if (gc == IncludeAll) {
304 ok = geom->isInside(x);
306 else if (gc == ExcludeAll) {
307 ok = !geom->isInside(x);
309 else if (gc == IncludeSelected) {
311 int ireg = geom->isWhere(x);
312 for (
int j=0; j<nrs; ++j) {
313 if (ireg == regions[j]) {
319 else if (gc == ExcludeSelected) {
321 int ireg = geom->isWhere(x);
322 for (
int j=0; j<nrs; ++j) {
323 if (ireg == regions[j]) {
332 if (gcm == IncludeSelected) {
334 int ireg = geom->isWhere(x);
335 int currentMedium = geom->medium(ireg);
336 for (
int j=0; j<nms; ++j) {
337 if (currentMedium == media[j]) {
343 else if (gcm == ExcludeSelected) {
345 int ireg = geom->isWhere(x);
346 for (
int j=0; j<nrs; ++j) {
347 if (ireg == media[j]) {
362 egsFatal(
"\nEGS_IsotropicSource::getPositionDirection:\n"
363 " For target shape %s, which is of type %s:\n"
364 " Failed to create a particle from the source after 100 000 attempts\n"
365 " Please ensure your .egsinp source definition -> source"
366 " -> shape encompasses the source region.\n",
367 shape->getObjectName().c_str(),
368 shape->getObjectType().c_str());
373 EGS_Float sinz = 1-u.
z*u.
z;
376 EGS_Float cphi, sphi;
377 EGS_Float phi = min_phi +(max_phi - min_phi)*rndm->
getUniform();
403 return (s != 0 && shape != 0);
410 int *regions, *media;
414 EGS_Float min_theta, max_theta;
415 EGS_Float buf_1, buf_2;
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
Base class for 'simple' particle sources.
virtual void getPositionDirection(EGS_RandomGenerator *rndm, EGS_Vector &x, EGS_Vector &u, EGS_Float &wt)=0
Sample a particle position and direction.
virtual bool isValid() const
Is this a valid source?
virtual bool storeFluenceState(ostream &data_out) const
Store the fluence state of this source to the data stream data_out.
virtual bool setFluenceState(istream &data)
Set the data related to the sampling of positions and directions to a state contained in the stream d...
EGS_I64 count
Number of statistically independent particles delivered so far.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
Base class for energy spectra. All energy spectra in the EGSnrc C++ class library are derived from th...
EGS_BaseShape * shape
The shape from which particles are emitted.
EGS_IsotropicSource(int Q, EGS_BaseSpectrum *Spec, EGS_BaseShape *Shape, EGS_BaseGeometry *geometry, const string &Name="", EGS_ObjectFactory *f=0)
Constructor.
GeometryConfinement
Geometry confinement options.
EGS_Float min_phi
avoid multi-calculating cos(min_theta) and cos(max_theta)
static void deleteObject(EGS_Object *o)
Delete an object.
Base random number generator class. All random number generators should be derived from this class.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
A class representing 3D vectors.
EGS_BaseGeometry class header file.
EGS_BaseSource class header file.
Attempts to fix broken math header files.
EGS_RandomGenerator class header file.
EGS_BaseShape and shape classes header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.