48 string EGS_IPlanes::type =
"EGS_IPlanes";
49 string EGS_RadialRepeater::type =
"EGS_RadialRepeater";
52 const EGS_Float *angles,
const string &Name,
bool degree) :
56 d =
new EGS_Float[
nreg];
58 EGS_Float phi180 = M_PI;
63 for (j=0; j<
nreg; j++) {
69 phi = angles[j-np] + phi180;
74 EGS_Float cphi = cos(phi), sphi = sin(phi);
81 int np,
const EGS_Vector *aj,
const EGS_Float *dj,
85 d =
new EGS_Float[
nreg];
87 for (j=0; j<
nreg; j++) {
94 int np, EGS_Float first,
const string &Name) :
97 EGS_Float dphi = 2*M_PI/
nreg;
100 d =
new EGS_Float[
nreg];
101 for (
int j=0; j<
nreg; j++) {
102 EGS_Float phi = first + dphi*j;
103 EGS_Float cphi = cos(phi), sphi = sin(phi);
109 EGS_IPlanes::~EGS_IPlanes() {
114 int EGS_IPlanes::isWhere(
const EGS_Vector &x) {
115 EGS_Float aux_old = a[0]*x;
116 for (
int j=1; j<
nreg; j++) {
117 EGS_Float aux = a[j]*x;
118 if (aux_old >= d[j-1] && aux < d[j]) {
126 int EGS_IPlanes::inside(
const EGS_Vector &x) {
127 EGS_Float aux_old = a[0]*x;
128 for (
int j=1; j<
nreg; j++) {
129 EGS_Float aux = a[j]*x;
130 if (aux_old >= d[j-1] && aux < d[j]) {
138 int EGS_IPlanes::howfar(
int ireg,
const EGS_Vector &x,
141 egsFatal(
"EGS_IPlanes::howfar: ireg (%d) can not be negative\n",ireg);
143 EGS_Float t1 = t, t2 = t;
144 EGS_Float up = a[ireg]*u;
147 t1 = (d[ireg] - a[ireg]*x)/up;
168 t2 = (d[j] - a[j]*x)/up;
183 EGS_Float EGS_IPlanes::hownear(
int ireg,
const EGS_Vector &x) {
185 egsFatal(
"EGS_IPlanes::hownear: ireg (%d) can not be negative\n",ireg);
187 EGS_Float t1 = a[ireg]*x - d[ireg];
192 EGS_Float t2 = d[j] - a[j]*x;
196 void EGS_IPlanes::printInfo()
const {
199 axis.
x,axis.
y,axis.
z);
201 "\n=======================================================\n");
206 EGS_RadialRepeater::EGS_RadialRepeater(
const EGS_Vector &Xo,
209 EGS_Float dphi = 2*M_PI/np;
221 for (
int j=0; j<nrep; j++) {
224 EGS_Float phi = dphi*j;
231 EGS_RadialRepeater::~EGS_RadialRepeater() {
233 if (!iplanes->
deref()) {
241 void EGS_RadialRepeater::printInfo()
const {
243 egsInformation(
"%d uniformely rotated replicas of geometry %s with "
244 "phi_o=%g degrees\n",nrep,g->
getName().c_str(),
246 EGS_Vector xo(iplanes->getAxisXo()), axis(iplanes->getAxisDirection());
247 egsInformation(
"Axis of rotation is xo=(%g,%g,%g) a=(%g,%g,%g)\n",
248 xo.
x,xo.
y,xo.
z,axis.x,axis.y,axis.z);
264 egsWarning(
"createGeometry(iplanes): null input?\n");
267 vector<EGS_Float> axis;
269 int err = input->
getInput(
"axis",axis);
270 if (!err && axis.size() == 6) {
275 else egsWarning(
"createGeometry(iplanes): wrong/missing axis input\n"
276 " using Xo=(0,0,0), a=(0,0,1)\n");
279 if (!err && (type ==
"EGS_RadialRepeater" || type ==
"repeater")) {
281 err = input->
getInput(
"number of repetitions",np);
283 egsWarning(
"createGeometry(iplanes): missing/wrong "
284 "'number of repetitions' input\n");
288 err = input->
getInput(
"repeated geometry",gname);
290 egsWarning(
"createGeometry(iplanes): missing 'repeated geometry'"
296 egsWarning(
"createGeometry(iplanes): no geometry named %s exists\n",
302 err = input->
getInput(
"first angle",tmp1);
303 int err1 = input->
getInput(
"first angle in radians",tmp2);
305 phi_o = tmp1*M_PI/180;
314 err = input->
getInput(
"medium",medium);
318 result->setRLabels(input);
323 vector<EGS_Float> angles;
324 err = input->
getInput(
"angles",angles);
325 bool is_degree =
true;
326 EGS_Float max_angle = 180;
328 err = input->
getInput(
"angles in radian",angles);
330 egsWarning(
"createGeometry(iplanes): wrong/missing 'angles' or "
331 "'angles in radian' input\n");
337 EGS_Float *ang =
new EGS_Float [angles.size()];
338 for (
int j=0; j<angles.size(); j++) {
347 if (ang[j] <= ang[j-1]) {
348 egsWarning(
"createGeometry(iplanes): angles must be ordered"
349 " in increasing order\n");
355 int nang = angles.size();
356 EGS_Float ang_diff = ang[nang-1]-ang[0];
357 if (ang_diff > max_angle) {
358 egsWarning(
"createGeometry(iplanes): difference between first and last"
359 " angle must be less then 180 degrees.\n");
361 egsWarning(
" Your input: first angle=%g, last angle=%g,"
362 " difference=%g\n",ang[0],ang[nang-1],ang[nang-1]-ang[0]);
364 egsWarning(
" Your input: first angle=%g, last angle=%g,"
365 " difference=%g\n",ang[0]*180/M_PI,ang[nang-1]*180/M_PI,
366 (ang[nang-1]-ang[0])*180/M_PI);
379 void EGS_RadialRepeater::setRLabels(
EGS_Input *input) {
384 err = input->
getInput(
"set repeater label", inp);
391 void EGS_RadialRepeater::getLabelRegions(
const string &str, vector<int> ®s) {
393 vector<int> local_regs;
398 for (
int i=0; i<nrep; i++) {
399 for (
int r=0; r<local_regs.size(); r++) {
400 regs.push_back(ng*i + local_regs[r]);
407 for (
int i=0; i<local_regs.size(); i++) {
408 for (
int r=0; r<ng; r++) {
409 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.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
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.
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.