43 EGS_TriangleShape::EGS_TriangleShape(
const vector<EGS_Float> &points,
51 A = 0.5*fabs(ax*by-ay*bx);
54 EGS_TriangleShape::EGS_TriangleShape(
const EGS_Float *points,
62 A = 0.5*fabs(ax*by-ay*bx);
65 EGS_PolygonShape::EGS_PolygonShape(
const vector<EGS_Float> &points,
67 int np = points.size();
69 EGS_Float auxx = points[np-2] - points[0];
70 EGS_Float auxy = points[np-1] - points[1];
72 if (auxx*auxx + auxy*auxy >
epsilon) {
75 xc =
new EGS_Float [n];
76 yc =
new EGS_Float [n];
77 vector<EGS_2DVector> p1;
78 for (
int j=0; j<np/2; j++) {
80 yc[j] = points[2*j+1];
94 for (
int i=0; i<np-2; i++) {
95 EGS_2DVector aux(0.5*(xc[i+2]+xc[i]),0.5*(yc[i+2]+yc[i]));
96 if (pol.isInside(aux)) {
98 vector<EGS_2DVector> p2;
99 for (
int k=0; k<3; k++) {
100 p_tmp[2*k] = xc[i+k];
101 p_tmp[2*k+1] = yc[i+k];
105 for (
int j=0; j<np-1; j++) {
106 if (j < i || j > i+2) {
108 if (tri.isInside(tmp)) {
117 for (
int j=i+1; j<np-1; j++) {
126 for (
int k=0; k<3; k++) {
128 p_tmp[2*k+1] = yc[k];
132 for (
int i=0; i<ntr; i++) {
133 yc[i] = triangle[i]->area();
146 egsWarning(
"createShape(polygon): null input?\n");
149 vector<EGS_Float> points;
150 int err = input->
getInput(
"points",points);
152 egsWarning(
"createShape(polygon): no 'points' input\n");
155 int np = points.size();
157 egsWarning(
"createShape(polygon): you must input an even number of"
158 " floating numbers\n");
162 egsWarning(
"createShape(polygon): you must input at least 3 2D points"
163 " to form a polygon\n");
A class for sampling random values from a given probability distribution using the alias table techni...
A class representing 2D vectors.
void setTransformation(EGS_Input *inp)
Set the transformation attached to this shape.
Global egspp functions header file.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
EGS_2DPolygon and EGS_PolygonT class header file.
Attempts to fix broken math header files.
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
A class to represent a polygon in a plane (a 2D polygon).
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.