70 egsWarning(
"EGS_SmartEnvelope::setMedia: don't use this method. Use the\n"
71 " setMedia() methods of the geometry objects that make up this geometry\n");
74 void EGS_SmartEnvelope::setRelativeRho(
int start,
int end, EGS_Float rho) {
78 void EGS_SmartEnvelope::setRelativeRho(
EGS_Input *) {
79 egsWarning(
"EGS_SmartEnvelope::setRelativeRho(): don't use this method."
80 " Use the\n setRelativeRho methods of the geometry objects that make up"
84 void EGS_SmartEnvelope::setBScaling(
int start,
int end, EGS_Float bf) {
88 void EGS_SmartEnvelope::setBScaling(
EGS_Input *) {
89 egsWarning(
"EGS_SmartEnvelope::setsetBScaling(): don't use this method."
90 " Use the\n setsetBScaling methods of the geometry objects that make up"
109 const vector<SmartEnvelopeAux *> &fgeoms,
const string &Name) :
111 reg_to_inscr(0), reg_to_base(0), local_start(0), itype(0) {
113 egsFatal(
"EGS_SmartEnvelope: base geometry must not be null\n");
117 n_in = fgeoms.size();
119 egsFatal(
"EGS_SmartEnvelope: no inscribed geometries!\n");
123 gindex =
new int [nbase];
124 itype =
new char [fgeoms.size()];
126 for (j=0; j<nbase; j++) {
129 for (j=0; j<fgeoms.size(); j++) {
132 int nreg_inscribed = 0;
134 for (j=0; j<fgeoms.size(); j++) {
135 geometries[j] = fgeoms[j]->g;
136 geometries[j]->ref();
137 int i = fgeoms[j]->ireg;
138 if (gindex[i] >= 0) {
140 " There can only be a single geometry inscribed in a region\n");
141 egsWarning(
" You are trying to inscribe %s into region %d but\n",
142 geometries[j]->getName().c_str(),i);
143 egsWarning(
" geometry %s is already inscribed in this region\n",
144 geometries[gindex[i]]->getName().c_str());
149 itype[j] = fgeoms[j]->type;
151 nreg_inscribed += geometries[j]->regions();
155 egsFatal(
"EGS_SmartEnvelope: errors during definition\n");
157 nreg = nbase + nreg_inscribed;
158 local_start =
new int [fgeoms.size()];
159 reg_to_inscr =
new int [nreg_inscribed];
160 reg_to_base =
new int [nreg_inscribed];
162 for (j=0; j<fgeoms.size(); j++) {
163 local_start[j] = nbase + nr;
164 int nj = geometries[j]->regions();
165 for (
int i=nr; i<nr+nj; ++i) {
167 reg_to_base[i] = fgeoms[j]->ireg;
173 if (!has_rho_scaling) {
174 for (
int j=0; j<n_in; j++) {
175 if (geometries[j]->hasRhoScaling()) {
176 has_rho_scaling =
true;
182 if (!has_B_scaling) {
183 for (
int j=0; j<n_in; j++) {
184 if (geometries[j]->hasBScaling()) {
185 has_B_scaling =
true;
192 EGS_SmartEnvelope::~EGS_SmartEnvelope() {
196 for (
int j=0; j<
n_in; j++) {
221 void EGS_SmartEnvelope::printInfo()
const {
231 "=======================================================\n");
235 static char EGS_SMART_ENVELOPE_LOCAL eeg_message1[] =
236 "createGeometry(smart envelope): %s\n";
237 static char EGS_SMART_ENVELOPE_LOCAL eeg_message2[] =
239 static char EGS_SMART_ENVELOPE_LOCAL eeg_message3[] =
240 "no 'base geometry' input?";
241 static char EGS_SMART_ENVELOPE_LOCAL eeg_message4[] =
242 "incorrect base geometry definition";
243 static char EGS_SMART_ENVELOPE_LOCAL eeg_message5[] =
244 "missing/incorrect 'base geometry' input";
245 static char EGS_SMART_ENVELOPE_LOCAL eeg_message6[] =
246 "createGeometry(smart envelope): no geometry with name %s defined\n";
252 static char EGS_SMART_ENVELOPE_LOCAL eeg_keyword1[] =
"base geometry";
253 static char EGS_SMART_ENVELOPE_LOCAL eeg_keyword2[] =
"geometry";
284 int err = i->
getInput(eeg_keyword1,bgname);
296 vector<SmartEnvelopeAux *> fgeoms;
299 while ((ix = input->
takeInputItem(
"inscribe geometry")) != 0) {
300 vector<string> values;
301 ix->
getInput(
"inscribe geometry",values);
302 if (values.size() < 2)
egsWarning(
"createGeometry(smart envelope):"
303 " %d inputs for 'inscribe geometry'? 2 or more are needed\n",values.size());
312 aux->ireg = atoi(values[1].c_str());
313 aux->type = values.size() == 3 ? atoi(values[2].c_str()) : 0;
315 if (aux->ireg < 0 || aux->ireg >= nbase) {
316 egsWarning(
"createGeometry(smart envelope): wrong "
317 "region index %d for inscribed geometry %s\n",
318 aux->ireg,gj->
getName().c_str());
322 fgeoms.push_back(aux);
332 for (
int j=0; j<fgeoms.size(); j++) {
339 void EGS_SmartEnvelope::getLabelRegions(
const string &str, vector<int> ®s) {
346 for (
int i=0; i<
n_in; i++) {
355 for (
int j=0; j<gregs.size(); j++) {
360 regs.insert(regs.end(), gregs.begin(), gregs.end());
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
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.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
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.
const string & getName() const
Get the name of this geometry.
bool isConvex() const
Is the geometry convex?
bool hasRhoScaling() const
Does this geometry object have a mass density scaling feature?
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.
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.