51 static bool EGS_ENVELOPEG_LOCAL inputSet =
false;
54 egsWarning(
"EGS_EnvelopeGeometry::setMedia: don't use this method. Use the\n"
55 " setMedia() methods of the geometry objects that make up this geometry\n");
58 void EGS_EnvelopeGeometry::setRelativeRho(
int start,
int end, EGS_Float rho) {
62 void EGS_EnvelopeGeometry::setRelativeRho(
EGS_Input *) {
63 egsWarning(
"EGS_EnvelopeGeometry::setRelativeRho(): don't use this method."
64 " Use the\n setRelativeRho methods of the geometry objects that make up"
68 void EGS_EnvelopeGeometry::setBScaling(
int start,
int end, EGS_Float bf) {
72 void EGS_EnvelopeGeometry::setBScaling(
EGS_Input *) {
73 egsWarning(
"EGS_EnvelopeGeometry::setBScaling(): don't use this method."
74 " Use the\n setBScaling methods of the geometry objects that make up"
79 egsWarning(
"EGS_FastEnvelope::setMedia: don't use this method. Use the\n"
80 " setMedia() methods of the geometry objects that make up this geometry\n");
83 void EGS_FastEnvelope::setRelativeRho(
int start,
int end, EGS_Float rho) {
87 void EGS_FastEnvelope::setRelativeRho(
EGS_Input *) {
88 egsWarning(
"EGS_FastEnvelope::setRelativeRho(): don't use this method."
89 " Use the\n setRelativeRho methods of the geometry objects that make up"
93 void EGS_FastEnvelope::setBScaling(
int start,
int end, EGS_Float bf) {
97 void EGS_FastEnvelope::setBScaling(
EGS_Input *) {
98 egsWarning(
"EGS_FastEnvelope::setBScaling(): don't use this method."
99 " Use the\n setBScaling methods of the geometry objects that make up"
116 const vector<EGS_BaseGeometry *> &geoms,
const string &Name,
120 egsFatal(
"EGS_EnvelopeGeometry: base geometry must not be null\n");
124 new_indexing =
false;
128 int nreg_inscribed = 0;
131 for (
int j=0; j<n_in; j++) {
132 geometries[j] = geoms[j];
133 geometries[j]->
ref();
134 int nj = geometries[j]->regions();
138 nreg_inscribed += nj;
141 nreg = nbase + n_in*nmax;
145 if (!has_rho_scaling) {
146 for (
int j=0; j<n_in; j++) {
147 if (geometries[j]->hasRhoScaling()) {
148 has_rho_scaling =
true;
154 if (!has_B_scaling) {
155 for (
int j=0; j<n_in; j++) {
156 if (geometries[j]->hasBScaling()) {
157 has_B_scaling =
true;
168 local_start =
new int [n_in];
169 reg_to_inscr =
new int [nreg_inscribed];
171 for (
int j=0; j<n_in; j++) {
172 int n = geometries[j]->regions();
173 local_start[j] = nbase + ir;
174 for (
int i=0; i<n; i++) {
175 reg_to_inscr[ir++] = j;
183 const vector<EnvelopeAux *> &fgeoms,
const string &Name,
187 egsFatal(
"EGS_FastEnvelope: base geometry must not be null\n");
191 n_in = fgeoms.size();
193 new_indexing =
false;
195 egsFatal(
"EGS_FastEnvelope: no inscribed geometries!\n");
199 int *iaux =
new int [nbase];
201 for (j=0; j<nbase; j++) {
205 int nreg_inscribed = 0;
206 for (j=0; j<fgeoms.size(); j++) {
207 geometries[j] = fgeoms[j]->g;
208 geometries[j]->ref();
209 int nj = geometries[j]->regions();
210 nreg_inscribed += nj;
214 for (
int i=0; i<fgeoms[j]->nreg; i++) {
215 int k = fgeoms[j]->regs[i];
216 if (k >= 0 && k < nbase) {
222 n_start =
new int [nbase+1];
223 glist =
new int [nlist];
225 for (j=0; j<nbase; j++) {
228 for (
int l=0; l<fgeoms.size(); l++) {
229 for (
int i=0; i<fgeoms[l]->nreg; i++) {
230 int k = fgeoms[l]->regs[i];
238 n_start[nbase] = ilist;
239 nreg = nbase + n_in*nmax;
242 if (!has_rho_scaling) {
243 for (
int j=0; j<n_in; j++) {
244 if (geometries[j]->hasRhoScaling()) {
245 has_rho_scaling =
true;
252 if (!has_B_scaling) {
253 for (
int j=0; j<n_in; j++) {
254 if (geometries[j]->hasBScaling()) {
255 has_B_scaling =
true;
264 local_start =
new int [n_in];
265 reg_to_inscr =
new int [nreg_inscribed];
267 for (
int j=0; j<n_in; j++) {
268 int n = geometries[j]->regions();
269 local_start[j] = nbase + ir;
270 for (
int i=0; i<n; i++) {
271 reg_to_inscr[ir++] = j;
278 EGS_EnvelopeGeometry::~EGS_EnvelopeGeometry() {
282 for (
int j=0; j<
n_in; j++) {
298 EGS_FastEnvelope::~EGS_FastEnvelope() {
302 for (
int j=0; j<
n_in; j++) {
320 void EGS_EnvelopeGeometry::printInfo()
const {
328 "=======================================================\n");
331 void EGS_FastEnvelope::printInfo()
const {
339 "=======================================================\n");
343 static char EGS_ENVELOPEG_LOCAL eeg_message1[] =
344 "createGeometry(envelope geometry): %s\n";
345 static char EGS_ENVELOPEG_LOCAL eeg_message2[] =
347 static char EGS_ENVELOPEG_LOCAL eeg_message3[] =
348 "no 'base geometry' input?";
349 static char EGS_ENVELOPEG_LOCAL eeg_message4[] =
350 "incorrect base geometry definition";
351 static char EGS_ENVELOPEG_LOCAL eeg_message5[] =
352 "missing/incorrect 'base geometry' input";
353 static char EGS_ENVELOPEG_LOCAL eeg_message6[] =
354 "createGeometry(envelope geometry): no geometry with name %s defined\n";
355 static char EGS_ENVELOPEG_LOCAL eeg_message7[] =
356 "no inscirebed geometries defined?. I hope you know what you are doing";
357 static char EGS_ENVELOPEG_LOCAL eeg_message8[] =
358 "an error occured while constructing inscibed geometries";
360 static char EGS_ENVELOPEG_LOCAL eeg_keyword1[] =
"base geometry";
361 static char EGS_ENVELOPEG_LOCAL eeg_keyword2[] =
"geometry";
362 static char EGS_ENVELOPEG_LOCAL eeg_keyword3[] =
"inscribed geometries";
365 static void setInputs() {
368 setBaseGeometryInputs(
false);
370 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_genvelope"});
373 auto typePtr = geomBlockInput->addSingleInput(
"type",
false,
"The type of envelope", {
"EGS_FastEnvelope"});
374 geomBlockInput->addSingleInput(
"base geometry",
true,
"The name of a previously defined geometry");
375 geomBlockInput->addSingleInput(
"inscribed geometries",
true,
"A list of names of previously defined geometries, must be stictly inside the envelope");
378 EGS_ENVELOPEG_EXPORT
string getExample() {
382 # Example of egs_genvelope
385 library = egs_genvelope
386 base geometry = my_box
387 inscribed geometries = geom1 geom2
388 # geometries geom1 and geom2 must be defined before this one
394 EGS_ENVELOPEG_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
398 return geomBlockInput;
410 input->
getInput(
"new indexing style",indexing);
432 int err = i->
getInput(eeg_keyword1,bgname);
444 vector<EnvelopeAux *> fgeoms;
446 while ((ix = input->
takeInputItem(
"inscribe in regions")) != 0) {
447 vector<string> values;
448 ix->
getInput(
"inscribe in regions",values);
449 if (values.size() < 2)
egsWarning(
"createGeometry(envelope geometry):"
450 " %d inputs for 'inscribe in regions'? 2 or more are needed\n",values.size());
459 aux->nreg = values.size()-1;
460 aux->regs =
new int [aux->nreg];
461 for (
int j=0; j<aux->nreg; j++) {
462 aux->regs[j] = atoi(values[j+1].c_str());
464 fgeoms.push_back(aux);
469 if (fgeoms.size() > 0) {
473 for (
int j=0; j<fgeoms.size(); j++) {
483 vector<EGS_BaseGeometry *> geoms;
504 vector<string> igeoms;
505 int err = i->
getInput(eeg_keyword3,igeoms);
506 if (err || !igeoms.size()) {
510 for (
unsigned int j=0; j<igeoms.size(); j++) {
536 int EGS_EnvelopeGeometry::getGlobalRegionOffset(
const string geomName) {
538 for (
int i=0; i<
n_in; i++) {
552 for (
int i=0; i<
n_in; i++) {
569 int EGS_FastEnvelope::getGlobalRegionOffset(
const string geomName) {
571 for (
int i=0; i<
n_in; i++) {
586 for (
int i=0; i<
n_in; i++) {
603 void EGS_EnvelopeGeometry::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
611 for (
int i=0; i<
n_in; i++) {
626 for (
int j=0; j<gregs.size(); j++) {
631 regs.insert(regs.end(), gregs.begin(), gregs.end());
640 void EGS_FastEnvelope::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
648 for (
int i=0; i<
n_in; i++) {
663 for (
int j=0; j<gregs.size(); j++) {
668 regs.insert(regs.end(), gregs.begin(), gregs.end());
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual int getGlobalRegionOffset(const string geomName)
Get the global region number for the first region in the geometry.
int deref()
Decrease the reference count to this geometry.
static EGS_BaseGeometry * createSingleGeometry(EGS_Input *inp)
Create a single geometry from the input inp.
virtual const string & getType() const =0
Get the geometry type.
bool hasBScaling() const
Does this geometry object have a B field scaling feature?
virtual bool hasRhoScaling()
Does this geometry object have a mass density scaling feature?
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
const string & getName() const
Get the name of this geometry.
bool isConvex() const
Is the geometry convex?
int regions() const
Returns the number of local regions in this geometry.
int setLabels(EGS_Input *input)
Set the labels from an input block.
virtual void printInfo() const
Print information about this geometry.
int ref()
Increase the reference count to this geometry.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
virtual void getLabelRegions(const string &str, vector< int > ®s, bool sanitize=true)
Get the list of all regions labeled with str.
An envelope geometry class.
EGS_BaseGeometry * g
The envelope geometry.
int n_in
Number of inscribed geometries.
static string type
Geometry type.
int * local_start
First region for each inscribed geometry.
void setMedia(EGS_Input *, int, const int *)
Don't set media for an envelope geometry.
int nbase
Number of regions in the base geometry.
bool new_indexing
If true, use new indexing style.
EGS_BaseGeometry ** geometries
The inscribed geometries.
int * reg_to_inscr
Region to inscribed geometry conversion.
An envelope geometry class.
int nbase
Number of regions in the base geometry.
EGS_BaseGeometry ** geometries
The inscribed geometries.
int * local_start
First region for each inscribed geometry.
int n_in
Number of inscribed geometries.
int * reg_to_inscr
Region to inscribed geometry conversion.
EGS_BaseGeometry * g
The envelope geometry.
static string type
Geometry type.
void setMedia(EGS_Input *, int, const int *)
Don't set media for an envelope geometry.
bool new_indexing
If true, use new indexing style.
An envelope geometry: header.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.