PLaSK library
Loading...
Searching...
No Matches
circle.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_CIRCLE_H
15#define PLASK__GEOMETRY_CIRCLE_H
16
21#include "leaf.hpp"
22
23namespace plask {
24
29template <int dim> struct PLASK_API Circle : public GeometryObjectLeaf<dim> {
30 double radius;
31
34
37
38 static const char* NAME;
39
40 std::string getTypeName() const override;
41
42 explicit Circle(double radius, const shared_ptr<Material>& material = shared_ptr<Material>());
43
45 : GeometryObjectLeaf<dim>(materialTopBottom), radius(radius) {
46 if (radius < 0.) radius = 0.;
47 }
48
49 explicit Circle(const Circle& src) : GeometryObjectLeaf<dim>(src), radius(src.radius) {}
50
52
53 Box getBoundingBox() const override;
54
55 bool contains(const DVec& p) const override;
56
57 void addPointsAlongToSet(std::set<double>& points,
59 unsigned max_steps,
60 double min_step_size) const override;
61
63 unsigned max_steps,
64 double min_step_size) const override;
65
66 void writeXMLAttr(XMLWriter::Element& dest_xml_object, const AxisNames& axes) const override;
67
72 void setRadius(double new_radius) {
73 if (new_radius < 0.) new_radius = 0.;
74 this->radius = new_radius;
75 this->fireChanged(GeometryObject::Event::EVENT_RESIZE);
76 }
77};
78
79template <> typename Circle<2>::Box Circle<2>::getBoundingBox() const;
80template <> typename Circle<3>::Box Circle<3>::getBoundingBox() const;
81
82template <>
84 unsigned max_steps,
85 double min_step_size) const;
86
87template <>
89 unsigned max_steps,
90 double min_step_size) const;
91
94
95} // namespace plask
96
97#endif // PLASK__GEOMETRY_CIRCLE_H