47 string EGS_IPlanes::type =
"EGS_IPlanes";
48 string EGS_RadialRepeater::type =
"EGS_RadialRepeater";
51 const EGS_Float *angles,
const string &Name,
bool degree) :
55 d =
new EGS_Float[
nreg];
57 EGS_Float phi180 = M_PI;
62 for (j=0; j<
nreg; j++) {
68 phi = angles[j-np] + phi180;
73 EGS_Float cphi = cos(phi), sphi = sin(phi);
80 int np,
const EGS_Vector *aj,
const EGS_Float *dj,
84 d =
new EGS_Float[
nreg];
86 for (j=0; j<
nreg; j++) {
93 int np, EGS_Float first,
const string &Name) :
96 EGS_Float dphi = 2*M_PI/
nreg;
99 d =
new EGS_Float[
nreg];
100 for (
int j=0; j<
nreg; j++) {
101 EGS_Float phi = first + dphi*j;
102 EGS_Float cphi = cos(phi), sphi = sin(phi);
108 EGS_IPlanes::~EGS_IPlanes() {
113 int EGS_IPlanes::isWhere(
const EGS_Vector &x) {
114 EGS_Float aux_old = a[0]*x;
115 for (
int j=1; j<
nreg; j++) {
116 EGS_Float aux = a[j]*x;
117 if (aux_old >= d[j-1] && aux < d[j]) {
125 int EGS_IPlanes::inside(
const EGS_Vector &x) {
126 EGS_Float aux_old = a[0]*x;
127 for (
int j=1; j<
nreg; j++) {
128 EGS_Float aux = a[j]*x;
129 if (aux_old >= d[j-1] && aux < d[j]) {
137 int EGS_IPlanes::howfar(
int ireg,
const EGS_Vector &x,
140 egsFatal(
"EGS_IPlanes::howfar: ireg (%d) can not be negative\n",ireg);
142 EGS_Float t1 = t, t2 = t;
143 EGS_Float up = a[ireg]*u;
146 t1 = (d[ireg] - a[ireg]*x)/up;
167 t2 = (d[j] - a[j]*x)/up;
182 EGS_Float EGS_IPlanes::hownear(
int ireg,
const EGS_Vector &x) {
184 egsFatal(
"EGS_IPlanes::hownear: ireg (%d) can not be negative\n",ireg);
186 EGS_Float t1 = a[ireg]*x - d[ireg];
191 EGS_Float t2 = d[j] - a[j]*x;
195 void EGS_IPlanes::printInfo()
const {
198 axis.
x,axis.
y,axis.
z);
200 "\n=======================================================\n");
205 EGS_RadialRepeater::EGS_RadialRepeater(
const EGS_Vector &Xo,
208 EGS_Float dphi = 2*M_PI/np;
220 for (
int j=0; j<nrep; j++) {
223 EGS_Float phi = dphi*j;
230 EGS_RadialRepeater::~EGS_RadialRepeater() {
232 if (!iplanes->
deref()) {
240 void EGS_RadialRepeater::printInfo()
const {
242 egsInformation(
"%d uniformely rotated replicas of geometry %s with "
243 "phi_o=%g degrees\n",nrep,g->
getName().c_str(),
245 EGS_Vector xo(iplanes->getAxisXo()), axis(iplanes->getAxisDirection());
246 egsInformation(
"Axis of rotation is xo=(%g,%g,%g) a=(%g,%g,%g)\n",
247 xo.
x,xo.
y,xo.
z,axis.x,axis.y,axis.z);
263 egsWarning(
"createGeometry(iplanes): null input?\n");
266 vector<EGS_Float> axis;
268 int err = input->
getInput(
"axis",axis);
269 if (!err && axis.size() == 6) {
274 else egsWarning(
"createGeometry(iplanes): wrong/missing axis input\n"
275 " using Xo=(0,0,0), a=(0,0,1)\n");
278 if (!err && (type ==
"EGS_RadialRepeater" || type ==
"repeater")) {
280 err = input->
getInput(
"number of repetitions",np);
282 egsWarning(
"createGeometry(iplanes): missing/wrong "
283 "'number of repetitions' input\n");
287 err = input->
getInput(
"repeated geometry",gname);
289 egsWarning(
"createGeometry(iplanes): missing 'repeated geometry'"
295 egsWarning(
"createGeometry(iplanes): no geometry named %s exists\n",
301 err = input->
getInput(
"first angle",tmp1);
302 int err1 = input->
getInput(
"first angle in radians",tmp2);
304 phi_o = tmp1*M_PI/180;
313 err = input->
getInput(
"medium",medium);
317 result->setRLabels(input);
322 vector<EGS_Float> angles;
323 err = input->
getInput(
"angles",angles);
324 bool is_degree =
true;
325 EGS_Float max_angle = 180;
327 err = input->
getInput(
"angles in radian",angles);
329 egsWarning(
"createGeometry(iplanes): wrong/missing 'angles' or "
330 "'angles in radian' input\n");
336 EGS_Float *ang =
new EGS_Float [angles.size()];
337 for (
int j=0; j<angles.size(); j++) {
346 if (ang[j] <= ang[j-1]) {
347 egsWarning(
"createGeometry(iplanes): angles must be ordered"
348 " in increasing order\n");
354 int nang = angles.size();
355 EGS_Float ang_diff = ang[nang-1]-ang[0];
356 if (ang_diff > max_angle) {
357 egsWarning(
"createGeometry(iplanes): difference between first and last"
358 " angle must be less then 180 degrees.\n");
360 egsWarning(
" Your input: first angle=%g, last angle=%g,"
361 " difference=%g\n",ang[0],ang[nang-1],ang[nang-1]-ang[0]);
363 egsWarning(
" Your input: first angle=%g, last angle=%g,"
364 " difference=%g\n",ang[0]*180/M_PI,ang[nang-1]*180/M_PI,
365 (ang[nang-1]-ang[0])*180/M_PI);
378 void EGS_RadialRepeater::setRLabels(
EGS_Input *input) {
383 err = input->
getInput(
"set repeater label", inp);
390 void EGS_RadialRepeater::getLabelRegions(
const string &str, vector<int> ®s) {
392 vector<int> local_regs;
397 for (
int i=0; i<nrep; i++) {
398 for (
int r=0; r<local_regs.size(); r++) {
399 regs.push_back(ng*i + local_regs[r]);
406 for (
int i=0; i<local_regs.size(); i++) {
407 for (
int r=0; r<ng; r++) {
408 regs.push_back(ng*local_regs[i] + r);
int deref()
Decrease the reference count to this geometry.
virtual int medium(int ireg) const
Returns the medium index in region ireg.
virtual void printInfo() const
Print information about this geometry.
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 class for vector rotations.
A class representing 3D vectors.
int setLabels(EGS_Input *input)
Set the labels from an input block.
A set of planes intersecting in the same axis.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
static EGS_RotationMatrix rotZ(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the z-axis by the angle with cphi, sphi = .
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
void setMedium(const string &Name)
Set all regions to a medium with name Name.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
Attempts to fix broken math header files.
A radial geometry replicator.
static const char * getMediumName(int ind)
Get the name of medium with index ind.
const string & getName() const
Get the name of this geometry.
Intersecting planes: header.
int nreg
Number of local regions in this geometry.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.