48 const string EGS_PLANES_LOCAL xproj_type(
"EGS_Xplanes");
49 const string EGS_PLANES_LOCAL yproj_type(
"EGS_Yplanes");
50 const string EGS_PLANES_LOCAL zproj_type(
"EGS_Zplanes");
51 const string EGS_PLANES_LOCAL proj_type(
"EGS_Planes");
53 static bool EGS_PLANES_LOCAL inputSet =
false;
55 string EGS_PlaneCollection::type =
"EGS_PlaneCollection";
57 EGS_PlaneCollection::EGS_PlaneCollection(
int Np,
const EGS_Float *pos,
59 if (Np < 2)
egsFatal(
"EGS_PlaneCollection::EGS_PlaneCollection: "
60 " you nead at least 2 planes\n");
64 for (
int j=0; j<np; j++) {
71 EGS_PlaneCollection::~EGS_PlaneCollection() {
73 for (
int j=0; j<np; j++)
if (!planes[j]->
deref()) {
79 void EGS_PlaneCollection::printInfo()
const {
83 for (j=0; j<np; j++) {
87 for (j=0; j<np; j++) {
91 egsInformation(
"\n=====================================================\n");
95 static void setInputs() {
98 setBaseGeometryInputs();
100 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_planes"});
103 auto typePtr = geomBlockInput->addSingleInput(
"type",
true,
"The type of plane.", {
"EGS_XPlanes",
"EGS_YPlanes",
"EGS_ZPlanes",
"EGS_Planes",
"EGS_PlaneCollection"});
105 auto posPtr = geomBlockInput->addSingleInput(
"positions",
false,
"A list of plane co-ordinates");
108 auto norPtr = geomBlockInput->addSingleInput(
"normal",
true,
"The plane normal (x, y, z)");
109 norPtr->addDependency(typePtr,
"EGS_Planes");
112 auto normsPtr = geomBlockInput->addSingleInput(
"normals",
true,
"3 numbers defining a unit vector as the normal for each plane");
113 normsPtr->addDependency(typePtr,
"EGS_PlaneCollection");
116 auto fpPtr = geomBlockInput->addSingleInput(
"first plane",
false,
"The position of the first plane.");
117 auto slabPtr = geomBlockInput->addSingleInput(
"slab thickness",
false,
"A list of the thickness between each set of planes");
118 auto numPtr = geomBlockInput->addSingleInput(
"number of slabs",
false,
"A list of the number of slabs");
121 fpPtr->addDependency(posPtr,
"",
true);
122 slabPtr->addDependency(posPtr,
"",
true);
123 numPtr->addDependency(posPtr,
"",
true);
124 posPtr->addDependency(fpPtr,
"",
true);
125 posPtr->addDependency(slabPtr,
"",
true);
126 posPtr->addDependency(numPtr,
"",
true);
129 EGS_PLANES_EXPORT
string getExample() {
133 # Examples of the egs_planes
144 # EGS_PlaneCollection example
147 type = EGS_PlaneCollection
148 name = my_plane_collection
149 normals = 0 0 1 0.1 -0.1 1 -0.1 -0.3 1 0 0 1
150 positions = -5 -2 2 12
152 media = air water air
161 EGS_PLANES_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
165 return geomBlockInput;
170 int err = input->
getInput(
"type",type);
172 egsWarning(
"createGeometry(planes): missing type key\n");
176 vector<EGS_Float> thick;
178 vector<EGS_Float> pos;
179 int err_first = input->
getInput(
"first plane",first);
180 int err_thick = input->
getInput(
"slab thickness",thick);
181 int err_nthick = input->
getInput(
"number of slabs",nthick);
182 if (!err_first && !err_thick && !err_nthick) {
183 if (thick.size() != nthick.size() || !thick.size()) {
184 egsWarning(
"createGeometry(planes): number of 'slab thickness' and"
185 "\n 'number of slabs' inputs must be the same and not zero\n");
186 egsWarning(
" got %d and %d inputs --> input ignored\n",
187 thick.size(),nthick.size());
190 pos.push_back(first);
192 for (
int i=0; i<thick.size(); i++) {
193 for (
int l=0; l<nthick[i]; ++l) {
194 pos.push_back(pos[j++]+thick[i]);
200 err = input->
getInput(
"positions",pos);
202 egsWarning(
"createGeometry(planes): missing/wrong 'positions' "
203 "input and missing/wrong multiple plane input\n");
208 if (type ==
"EGS_Xplanes") g =
new EGS_PlanesX(pos,
"",
210 else if (type ==
"EGS_Yplanes") g =
new EGS_PlanesY(pos,
"",
212 else if (type ==
"EGS_Zplanes") g =
new EGS_PlanesZ(pos,
"",
214 else if (type ==
"EGS_Planes") {
217 if (err || a.size() != 3) {
218 egsWarning(
"createGeometry(planes): missing/wrong normal input\n");
224 else if (type ==
"EGS_PlaneCollection") {
227 if (err || a.size() < 6) {
228 egsWarning(
"createGeometry(planes): missing/wrong normal input\n");
232 if (np != pos.size()) {
233 egsWarning(
"createGeometry(planes): number of plane normals (%d)\n"
234 " is not the same as number of plane positions (%d) for a"
235 " plane collection\n",np,pos.size());
238 EGS_Float *p =
new EGS_Float [np];
240 for (
int j=0; j<np; j++) {
242 normal[j] =
EGS_Vector(a[3*j],a[3*j+1],a[3*j+2]);
247 egsWarning(
"createGeometry(planes): unknown type %s\n",type.c_str());
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
int deref()
Decrease the reference count to this geometry.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
int setLabels(EGS_Input *input)
Set the labels from an input block.
virtual void printInfo() const
Print information about this geometry.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
A collection of non-parallel planes.
A set of parallel planes.
A projector into any plane.
A class representing 3D vectors.
A projector into the x-plane.
A projector into the y-plane.
A projector into the z-plane.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Sets of parallel planes and a plane collection.
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.