49 string EGS_IPlanes::type =
"EGS_IPlanes";
50 string EGS_RadialRepeater::type =
"EGS_RadialRepeater";
52 static bool EGS_IPLANES_LOCAL inputSet =
false;
55 const EGS_Float *angles,
const string &Name,
bool degree) :
59 d =
new EGS_Float[
nreg];
61 EGS_Float phi180 = M_PI;
66 for (j=0; j<
nreg; j++) {
72 phi = angles[j-np] + phi180;
77 EGS_Float cphi = cos(phi), sphi = sin(phi);
84 int np,
const EGS_Vector *aj,
const EGS_Float *dj,
88 d =
new EGS_Float[
nreg];
90 for (j=0; j<
nreg; j++) {
97 int np, EGS_Float first,
const string &Name) :
100 EGS_Float dphi = 2*M_PI/
nreg;
103 d =
new EGS_Float[
nreg];
104 for (
int j=0; j<
nreg; j++) {
105 EGS_Float phi = first + dphi*j;
106 EGS_Float cphi = cos(phi), sphi = sin(phi);
112 EGS_IPlanes::~EGS_IPlanes() {
117 int EGS_IPlanes::isWhere(
const EGS_Vector &x) {
118 EGS_Float aux_old = a[0]*x;
119 for (
int j=1; j<
nreg; j++) {
120 EGS_Float aux = a[j]*x;
121 if (aux_old >= d[j-1] && aux < d[j]) {
129 int EGS_IPlanes::inside(
const EGS_Vector &x) {
130 EGS_Float aux_old = a[0]*x;
131 for (
int j=1; j<
nreg; j++) {
132 EGS_Float aux = a[j]*x;
133 if (aux_old >= d[j-1] && aux < d[j]) {
141 int EGS_IPlanes::howfar(
int ireg,
const EGS_Vector &x,
144 egsFatal(
"EGS_IPlanes::howfar: ireg (%d) can not be negative\n",ireg);
146 EGS_Float t1 = t, t2 = t;
147 EGS_Float up = a[ireg]*u;
150 t1 = (d[ireg] - a[ireg]*x)/up;
171 t2 = (d[j] - a[j]*x)/up;
186 EGS_Float EGS_IPlanes::hownear(
int ireg,
const EGS_Vector &x) {
188 egsFatal(
"EGS_IPlanes::hownear: ireg (%d) can not be negative\n",ireg);
190 EGS_Float t1 = a[ireg]*x - d[ireg];
195 EGS_Float t2 = d[j] - a[j]*x;
199 void EGS_IPlanes::printInfo()
const {
202 axis.
x,axis.
y,axis.
z);
204 "\n=======================================================\n");
209 EGS_RadialRepeater::EGS_RadialRepeater(
const EGS_Vector &Xo,
212 EGS_Float dphi = 2*M_PI/np;
224 for (
int j=0; j<nrep; j++) {
227 EGS_Float phi = dphi*j;
234 EGS_RadialRepeater::~EGS_RadialRepeater() {
236 if (!iplanes->
deref()) {
244 void EGS_RadialRepeater::printInfo()
const {
246 egsInformation(
"%d uniformely rotated replicas of geometry %s with "
247 "phi_o=%g degrees\n",nrep,g->
getName().c_str(),
249 EGS_Vector xo(iplanes->getAxisXo()), axis(iplanes->getAxisDirection());
250 egsInformation(
"Axis of rotation is xo=(%g,%g,%g) a=(%g,%g,%g)\n",
251 xo.
x,xo.
y,xo.
z,axis.x,axis.y,axis.z);
264 static void setInputs() {
267 setBaseGeometryInputs();
269 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_iplanes"});
272 auto typePtr = geomBlockInput->addSingleInput(
"type",
false,
"The type of iplane", {
"EGS_RadialRepeater"});
274 geomBlockInput->addSingleInput(
"axis",
true,
"A list of three coordinates of a point on the axis and three direction cosines defining the axis direction");
277 auto anglesPtr = geomBlockInput->addSingleInput(
"angles",
false,
"A list of angles of rotation around the axis for the planes in degrees, must be in increasing order and between 0 and 180");
278 auto anglesRadPtr = geomBlockInput->addSingleInput(
"angles in radian",
false,
"A list of angles of rotation around the axis for the planes in degrees, in increasing order");
280 anglesRadPtr->addDependency(anglesPtr,
"",
true);
281 anglesRadPtr->addDependency(typePtr,
"",
true);
282 anglesPtr->addDependency(anglesRadPtr,
"",
true);
283 anglesPtr->addDependency(typePtr,
"",
true);
286 auto geoPtr = geomBlockInput->addSingleInput(
"repeated geometry",
true,
"The exsisting geometry that is repeated");
287 geoPtr->addDependency(typePtr,
"EGS_RadialRepeater");
288 auto numPtr = geomBlockInput->addSingleInput(
"number of repetitions",
true,
"The number of times the geometry is repeated");
289 numPtr->addDependency(typePtr,
"EGS_RadialRepeater");
290 auto medPtr = geomBlockInput->addSingleInput(
"medium",
false,
"The medium with which the space outside the replicated geometry is filled");
291 medPtr->addDependency(typePtr,
"EGS_RadialRepeater");
292 auto firstanglePtr = geomBlockInput->addSingleInput(
"first angle",
false,
"First angle of the repetitions, phi_o, in degrees");
293 firstanglePtr->addDependency(typePtr,
"EGS_RadialRepeater");
294 auto firstangleRadPtr = geomBlockInput->addSingleInput(
"first angle in radians",
false,
"First angle of the repetitions, phi_o, in radians");
295 firstangleRadPtr->addDependency(typePtr,
"EGS_RadialRepeater");
298 firstangleRadPtr->addDependency(firstanglePtr,
"",
true);
299 firstanglePtr->addDependency(firstangleRadPtr,
"",
true);
302 EGS_IPLANES_EXPORT
string getExample() {
306 # Example of egs_iplanes
308 library = egs_iplanes
311 angles = 0 30 60 90 120 150
314 # Example of EGS_RadialRepeater
316 library = egs_iplanes
317 type = EGS_RadialRepeater
319 number of repetitions = 5
320 repeated geometry = my_geom
321 # use with geometry called my_geom
326 EGS_IPLANES_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
330 return geomBlockInput;
335 egsWarning(
"createGeometry(iplanes): null input?\n");
338 vector<EGS_Float> axis;
340 int err = input->
getInput(
"axis",axis);
341 if (!err && axis.size() == 6) {
346 else egsWarning(
"createGeometry(iplanes): wrong/missing axis input\n"
347 " using Xo=(0,0,0), a=(0,0,1)\n");
350 if (!err && (type ==
"EGS_RadialRepeater" || type ==
"repeater")) {
352 err = input->
getInput(
"number of repetitions",np);
354 egsWarning(
"createGeometry(iplanes): missing/wrong "
355 "'number of repetitions' input\n");
359 err = input->
getInput(
"repeated geometry",gname);
361 egsWarning(
"createGeometry(iplanes): missing 'repeated geometry'"
367 egsWarning(
"createGeometry(iplanes): no geometry named %s exists\n",
373 err = input->
getInput(
"first angle",tmp1);
374 int err1 = input->
getInput(
"first angle in radians",tmp2);
376 phi_o = tmp1*M_PI/180;
385 err = input->
getInput(
"medium",medium);
389 result->setRLabels(input);
394 vector<EGS_Float> angles;
395 err = input->
getInput(
"angles",angles);
396 bool is_degree =
true;
397 EGS_Float max_angle = 180;
399 err = input->
getInput(
"angles in radian",angles);
401 egsWarning(
"createGeometry(iplanes): wrong/missing 'angles' or "
402 "'angles in radian' input\n");
408 EGS_Float *ang =
new EGS_Float [angles.size()];
409 for (
int j=0; j<angles.size(); j++) {
418 if (ang[j] <= ang[j-1]) {
419 egsWarning(
"createGeometry(iplanes): angles must be ordered"
420 " in increasing order\n");
426 int nang = angles.size();
427 EGS_Float ang_diff = ang[nang-1]-ang[0];
428 if (ang_diff > max_angle) {
429 egsWarning(
"createGeometry(iplanes): difference between first and last"
430 " angle must be less then 180 degrees.\n");
432 egsWarning(
" Your input: first angle=%g, last angle=%g,"
433 " difference=%g\n",ang[0],ang[nang-1],ang[nang-1]-ang[0]);
435 egsWarning(
" Your input: first angle=%g, last angle=%g,"
436 " difference=%g\n",ang[0]*180/M_PI,ang[nang-1]*180/M_PI,
437 (ang[nang-1]-ang[0])*180/M_PI);
450 void EGS_RadialRepeater::setRLabels(
EGS_Input *input) {
455 err = input->
getInput(
"set repeater label", inp);
462 void EGS_RadialRepeater::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
464 vector<int> local_regs;
469 for (
int i=0; i<nrep; i++) {
470 for (
int r=0; r<local_regs.size(); r++) {
471 regs.push_back(ng*i + local_regs[r]);
478 for (
int i=0; i<local_regs.size(); i++) {
479 for (
int r=0; r<ng; r++) {
480 regs.push_back(ng*local_regs[i] + r);
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.
int nreg
Number of local regions in this geometry.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
void setMedium(const string &Name)
Set all regions to a medium with name Name.
const string & getName() const
Get the name of this geometry.
virtual int medium(int ireg) const
Returns the medium index in region ireg.
int setLabels(EGS_Input *input)
Set the labels from an input block.
virtual void printInfo() const
Print information about this geometry.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
static const char * getMediumName(int ind)
Get the name of medium with index ind.
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 set of planes intersecting in the same axis.
EGS_IPlanes(const EGS_Vector &Xo, const EGS_Vector &A, int np, const EGS_Float *angles, const string &Name="", bool degree=true)
Construct a set of intersecting planes (iplanes)
A radial geometry replicator.
A class for vector rotations.
static EGS_RotationMatrix rotZ(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the z-axis by the angle with cphi, sphi = .
A class representing 3D vectors.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Intersecting planes: header.
Attempts to fix broken math header files.
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.