41 static bool EGS_LINE_SHAPE_LOCAL inputSet =
false;
42 static shared_ptr<EGS_BlockInput> EGS_LINE_SHAPE_LOCAL shapeBlockInput = make_shared<EGS_BlockInput>(
"shape");
44 EGS_LineShape::EGS_LineShape(
const vector<EGS_Float> &points,
46 int np = points.size();
54 EGS_Float *w =
new EGS_Float [n-1];
55 for (
int j=0; j<n; j++) {
59 EGS_Float ax = x[j]-x[j-1], ay = y[j]-y[j-1];
60 w[j-1] = sqrt(ax*ax+ay*ay);
69 static void setInputs() {
72 setShapeInputs(shapeBlockInput);
73 shapeBlockInput->getSingleInput(
"library")->setValues({
"egs_line_shape"});
75 shapeBlockInput->addSingleInput(
"points",
true,
"A list of 2D positions, at least 2 required. By default these are in the x-y plane at z=0; use a transformation to adjust.");
78 EGS_LINE_SHAPE_EXPORT
string getExample() {
82 # Example of egs_line_shape
84 library = egs_line_shape
85 points = list of 2D positions
91 EGS_LINE_SHAPE_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
95 return shapeBlockInput;
101 egsWarning(
"createShape(line): null input?\n");
104 vector<EGS_Float> points;
105 int err = input->
getInput(
"points",points);
107 egsWarning(
"createShape(line): no 'points' input\n");
110 int np = points.size();
112 egsWarning(
"createShape(line): you must input an even number of"
113 " floating numbers\n");
117 egsWarning(
"createShape(line): you must input at least 2 2D points"
118 " to form a line\n");
A class for sampling random values from a given probability distribution using the alias table techni...
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.