PLaSK library

Loading...
Searching...
No Matches
elliptic_cylinder.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__GEOMETRY_ELLIPTIC_CYLINDER_H
15#define PLASK__GEOMETRY_ELLIPTIC_CYLINDER_H
16
17#include "leaf.hpp"
18
19 namespace plask {
20
26 struct PLASK_API EllipticCylinder : public GeometryObjectLeaf<3> {
27 typedef typename GeometryObjectLeaf<3>::DVec DVec;
28
29 private:
30
31 DVec T(const DVec& p) const {
32 return DVec(cosa * p.c0 - sina * p.c1, sina * p.c0 + cosa * p.c1, p.c2);
33 }
34
35 DVec TVec(double x, double y, double z) const {
36 return DVec(cosa * x - sina * y, sina * x + cosa * y, z);
37 }
38
39 DVec invT(const DVec& p) const {
40 return DVec(cosa * p.c0 + sina * p.c1, -sina * p.c0 + cosa * p.c1, p.c2);
41 }
42
43 public:
44 double radius0;
45 double radius1;
46 double sina;
47 double cosa;
48 double height;
49
50 static const char* NAME;
51
52 std::string getTypeName() const override { return NAME; }
53
54 EllipticCylinder(double radius0,
55 double radius1,
56 double angle,
57 double height,
58 const shared_ptr<Material>& material = shared_ptr<Material>());
59
60 EllipticCylinder(double radius0,
61 double radius1,
62 double angle,
63 double height,
64 const shared_ptr<MaterialsDB::MixedCompositionFactory>& materialTopBottom);
65
66 EllipticCylinder(double radius0, double radius1, double height, const shared_ptr<Material>& material = shared_ptr<Material>());
67
68 EllipticCylinder(double radius0,
69 double radius1,
70 double height,
71 const shared_ptr<MaterialsDB::MixedCompositionFactory>& materialTopBottom);
72
73 EllipticCylinder(const EllipticCylinder& src);
74
75 Box getBoundingBox() const override;
76
77 bool contains(const DVec& p) const override;
78
79 // virtual bool intersects(const Box& area) const;
80
81 void writeXMLAttr(XMLWriter::Element& dest_xml_object, const AxisNames& axes) const override;
82
83 shared_ptr<GeometryObject> shallowCopy() const override { return make_shared<EllipticCylinder>(*this); }
84
89 std::pair<double, double> getRadii() const { return std::make_pair(radius0, radius1); }
90
96 void setRadii(double rx, double ry) {
97 this->radius0 = std::max(rx, 0.);
98 this->radius1 = std::max(ry, 0.);
99 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
100 }
101
106 void setRadius0(double new_radius) {
107 if (new_radius < 0.) new_radius = 0.;
108 this->radius0 = new_radius;
109 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
110 }
111
116 void setRadius1(double new_radius) {
117 if (new_radius < 0.) new_radius = 0.;
118 this->radius1 = new_radius;
119 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
120 }
121
126 double getAngle() const { return atan2(sina, cosa); }
127
132 void setAngle(double new_angle) {
133 this->sina = sin(new_angle);
134 this->cosa = cos(new_angle);
135 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
136 }
137
142 void setHeight(double new_height) {
143 if (new_height < 0.) new_height = 0.;
144 this->height = new_height;
145 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
146 }
147
155 void resize(double radius0, double radius1, double angle, double height) {
156 this->radius0 = radius0;
157 this->radius1 = radius1;
158 this->sina = sin(angle);
159 this->cosa = cos(angle);
160 this->height = height;
161 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
162 }
163
171 void resize(double radius0, double radius1, double height) {
172 this->radius0 = radius0;
173 this->radius1 = radius1;
174 this->sina = 0.0;
175 this->cosa = 1.0;
176 this->height = height;
177 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
178 }
179
180 void addPointsAlongToSet(std::set<double>& points,
181 Primitive<3>::Direction direction,
182 unsigned max_steps,
183 double min_step_size) const override;
184
185 void addLineSegmentsToSet(std::set<typename GeometryObjectD<3>::LineSegment>& segments,
186 unsigned max_steps,
187 double min_step_size) const override;
188};
189
190} // namespace plask
191
192#endif // PLASK__GEOMETRY_ELLIPTIC_CYLINDER_H