41 EGS_ShapeCollection::EGS_ShapeCollection(
const vector<EGS_BaseShape *> &Shapes,
44 int n1 = Shapes.size(), n2 = Probs.size();
45 if (n1 < 2 || n2 < 2 || n1 != n2) {
46 egsWarning(
"EGS_ShapeCollection::EGS_ShapeCollection: invalid input\n");
51 EGS_Float *p =
new EGS_Float [nshape];
52 for (
int j=0; j<nshape; j++) {
53 shapes[j] = Shapes[j];
66 egsWarning(
"createShape(shape collection): null input?\n");
69 vector<EGS_BaseShape *> shapes;
70 vector<EGS_Float> probs;
75 egsWarning(
"createShape(shape collection): got null shape\n");
78 shapes.push_back(shape);
82 vector<string> snames;
83 int err = input->
getInput(
"shape names",snames);
84 if (!err && snames.size() > 0) {
85 for (
unsigned int j=0; j<snames.size(); j++) {
87 if (!shape)
egsWarning(
"createShape(shape collection): no shape "
88 "named %s exists\n",snames[j].c_str());
90 shapes.push_back(shape);
94 err = input->
getInput(
"probabilities",probs);
97 egsWarning(
"createShape(shape collection): no 'probabilities' input\n");
100 if (shapes.size() < 2) {
101 egsWarning(
"createShape(shape collection): at least 2 shapes are "
102 "needed for a shape collection, you defined %d\n",shapes.size());
105 if (shapes.size() != probs.size()) {
106 egsWarning(
"createShape(shape collection): the number of shapes (%d)"
107 " is not the same as the number of input probabilities (%d)\n");
110 for (
unsigned int i=0; i<probs.size(); i++) {
112 egsWarning(
"createShape(shape collection): probabilities must not"
113 " be negative, but your input probability %d is %g\n",
119 for (
unsigned int j=0; j<shapes.size(); j++) {
void setTransformation(EGS_Input *inp)
Set the transformation attached to this shape.
static EGS_BaseShape * createShape(EGS_Input *inp)
Create a shape from the information pointed to by inp.
static EGS_BaseShape * getShape(const string &Name)
Get a pointer to the shape named Name.
Global egspp functions header file.
static void deleteObject(EGS_Object *o)
Delete an object.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
A class for sampling random bins from a given probability distribution using the alias table techniqu...
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.