44 static bool EGS_ROUNDRECT_CYLINDERS_LOCAL inputSet =
false;
47 static void setInputs() {
50 setBaseGeometryInputs();
52 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_roundrect_cylinders"});
55 auto typePtr = geomBlockInput->addSingleInput(
"type",
true,
"The type of rounded rectangle cylinder", {
"EGS_RoundRectCylinders",
"EGS_RoundRectCylindersXY",
"EGS_RoundRectCylindersYZ",
"EGS_RoundRectCylindersXZ"});
57 geomBlockInput->addSingleInput(
"x-widths",
true,
"A list of cylinder half-widths in the x-direction, must be in increasing order");
58 geomBlockInput->addSingleInput(
"y-widths",
true,
"A list of cylinder half-widths in the y-direction, must be in increasing order");
59 geomBlockInput->addSingleInput(
"radii",
true,
"A list of fillet radii, must be in increasing order");
60 geomBlockInput->addSingleInput(
"midpoint",
false,
"The position of the midpoint (x, y, z)");
63 auto inpPtr = geomBlockInput->addSingleInput(
"x-axis",
true,
"x-axis of rounded rectangle (x, y, z)");
64 inpPtr->addDependency(typePtr,
"EGS_RoundRectCylinders");
65 auto yinpPtr = geomBlockInput->addSingleInput(
"y-axis",
true,
"y-axis of rounded rectangle (x, y, z)");
66 yinpPtr->addDependency(typePtr,
"EGS_RoundRectCylinders");
69 EGS_ROUNDRECT_CYLINDERS_EXPORT
string getExample() {
73 # Example of rounded reactangle cylinder
75 name = my_roundedrectcylinder
76 library = egs_roundrect_cylinders
77 type = EGS_RoundRectCylindersXY
90 EGS_ROUNDRECT_CYLINDERS_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
94 return geomBlockInput;
97 EGS_ROUNDRECT_CYLINDERS_EXPORT
101 egsWarning(
"createGeometry(round rectangular cylinders): null input?\n");
105 int err = input->
getInput(
"type",type);
107 egsWarning(
"createGeometry(round rectangular cylinders): missing type key\n");
113 vector<EGS_Float> Xo;
114 err = input->
getInput(
"midpoint",Xo);
115 if (!err && Xo.size() == 3) {
120 vector<EGS_Float> x_widths, y_widths, radii;
121 err = input->
getInput(
"x-widths",x_widths);
123 egsWarning(
"createGeometry(round rectangular cylinders): wrong/missing "
124 "'x-widths' input\n");
127 err = input->
getInput(
"y-widths",y_widths);
129 egsWarning(
"createGeometry(round rectangular cylinders): wrong/missing "
130 "'y-widths' input\n");
133 err = input->
getInput(
"radii",radii);
135 egsWarning(
"createGeometry(round rectangular cylinders): wrong/missing "
139 if (x_widths.size() != y_widths.size() || x_widths.size() != radii.size()) {
140 egsWarning(
"createGeometry(round rectangular cylinders): expecting the same "
141 "number of x- and y-widths and radii, your input is %d %d %d\n",
142 x_widths.size(),y_widths.size(), radii.size());
146 for (
int i=0; i<x_widths.size(); i++) {
148 if (x_widths[i-1] > x_widths[i] || x_widths[i] <= 0 || x_widths[i-1] <= 0) {
149 egsWarning(
"createGeometry(round rectangular cylinders): x-widths must all be positive and in sorted order\n");
152 if (y_widths[i-1] > y_widths[i] || y_widths[i] <= 0 || y_widths[i-1] <= 0) {
153 egsWarning(
"createGeometry(round rectangular cylinders): y-widths must all be positive and in sorted order\n");
156 if (radii[i] > radii[i-1]) {
157 if (x_widths[i] - radii[i] >= x_widths[i-1] - radii[i-1]) {
159 else if (x_widths[i] - radii[i] >= x_widths[i-1] - radii[i-1]) {
165 EGS_Float dx = (x_widths[i] - radii[i]) - (x_widths[i-1] - radii[i-1]);
166 EGS_Float dy = (y_widths[i] - radii[i]) - (y_widths[i-1] - radii[i-1]);
167 EGS_Float maxdist = sqrt(dx*dx+dy*dy);
168 if (radii[i] - radii[i-1] < maxdist) {
169 egsWarning(
"createGeometry(round rectangular cylinders): rounded rectangles may not intersect (but (hx,hy,r) = (%f,%f,%f) and (%f,%f,%f) do)\n",
170 x_widths[i-1], y_widths[i-1], radii[i-1],
171 x_widths[i], y_widths[i], radii[i]);
178 egsWarning(
"createGeometry(round rectangular cylinders): radii must all be positive\n");
181 if (radii[i] > x_widths[i] || radii[i] > y_widths[i]) {
182 egsWarning(
"createGeometry(round rectangular cylinders): radii cannot be larger than half-widths\n");
189 if (type ==
"EGS_RoundRectCylindersXY")
192 else if (type ==
"EGS_RoundRectCylindersXZ")
195 else if (type ==
"EGS_RoundRectCylindersYZ")
199 vector<EGS_Float> ax, ay;
201 if (err || ax.size() != 3) {
202 egsWarning(
"createGeometry(round rectangular cylinders): missing/wrong "
207 if (err || ay.size() != 3) {
208 egsWarning(
"createGeometry(round rectangular cylinders): missing/wrong "
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.
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.
A projector into any plane.
A set of concentric rounded rectangles.
A class representing 3D vectors.
A projector into the x-plane.
A projector into the y-plane.
A projector into the z-plane.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
A set of concentric rounded rectangular cylinders: header.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.