44 EGS_TriangleShape::EGS_TriangleShape(
const vector<EGS_Float> &points,
52 A = 0.5*fabs(ax*by-ay*bx);
55 EGS_TriangleShape::EGS_TriangleShape(
const EGS_Float *points,
63 A = 0.5*fabs(ax*by-ay*bx);
66 EGS_PolygonShape::EGS_PolygonShape(
const vector<EGS_Float> &points,
68 int np = points.size();
70 EGS_Float auxx = points[np-2] - points[0];
71 EGS_Float auxy = points[np-1] - points[1];
73 if (auxx*auxx + auxy*auxy >
epsilon) {
76 xc =
new EGS_Float [n];
77 yc =
new EGS_Float [n];
78 vector<EGS_2DVector> p1;
79 for (
int j=0; j<np/2; j++) {
81 yc[j] = points[2*j+1];
95 for (
int i=0; i<np-2; i++) {
96 EGS_2DVector aux(0.5*(xc[i+2]+xc[i]),0.5*(yc[i+2]+yc[i]));
97 if (pol.isInside(aux)) {
99 vector<EGS_2DVector> p2;
100 for (
int k=0; k<3; k++) {
101 p_tmp[2*k] = xc[i+k];
102 p_tmp[2*k+1] = yc[i+k];
106 for (
int j=0; j<np-1; j++) {
107 if (j < i || j > i+2) {
109 if (tri.isInside(tmp)) {
118 for (
int j=i+1; j<np-1; j++) {
127 for (
int k=0; k<3; k++) {
129 p_tmp[2*k+1] = yc[k];
133 for (
int i=0; i<ntr; i++) {
134 yc[i] = triangle[i]->area();
147 egsWarning(
"createShape(polygon): null input?\n");
150 vector<EGS_Float> points;
151 int err = input->
getInput(
"points",points);
153 egsWarning(
"createShape(polygon): no 'points' input\n");
156 int np = points.size();
158 egsWarning(
"createShape(polygon): you must input an even number of"
159 " floating numbers\n");
163 egsWarning(
"createShape(polygon): you must input at least 3 2D points"
164 " to form a polygon\n");
A class to represent a polygon in a plane (a 2D polygon).
A class representing 2D vectors.
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.
Attempts to fix broken math header files.
EGS_2DPolygon and EGS_PolygonT class header file.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.