41 static bool EGS_RECTANGLE_LOCAL inputSet =
false;
42 static shared_ptr<EGS_BlockInput> EGS_RECTANGLE_LOCAL shapeBlockInput = make_shared<EGS_BlockInput>(
"shape");
44 EGS_RectangularRing::EGS_RectangularRing(EGS_Float xmin, EGS_Float xmax,
45 EGS_Float ymin, EGS_Float ymax, EGS_Float xmin_i, EGS_Float xmax_i,
46 EGS_Float ymin_i, EGS_Float ymax_i,
const string &Name,
59 if (xmin_i > xmax_i) {
64 if (ymin_i > ymax_i) {
69 if (xmin_i < xmin || ymin_i < ymin || xmax_i > xmax || ymax_i > ymax) {
77 p[0] = (xmin_i - xmin)*(ymax - ymin);
78 p[1] = (xmax - xmax_i)*(ymax - ymin);
79 p[2] = (xmax_i - xmin_i)*(ymin_i - ymin);
80 p[3] = (xmax_i - xmin_i)*(ymax - ymax_i);
81 A = p[0] + p[1] + p[2] + p[3];
87 otype =
"rectangular ring";
91 EGS_RectangularRing::~EGS_RectangularRing() {
103 static void setInputs() {
106 setShapeInputs(shapeBlockInput);
107 shapeBlockInput->getSingleInput(
"library")->setValues({
"egs_rectangle"});
109 shapeBlockInput->addSingleInput(
"rectangle",
true,
"Two 2D coordinates to define a rectangle: x1 y1 x2 y2. By default these are in the x-y plane at z=0; use a transformation to adjust.");
110 shapeBlockInput->addSingleInput(
"inner rectangle",
false,
"Two 2D coordinates to define an inner rectangle, and create a 'rectangular ring': xp1 yp1 xp2 yp2");
113 EGS_RECTANGLE_EXPORT
string getExample() {
117 # Example of egs_rectangle
119 library = egs_rectangle
120 rectangle = x1 y1 x2 y2
121 inner rectangle = xp1 yp1 xp2 yp2 (optional)
127 EGS_RECTANGLE_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
131 return shapeBlockInput;
137 egsWarning(
"createShape(rectangle): null input?\n");
140 vector<EGS_Float> pos;
141 int err = input->
getInput(
"rectangle",pos);
143 egsWarning(
"createShape(rectangle): no 'rectangle' input\n");
146 if (pos.size() != 4) {
147 egsWarning(
"createShape(rectangle): found only %d inputs instead"
152 vector<EGS_Float> posi;
153 err = input->
getInput(
"inner rectangle",posi);
154 if (!err && posi.size() == 4) {
156 pos[3],posi[0],posi[2],posi[1],posi[3],
"",f);
158 egsWarning(
"createShape(rectangle): your input did not result in"
159 " a valid \"rectangular ring\"\n");
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
void setTransformation(EGS_Input *inp)
Set the transformation attached to this shape.
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
Global egspp functions header file.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.