47 static EGS_PYRAMID_LOCAL
string __pyrX =
"EGS_PyramidX";
48 static EGS_PYRAMID_LOCAL
string __pyrY =
"EGS_PyramidY";
49 static EGS_PYRAMID_LOCAL
string __pyrZ =
"EGS_PyramidZ";
50 static EGS_PYRAMID_LOCAL
string __pyr =
"EGS_Pyramid";
52 static bool EGS_PYRAMID_LOCAL inputSet =
false;
57 a(p->getNormal()), open(O) {
60 xop =
p->getProjection(
xo);
62 " the base (%g)\n",getType().c_str(),fabs(
d));
70 vector<EGS_2DVector> aux;
71 for (
int j=0; j<
p->getN(); j++) {
73 v2 =
p->getPoint(j+1);
82 egsFatal(
"%s: n*aj < 0 for both normal orientations?\n",
102 static void setInputs() {
105 setBaseGeometryInputs();
107 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_pyramid"});
110 auto typePtr = geomBlockInput->addSingleInput(
"type",
true,
"The type of pyramid", {
"EGS_PyramidX",
"EGS_PyramidY",
"EGS_PyramidZ",
"EGS_Pyramid"});
112 geomBlockInput->addSingleInput(
"points",
true,
"A list of 2D or 3D (for type=EGS_Pyramid) positions. For 3D points, they must reside on a plane. These create a polygon that define the base of the pyramid.");
113 geomBlockInput->addSingleInput(
"tip",
true,
"The 3D position of the tip of the pyramid (x, y ,z)");
114 geomBlockInput->addSingleInput(
"closed",
false,
"0 (open) or 1 (closed). When missing or set to 0, the pyramid is open, otherwise it is closed by the plane in which the pyramid base is defined.", {
"0",
"1"});
117 EGS_PYRAMID_EXPORT
string getExample() {
121 # Example of egs_pyramid
123 # EGS_PyramidZ example
126 library = egs_pyramid
128 points = 1 1 -1 1 -1 -1 4 -1
139 EGS_PYRAMID_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
143 return geomBlockInput;
149 egsWarning(
"createGeometry(pyramid): null input?\n");
153 int err = input->
getInput(
"type",type);
155 egsWarning(
"createGeometry(pyramid): missing 'type' input\n");
162 egsWarning(
"createGeometry(pyramid): missing 'points' input\n");
165 vector<EGS_Float> tip;
167 if (err || tip.size() != 3) {
168 egsWarning(
"createGeometry(pyramid): wrong/missing 'tip' input\n");
173 err = input->
getInput(
"closed",is_closed);
174 if (!err && is_closed == 1) {
182 egsWarning(
"createGeometry(pyramid): at least 3 points are "
183 "required to construct a pyramid\n");
186 vector<EGS_2DVector> points;
187 for (
int j=0; j<np; j++) {
190 if (input->
compare(type,__pyrX))
194 else if (input->
compare(type,__pyrY))
206 egsWarning(
"createGeometry(pyramid): at least 3 points are required"
207 " to construct a pyramid\n");
210 vector<EGS_Vector> points;
211 for (
int j=0; j<np; j++) {
212 points.push_back(
EGS_Vector(p[3*j],p[3*j+1],p[3*j+2]));
216 points.push_back(points[0]);
220 vector<EGS_2DVector> p2;
222 for (
int j=0; j<np; j++) {
223 p2.push_back(pro.getProjection(points[j]));
224 EGS_Float d = pro.distance(points[j]);
227 "points are not on a plane\n");
A class representing 2D vectors.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
int nreg
Number of local regions in this geometry.
bool is_convex
Is this geometry convex?
EGS_Float boundaryTolerance
Boundary tolerance for geometries that need it.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
int setLabels(EGS_Input *input)
Set the labels from an input block.
virtual void printInfo() const
Print information about this geometry.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
A template class for 3D polygons.
A projector into any plane.
EGS_Vector normal() const
Get the normal to the projection plane.
EGS_2DVector getProjection(const EGS_Vector &x) const
Get the 2D projection of the vector x onto the plane.
A template class for modeling pyramids.
EGS_2DVector xop
the tip projection on the base polygon
EGS_Vector xo
the tip of the pyramid
EGS_Float d
distance from tip to base polygon (always positive)
EGS_Vector a
the base normal vector.
bool open
is the pyramid open ?
EGS_PyramidT(T *P, const EGS_Vector &Xo, bool O=true, const string &N="")
Construct a pyramid using P as the base polygon and Xo as the position of the tip.
A class representing 3D vectors.
A projector into the x-plane.
A projector into the y-plane.
A projector into the z-plane.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
EGS_PolygonT< EGS_XProjector > EGS_PolygonYZ
A 3D polygon in the x-plane.
EGS_PolygonT< EGS_Projector > EGS_Polygon
A 3D polygon in any plane.
EGS_PolygonT< EGS_ZProjector > EGS_PolygonXY
A 3D polygon in the z-plane.
EGS_PolygonT< EGS_YProjector > EGS_PolygonXZ
A 3D polygon in the y-plane.
A pyramid geometry: header.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.