39 #ifndef EGS_UNION_GEOMETRY_
40 #define EGS_UNION_GEOMETRY_
44 #ifdef BUILD_UNIONG_DLL
45 #define EGS_UNIONG_EXPORT __declspec(dllexport)
47 #define EGS_UNIONG_EXPORT __declspec(dllimport)
49 #define EGS_UNIONG_LOCAL
53 #ifdef HAVE_VISIBILITY
54 #define EGS_UNIONG_EXPORT __attribute__ ((visibility ("default")))
55 #define EGS_UNIONG_LOCAL __attribute__ ((visibility ("hidden")))
57 #define EGS_UNIONG_EXPORT
58 #define EGS_UNIONG_LOCAL
141 const int *priorities = 0,
const string &Name =
"");
146 if (ireg < 0 || ireg >= nreg) {
150 return g[j]->isRealRegion(ireg-j*nmax);
154 for (
int j=0; j<ng; j++)
if (g[j]->
isInside(x)) {
161 for (
int j=0; j<ng; j++) {
162 int ij = g[j]->isWhere(x);
174 int medium(
int ireg)
const {
175 if (ireg < 0 || ireg >= nreg) {
179 return g[j]->medium(ireg-j*nmax);
183 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
188 int inew = g[jg]->howfar(ireg-jg*nmax,x,u,t,newmed,normal);
190 int jgnew = inew >= 0 ? jg : -1;
199 for (
int j=0; j<jg; j++) {
200 int ii = g[j]->howfar(-1,x,u,t,newmed,normal);
212 for (
int j=jg+1; j<ng; j++) {
213 int ii = g[j]->isWhere(xnew);
228 *newmed = g[jgnew]->medium(inew);
230 return inew + jgnew*nmax;
234 for (
int j=0; j<ng; j++) {
235 int ii = g[j]->howfar(-1,x,u,t,newmed,normal);
241 return inew < 0 ? -1 : inew + jg*nmax;
247 EGS_Float tmin = g[jg]->hownear(ireg-jg*nmax,x);
257 for (
int j=jg-1; j>=0; --j) {
258 EGS_Float t = g[j]->hownear(-1,x);
270 for (
int j=ng-1; j>=0; j--) {
271 EGS_Float t = g[j]->hownear(-1,x);
284 for (
int j=0; j<ng; ++j) {
285 nstep += g[j]->getMaxStep();
290 const string &
getType()
const {
297 if (ireg < 0 || ireg >= nreg) {
301 return g[jg]->getRelativeRho(ireg-jg*nmax);
306 void setBScaling(
int start,
int end, EGS_Float rho);
309 if (ireg < 0 || ireg >= nreg) {
313 return g[jg]->getBScaling(ireg-jg*nmax);
virtual const string & getType() const =0
Get the geometry type.
virtual bool isInside(const EGS_Vector &x)=0
Is the position x inside the geometry?
virtual int medium(int ireg) const
Returns the medium index in region ireg.
virtual void printInfo() const
Print information about this geometry.
virtual int getMaxStep() const
Returns the maximum number of steps through the geometry.
A class representing 3D vectors.
EGS_BaseGeometry ** g
the geometries that form the union.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
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.
const EGS_Float veryFar
A very large float.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual void setRelativeRho(int start, int end, EGS_Float rho)
Set the relative mass density in regions.
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.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
A geometry constructed as the union of other geometries.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
static string type
the geometry type
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
int nmax
max. number of regions in all of the geoms.
virtual EGS_Float getRelativeRho(int ireg) const
Get the relative mass density in region ireg.
virtual bool isRealRegion(int ireg) const
Returnes true if ireg is a real region, false otherwise.
EGS_BaseGeometry class header file.
int ng
number of geometries.