42 EGS_ShapeCollection::EGS_ShapeCollection(
const vector<EGS_BaseShape *> &Shapes,
45 int n1 = Shapes.size(), n2 = Probs.size();
46 if (n1 < 2 || n2 < 2 || n1 != n2) {
47 egsWarning(
"EGS_ShapeCollection::EGS_ShapeCollection: invalid input\n");
52 EGS_Float *p =
new EGS_Float [nshape];
53 for (
int j=0; j<nshape; j++) {
54 shapes[j] = Shapes[j];
67 egsWarning(
"createShape(shape collection): null input?\n");
70 vector<EGS_BaseShape *> shapes;
71 vector<EGS_Float> probs;
76 egsWarning(
"createShape(shape collection): got null shape\n");
79 shapes.push_back(shape);
83 vector<string> snames;
84 int err = input->
getInput(
"shape names",snames);
85 if (!err && snames.size() > 0) {
86 for (
unsigned int j=0; j<snames.size(); j++) {
88 if (!shape)
egsWarning(
"createShape(shape collection): no shape "
89 "named %s exists\n",snames[j].c_str());
91 shapes.push_back(shape);
95 err = input->
getInput(
"probabilities",probs);
98 egsWarning(
"createShape(shape collection): no 'probabilities' input\n");
101 if (shapes.size() < 2) {
102 egsWarning(
"createShape(shape collection): at least 2 shapes are "
103 "needed for a shape collection, you defined %d\n",shapes.size());
106 if (shapes.size() != probs.size()) {
107 egsWarning(
"createShape(shape collection): the number of shapes (%d)"
108 " is not the same as the number of input probabilities (%d)\n");
111 for (
unsigned int i=0; i<probs.size(); i++) {
113 egsWarning(
"createShape(shape collection): probabilities must not"
114 " be negative, but your input probability %d is %g\n",
120 for (
unsigned int j=0; j<shapes.size(); j++) {
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
static EGS_BaseShape * getShape(const string &Name)
Get a pointer to the shape named Name.
static EGS_BaseShape * createShape(EGS_Input *inp)
Create a shape from the information pointed to by inp.
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.
int ref()
Increase the reference count to this object.
static void deleteObject(EGS_Object *o)
Delete an object.
A class for sampling random bins from a given probability distribution using the alias table techniqu...
Global egspp functions header file.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.