70 static bool EGS_SMART_ENVELOPE_LOCAL inputSet =
false;
73 egsWarning(
"EGS_SmartEnvelope::setMedia: don't use this method. Use the\n"
74 " setMedia() methods of the geometry objects that make up this geometry\n");
77 void EGS_SmartEnvelope::setRelativeRho(
int start,
int end, EGS_Float rho) {
81 void EGS_SmartEnvelope::setRelativeRho(
EGS_Input *) {
82 egsWarning(
"EGS_SmartEnvelope::setRelativeRho(): don't use this method."
83 " Use the\n setRelativeRho methods of the geometry objects that make up"
87 void EGS_SmartEnvelope::setBScaling(
int start,
int end, EGS_Float bf) {
91 void EGS_SmartEnvelope::setBScaling(
EGS_Input *) {
92 egsWarning(
"EGS_SmartEnvelope::setsetBScaling(): don't use this method."
93 " Use the\n setsetBScaling methods of the geometry objects that make up"
112 const vector<SmartEnvelopeAux *> &fgeoms,
const string &Name) :
114 reg_to_inscr(0), reg_to_base(0), local_start(0), itype(0) {
116 egsFatal(
"EGS_SmartEnvelope: base geometry must not be null\n");
120 n_in = fgeoms.size();
122 egsFatal(
"EGS_SmartEnvelope: no inscribed geometries!\n");
126 gindex =
new int [nbase];
127 itype =
new char [fgeoms.size()];
129 for (j=0; j<nbase; j++) {
132 for (j=0; j<fgeoms.size(); j++) {
135 int nreg_inscribed = 0;
137 for (j=0; j<fgeoms.size(); j++) {
138 geometries[j] = fgeoms[j]->g;
139 geometries[j]->ref();
140 int i = fgeoms[j]->ireg;
141 if (gindex[i] >= 0) {
143 " There can only be a single geometry inscribed in a region\n");
144 egsWarning(
" You are trying to inscribe %s into region %d but\n",
145 geometries[j]->getName().c_str(),i);
146 egsWarning(
" geometry %s is already inscribed in this region\n",
147 geometries[gindex[i]]->getName().c_str());
152 itype[j] = fgeoms[j]->type;
154 nreg_inscribed += geometries[j]->regions();
158 egsFatal(
"EGS_SmartEnvelope: errors during definition\n");
160 nreg = nbase + nreg_inscribed;
161 local_start =
new int [fgeoms.size()];
162 reg_to_inscr =
new int [nreg_inscribed];
163 reg_to_base =
new int [nreg_inscribed];
165 for (j=0; j<fgeoms.size(); j++) {
166 local_start[j] = nbase + nr;
167 int nj = geometries[j]->regions();
168 for (
int i=nr; i<nr+nj; ++i) {
170 reg_to_base[i] = fgeoms[j]->ireg;
176 if (!has_rho_scaling) {
177 for (
int j=0; j<n_in; j++) {
178 if (geometries[j]->hasRhoScaling()) {
179 has_rho_scaling =
true;
185 if (!has_B_scaling) {
186 for (
int j=0; j<n_in; j++) {
187 if (geometries[j]->hasBScaling()) {
188 has_B_scaling =
true;
195 EGS_SmartEnvelope::~EGS_SmartEnvelope() {
199 for (
int j=0; j<
n_in; j++) {
224 void EGS_SmartEnvelope::printInfo()
const {
234 "=======================================================\n");
238 static char EGS_SMART_ENVELOPE_LOCAL eeg_message1[] =
239 "createGeometry(smart envelope): %s\n";
240 static char EGS_SMART_ENVELOPE_LOCAL eeg_message2[] =
242 static char EGS_SMART_ENVELOPE_LOCAL eeg_message3[] =
243 "no 'base geometry' input?";
244 static char EGS_SMART_ENVELOPE_LOCAL eeg_message4[] =
245 "incorrect base geometry definition";
246 static char EGS_SMART_ENVELOPE_LOCAL eeg_message5[] =
247 "missing/incorrect 'base geometry' input";
248 static char EGS_SMART_ENVELOPE_LOCAL eeg_message6[] =
249 "createGeometry(smart envelope): no geometry with name %s defined\n";
255 static char EGS_SMART_ENVELOPE_LOCAL eeg_keyword1[] =
"base geometry";
256 static char EGS_SMART_ENVELOPE_LOCAL eeg_keyword2[] =
"geometry";
261 static void setInputs() {
264 setBaseGeometryInputs(
false);
266 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_smart_envelope"});
269 geomBlockInput->addSingleInput(
"base geometry",
true,
"The name of a previously defined geometry, that other geometries will be placed strictly inside.");
270 geomBlockInput->addSingleInput(
"inscribed geometries",
true,
"A list of previously defined geometries to place inside the base geometry. They must not intersect each other or extend beyond the base geometry.");
273 EGS_SMART_ENVELOPE_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
277 return geomBlockInput;
306 int err = i->
getInput(eeg_keyword1,bgname);
318 vector<SmartEnvelopeAux *> fgeoms;
321 while ((ix = input->
takeInputItem(
"inscribe geometry")) != 0) {
322 vector<string> values;
323 ix->
getInput(
"inscribe geometry",values);
324 if (values.size() < 2)
egsWarning(
"createGeometry(smart envelope):"
325 " %d inputs for 'inscribe geometry'? 2 or more are needed\n",values.size());
334 aux->ireg = atoi(values[1].c_str());
335 aux->type = values.size() == 3 ? atoi(values[2].c_str()) : 0;
337 if (aux->ireg < 0 || aux->ireg >= nbase) {
338 egsWarning(
"createGeometry(smart envelope): wrong "
339 "region index %d for inscribed geometry %s\n",
340 aux->ireg,gj->
getName().c_str());
344 fgeoms.push_back(aux);
354 for (
int j=0; j<fgeoms.size(); j++) {
361 int EGS_SmartEnvelope::getGlobalRegionOffset(
const string geomName) {
363 for (
int i=0; i<
n_in; i++) {
370 for (
int i=0; i<
n_in; i++) {
382 void EGS_SmartEnvelope::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
389 for (
int i=0; i<
n_in; i++) {
398 for (
int j=0; j<gregs.size(); j++) {
403 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.
int n_in
Number of inscribed geometries.
void setMedia(EGS_Input *, int, const int *)
Don't set media for an envelope geometry.
int * gindex
Index of inscribed geometries.
EGS_BaseGeometry * g
The envelope geometry.
int * local_start
First region for each inscribed geometry.
int * reg_to_inscr
Region to inscribed geometry conversion.
static string type
Geometry type.
int * reg_to_base
Region to base region conversion.
EGS_BaseGeometry ** geometries
The inscribed geometries.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
A smart envelope geometry: header.
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.