49 static bool EGS_UNIONG_LOCAL inputSet =
false;
52 egsWarning(
"EGS_UnionGeometry::setMedia: don't use this method. Use the\n"
53 " setMedia() methods of the geometry objects that make up this geometry\n");
56 void EGS_UnionGeometry::setRelativeRho(
int start,
int end, EGS_Float rho) {
60 void EGS_UnionGeometry::setRelativeRho(
EGS_Input *) {
61 egsWarning(
"EGS_UnionGeometry::setRelativeRho(): don't use this method. "
62 "Use the\n setRelativeRho() methods of the geometry objects that make "
63 "up this geometry\n");
66 void EGS_UnionGeometry::setBScaling(
int start,
int end, EGS_Float bf) {
70 void EGS_UnionGeometry::setBScaling(
EGS_Input *) {
71 egsWarning(
"EGS_UnionGeometry::setBScaling(): don't use this method. "
72 "Use the\n setBScaling() methods of the geometry objects that make "
73 "up this geometry\n");
77 const int *priorities,
const string &Name) :
80 if (
ng <= 0)
egsFatal(
"EGS_UnionGeometry::EGS_UnionGeometry: attempt "
81 " to construct a union geometry from zero geometries\n");
83 if (
ng == 1)
egsWarning(
"EGS_UnionGeometry::EGS_UnionGeometry: why "
84 "do you want to make a union out of a single geometry?\n");
88 int *order =
new int [
ng];
92 bool *is_used =
new bool [
ng];
93 for (j=0; j<
ng; j++) {
96 for (j=0; j<
ng; j++) {
98 for (imax=0; imax<
ng-1; imax++)
if (!is_used[imax]) {
101 int pmax = priorities[imax];
102 for (
int i=0; i<
ng; i++) {
103 if (!is_used[i] && priorities[i] > pmax) {
105 pmax = priorities[i];
109 is_used[imax] =
true;
115 for (j=0; j<
ng; j++) {
122 for (j=0; j<
ng; j++) {
137 for (j=0; j<
ng; j++) {
150 if (!
nmax)
egsFatal(
"EGS_UnionGeometry::EGS_UnionGeometry: all geometries"
151 " have zero regions?\n");
155 EGS_UnionGeometry::~EGS_UnionGeometry() {
156 for (
int j=0; j<
ng; j++) {
164 void EGS_UnionGeometry::printInfo()
const {
168 g[j]->
getName().c_str(),
g[j]->getType().c_str());
170 "=======================================================\n");
174 static void setInputs() {
177 setBaseGeometryInputs(
false);
179 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_gunion"});
182 geomBlockInput->addSingleInput(
"geometries",
true,
"A list of names of previously defined geometries");
183 geomBlockInput->addSingleInput(
"priorities",
false,
"A list of integers defining the geometry priorities. If neglected, the priority decreases when moving from the first to the last of the geometry list.");
186 EGS_UNIONG_EXPORT
string getExample() {
190 # Example of egs_gunion
194 geometries = my_box my_sphere
200 EGS_UNIONG_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
204 return geomBlockInput;
209 egsWarning(
"createGeometry(union): null input?\n");
212 vector<EGS_BaseGeometry *> geoms;
213 vector<string> gnames;
214 int err = input->
getInput(
"geometries",gnames);
215 if (err || gnames.size() < 1) {
216 egsWarning(
"createGeometry(union): missing/wrong 'geometries' input\n");
219 for (
unsigned int j=0; j<gnames.size(); j++) {
221 if (!gj)
egsWarning(
"createGeometry(union): no geometry named %s "
222 "defined\n",gnames[j].c_str());
227 if (geoms.size() < 1) {
228 egsWarning(
"createGeometry(union): must have at least one geometry\n");
232 err = input->
getInput(
"priorities",pri);
235 if (pri.size() == geoms.size()) {
236 p =
new int [pri.size()];
237 for (
int i=0; i<pri.size(); i++) {
241 else egsWarning(
"createGeometry(union): the number of priorities (%d)"
242 " is not the same as the number of geometries (%d) => ignoring\n",
243 pri.size(),geoms.size());
255 int EGS_UnionGeometry::getGlobalRegionOffset(
const string geomName) {
257 for (
int i=0; i<
ng; i++) {
258 if (
g[i] &&
g[i]->
getName() == geomName) {
264 for (
int i=0; i<
ng; i++) {
276 void EGS_UnionGeometry::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
280 for (
int i=0; i<
ng; i++) {
289 for (
int j=0; j<gregs.size(); j++) {
294 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.
int nreg
Number of local regions in this geometry.
bool has_B_scaling
Does this geometry has B field scaling factor?
bool is_convex
Is this geometry convex?
bool has_rho_scaling
Does this geometry have relative mass density scvaling?
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.
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.
A geometry constructed as the union of other geometries.
void setMedia(EGS_Input *, int, const int *)
Don't set media when defining the union.
int nmax
max. number of regions in all of the geoms.
int ng
number of geometries.
static string type
the geometry type
EGS_BaseGeometry ** g
the geometries that form the union.
EGS_UnionGeometry(const vector< EGS_BaseGeometry * > &geoms, const int *priorities=0, const string &Name="")
Construct a geometry union from the vector of geometries geom.
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.