46 string EGS_StackGeometry::type =
"EGS_StackGeometry";
48 static bool EGS_STACKG_LOCAL inputSet =
false;
52 if (geoms.size() < 2)
egsFatal(
"EGS_StackGeometry::EGS_StackGeometry: "
53 " less than 2 geometries is not mermitted\n");
58 for (
int j=0; j<ng; j++) {
70 for (
int j=0; j<ng; j++) {
85 EGS_StackGeometry::~EGS_StackGeometry() {
86 for (
int j=0; j<ng; j++)
93 void EGS_StackGeometry::printInfo()
const {
97 g[j]->
getName().c_str(),g[j]->getType().c_str());
99 "=======================================================\n");
102 void EGS_StackGeometry::setMedia(
EGS_Input *,
int,
const int *) {
103 egsWarning(
"EGS_StackGeometry::setMedia: don't use this method. Use the\n"
104 " setMedia() methods of the geometry objects that make up this geometry\n");
107 void EGS_StackGeometry::setRelativeRho(
int start,
int end, EGS_Float rho) {
111 void EGS_StackGeometry::setRelativeRho(
EGS_Input *) {
112 egsWarning(
"EGS_StackGeometry::setRelativeRho(): don't use this method.\n"
113 " Use the setRelativeRho methods of the geometry objects that make up"
117 void EGS_StackGeometry::setBScaling(
int start,
int end, EGS_Float rho) {
121 void EGS_StackGeometry::setBScaling(
EGS_Input *) {
122 egsWarning(
"EGS_StackGeometry::setBScaling(): don't use this method.\n"
123 " Use the setBScaling methods of the geometry objects that make up"
129 static void setInputs() {
132 setBaseGeometryInputs(
false);
134 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_gstack"});
137 geomBlockInput->addSingleInput(
"geometries",
true,
"A list of names of previously defined geometries");
138 geomBlockInput->addSingleInput(
"tolerance",
false,
"A small floating number boundaryTolerance");
141 EGS_STACKG_EXPORT
string getExample() {
145 # Example of egs_gstack
149 geometries = geom1 geom2
150 # create geometries called geom1 geom2
157 EGS_STACKG_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
161 return geomBlockInput;
166 egsWarning(
"createGeometry(stack): null input?\n");
169 vector<string> gnames;
170 vector<EGS_BaseGeometry *> geoms;
171 int err = input->
getInput(
"geometries",gnames);
172 if (err || gnames.size() < 2) {
173 egsWarning(
"createGeometry(stack): missing/wrong 'geometries' input\n");
176 for (
unsigned int j=0; j<gnames.size(); j++) {
178 if (!gj)
egsWarning(
"createGeometry(stack): no geometry named %s "
179 " defined\n",gnames[j].c_str());
184 if (geoms.size() < 2) {
185 egsWarning(
"createGeometry(stack): must have at least 2 geometries\n");
193 err = input->
getInput(
"tolerance",tol);
200 int EGS_StackGeometry::getGlobalRegionOffset(
const string geomName) {
202 for (
int i=0; i<ng; i++) {
203 if (g[i] && g[i]->
getName() == geomName) {
209 for (
int i=0; i<ng; i++) {
221 void EGS_StackGeometry::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
223 vector<int> local_regs;
226 for (
int i=0; i<ng; i++) {
229 for (
int j=0; j<local_regs.size(); j++) {
230 regs.push_back(i*nmax + local_regs[j]);
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.
EGS_StackGeometry(const vector< EGS_BaseGeometry * > &geoms, const string &Name="")
Construct a geometry stack from the vector of geometries geom.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
A geometry stack: 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.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.