40 #ifndef EGS_UNION_GEOMETRY_
41 #define EGS_UNION_GEOMETRY_
45 #ifdef BUILD_UNIONG_DLL
46 #define EGS_UNIONG_EXPORT __declspec(dllexport)
48 #define EGS_UNIONG_EXPORT __declspec(dllimport)
50 #define EGS_UNIONG_LOCAL
54 #ifdef HAVE_VISIBILITY
55 #define EGS_UNIONG_EXPORT __attribute__ ((visibility ("default")))
56 #define EGS_UNIONG_LOCAL __attribute__ ((visibility ("hidden")))
58 #define EGS_UNIONG_EXPORT
59 #define EGS_UNIONG_LOCAL
142 const int *priorities = 0,
const string &Name =
"");
147 if (ireg < 0 || ireg >= nreg) {
151 return g[j]->isRealRegion(ireg-j*nmax);
155 for (
int j=0; j<ng; j++)
if (g[j]->
isInside(x)) {
162 for (
int j=0; j<ng; j++) {
163 int ij = g[j]->isWhere(x);
175 int medium(
int ireg)
const {
176 if (ireg < 0 || ireg >= nreg) {
180 return g[j]->medium(ireg-j*nmax);
184 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
189 int inew = g[jg]->howfar(ireg-jg*nmax,x,u,t,newmed,normal);
191 int jgnew = inew >= 0 ? jg : -1;
200 for (
int j=0; j<jg; j++) {
201 int ii = g[j]->howfar(-1,x,u,t,newmed,normal);
213 for (
int j=jg+1; j<ng; j++) {
214 int ii = g[j]->isWhere(xnew);
229 *newmed = g[jgnew]->medium(inew);
231 return inew + jgnew*nmax;
235 for (
int j=0; j<ng; j++) {
236 int ii = g[j]->howfar(-1,x,u,t,newmed,normal);
242 return inew < 0 ? -1 : inew + jg*nmax;
248 EGS_Float tmin = g[jg]->hownear(ireg-jg*nmax,x);
258 for (
int j=jg-1; j>=0; --j) {
259 EGS_Float t = g[j]->hownear(-1,x);
271 for (
int j=ng-1; j>=0; j--) {
272 EGS_Float t = g[j]->hownear(-1,x);
286 for (
int j=0; j<ng; j++) {
287 g[j]->getNextGeom(rndm);
291 void updatePosition(EGS_Float time) {
294 for (
int j=0; j<ng; j++) {
295 g[j]->updatePosition(time);
299 void containsDynamic(
bool &hasdynamic) {
302 for (
int j=0; j<ng; j++) {
304 g[j]->containsDynamic(hasdynamic);
311 for (
int j=0; j<ng; ++j) {
312 nstep += g[j]->getMaxStep();
317 const string &
getType()
const {
324 if (ireg < 0 || ireg >= nreg) {
328 return g[jg]->getRelativeRho(ireg-jg*nmax);
333 void setBScaling(
int start,
int end, EGS_Float rho);
336 if (ireg < 0 || ireg >= nreg) {
340 return g[jg]->getBScaling(ireg-jg*nmax);
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
virtual EGS_Float getBScaling(int ireg) const
Get the B field scaling factor in region ireg.
virtual void setBScaling(int start, int end, EGS_Float bf)
Set the B field scaling factor in regions.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
virtual const string & getType() const =0
Get the geometry type.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
virtual int howfar(int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0)=0
Calculate the distance to a boundary from x along the direction u.
virtual bool isRealRegion(int ireg) const
Returnes true if ireg is a real region, false otherwise.
virtual bool isInside(const EGS_Vector &x)=0
Is the position x inside the geometry?
virtual EGS_Float getRelativeRho(int ireg) const
Get the relative mass density in region ireg.
virtual int getMaxStep() const
Returns the maximum number of steps through the geometry.
virtual int medium(int ireg) const
Returns the medium index in region ireg.
virtual void setRelativeRho(int start, int end, EGS_Float rho)
Set the relative mass density in regions.
virtual void printInfo() const
Print information about this geometry.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
Base random number generator class. All random number generators should be derived from this class.
A geometry constructed as the union of other geometries.
int nmax
max. number of regions in all of the geoms.
int ng
number of geometries.
static string type
the geometry type
EGS_BaseGeometry ** g
the geometries that form the union.
A class representing 3D vectors.
EGS_BaseGeometry class header file.
const EGS_Float veryFar
A very large float.