69 egsWarning(
"EGS_SmartEnvelope::setMedia: don't use this method. Use the\n"
70 " setMedia() methods of the geometry objects that make up this geometry\n");
73 void EGS_SmartEnvelope::setRelativeRho(
int start,
int end, EGS_Float rho) {
77 void EGS_SmartEnvelope::setRelativeRho(
EGS_Input *) {
78 egsWarning(
"EGS_SmartEnvelope::setRelativeRho(): don't use this method."
79 " Use the\n setRelativeRho methods of the geometry objects that make up"
83 void EGS_SmartEnvelope::setBScaling(
int start,
int end, EGS_Float bf) {
87 void EGS_SmartEnvelope::setBScaling(
EGS_Input *) {
88 egsWarning(
"EGS_SmartEnvelope::setsetBScaling(): don't use this method."
89 " Use the\n setsetBScaling methods of the geometry objects that make up"
108 const vector<SmartEnvelopeAux *> &fgeoms,
const string &Name) :
110 reg_to_inscr(0), reg_to_base(0), local_start(0), itype(0) {
112 egsFatal(
"EGS_SmartEnvelope: base geometry must not be null\n");
116 n_in = fgeoms.size();
118 egsFatal(
"EGS_SmartEnvelope: no inscribed geometries!\n");
122 gindex =
new int [nbase];
123 itype =
new char [fgeoms.size()];
125 for (j=0; j<nbase; j++) {
128 for (j=0; j<fgeoms.size(); j++) {
131 int nreg_inscribed = 0;
133 for (j=0; j<fgeoms.size(); j++) {
134 geometries[j] = fgeoms[j]->g;
135 geometries[j]->ref();
136 int i = fgeoms[j]->ireg;
137 if (gindex[i] >= 0) {
139 " There can only be a single geometry inscribed in a region\n");
140 egsWarning(
" You are trying to inscribe %s into region %d but\n",
141 geometries[j]->getName().c_str(),i);
142 egsWarning(
" geometry %s is already inscribed in this region\n",
143 geometries[gindex[i]]->getName().c_str());
148 itype[j] = fgeoms[j]->type;
150 nreg_inscribed += geometries[j]->regions();
154 egsFatal(
"EGS_SmartEnvelope: errors during definition\n");
156 nreg = nbase + nreg_inscribed;
157 local_start =
new int [fgeoms.size()];
158 reg_to_inscr =
new int [nreg_inscribed];
159 reg_to_base =
new int [nreg_inscribed];
161 for (j=0; j<fgeoms.size(); j++) {
162 local_start[j] = nbase + nr;
163 int nj = geometries[j]->regions();
164 for (
int i=nr; i<nr+nj; ++i) {
166 reg_to_base[i] = fgeoms[j]->ireg;
172 if (!has_rho_scaling) {
173 for (
int j=0; j<n_in; j++) {
174 if (geometries[j]->hasRhoScaling()) {
175 has_rho_scaling =
true;
181 if (!has_B_scaling) {
182 for (
int j=0; j<n_in; j++) {
183 if (geometries[j]->hasBScaling()) {
184 has_B_scaling =
true;
191 EGS_SmartEnvelope::~EGS_SmartEnvelope() {
195 for (
int j=0; j<
n_in; j++) {
220 void EGS_SmartEnvelope::printInfo()
const {
230 "=======================================================\n");
234 static char EGS_SMART_ENVELOPE_LOCAL eeg_message1[] =
235 "createGeometry(smart envelope): %s\n";
236 static char EGS_SMART_ENVELOPE_LOCAL eeg_message2[] =
238 static char EGS_SMART_ENVELOPE_LOCAL eeg_message3[] =
239 "no 'base geometry' input?";
240 static char EGS_SMART_ENVELOPE_LOCAL eeg_message4[] =
241 "incorrect base geometry definition";
242 static char EGS_SMART_ENVELOPE_LOCAL eeg_message5[] =
243 "missing/incorrect 'base geometry' input";
244 static char EGS_SMART_ENVELOPE_LOCAL eeg_message6[] =
245 "createGeometry(smart envelope): no geometry with name %s defined\n";
251 static char EGS_SMART_ENVELOPE_LOCAL eeg_keyword1[] =
"base geometry";
252 static char EGS_SMART_ENVELOPE_LOCAL eeg_keyword2[] =
"geometry";
283 int err = i->
getInput(eeg_keyword1,bgname);
295 vector<SmartEnvelopeAux *> fgeoms;
298 while ((ix = input->
takeInputItem(
"inscribe geometry")) != 0) {
299 vector<string> values;
300 ix->
getInput(
"inscribe geometry",values);
301 if (values.size() < 2)
egsWarning(
"createGeometry(smart envelope):"
302 " %d inputs for 'inscribe geometry'? 2 or more are needed\n",values.size());
311 aux->ireg = atoi(values[1].c_str());
312 aux->type = values.size() == 3 ? atoi(values[2].c_str()) : 0;
314 if (aux->ireg < 0 || aux->ireg >= nbase) {
315 egsWarning(
"createGeometry(smart envelope): wrong "
316 "region index %d for inscribed geometry %s\n",
317 aux->ireg,gj->
getName().c_str());
321 fgeoms.push_back(aux);
331 for (
int j=0; j<fgeoms.size(); j++) {
338 void EGS_SmartEnvelope::getLabelRegions(
const string &str, vector<int> ®s) {
345 for (
int i=0; i<
n_in; i++) {
354 for (
int j=0; j<gregs.size(); j++) {
359 regs.insert(regs.end(), gregs.begin(), gregs.end());
void setMedia(EGS_Input *, int, const int *)
Don't set media for an envelope geometry.
virtual const string & getType() const =0
Get the geometry type.
int regions() const
Returns the number of local regions in this geometry.
int deref()
Decrease the reference count to this geometry.
virtual void printInfo() const
Print information about this geometry.
int * gindex
Index of inscribed geometries.
A smart envelope geometry: header.
int setLabels(EGS_Input *input)
Set the labels from an input block.
bool hasRhoScaling() const
Does this geometry object have a mass density scaling feature?
int * reg_to_base
Region to base region conversion.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
bool isConvex() const
Is the geometry convex?
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
bool hasBScaling() const
Does this geometry object have a B field scaling feature?
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
int n_in
Number of inscribed geometries.
int * reg_to_inscr
Region to inscribed geometry conversion.
EGS_BaseGeometry * g
The envelope geometry.
int * local_start
First region for each inscribed geometry.
EGS_BaseGeometry ** geometries
The inscribed geometries.
int ref()
Increase the reference count to this geometry.
static string type
Geometry type.
static EGS_BaseGeometry * createSingleGeometry(EGS_Input *inp)
Create a single geometry from the input inp.
const string & getName() const
Get the name of this geometry.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.