PLaSK library
Loading...
Searching...
No Matches
mirror.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_MIRROR_H
15#define PLASK__GEOMETRY_MIRROR_H
16
17#include "transform.hpp"
18
19// Flip - odbicie
20// Mirror - odbicie i klonowanie
21
22namespace plask {
23
29template <int dim> struct PLASK_API Flip : public GeometryObjectTransform<dim> {
31
32 static const char* NAME;
33
34 std::string getTypeName() const override;
35
37
39 typedef typename BaseClass::DVec DVec;
40
42 typedef typename BaseClass::Box Box;
43
44 using BaseClass::getChild;
45
51 explicit Flip(typename Primitive<dim>::Direction flipDir,
52 shared_ptr<GeometryObjectD<dim>> child = shared_ptr<GeometryObjectD<dim>>())
53 : BaseClass(child), flipDir(flipDir) {}
54
57
63 DVec flipped(DVec v) const { return v.flipped(flipDir); }
64
65 Box flipped(Box res) const { return res.flipped(flipDir); }
66
67 shared_ptr<Material> getMaterial(const DVec& p) const override;
68
69 bool contains(const DVec& p) const override;
70
71 using GeometryObjectTransform<dim>::getPathsTo;
72
73 GeometryObject::Subtree getPathsAt(const DVec& point, bool all = false) const override;
74
75 Box fromChildCoords(const typename ChildType::Box& child_bbox) const override;
76
77 void getPositionsToVec(const GeometryObject::Predicate& predicate,
78 std::vector<DVec>& dest,
79 const PathHints* path = 0) const override;
80
85 shared_ptr<Flip<dim>> copyShallow() const { return shared_ptr<Flip<dim>>(new Flip<dim>(flipDir, getChild())); }
86
87 shared_ptr<GeometryObject> shallowCopy() const override;
88
89 void addPointsAlongToSet(std::set<double>& points,
91 unsigned max_steps,
92 double min_step_size) const override;
93
94 void addLineSegmentsToSet(std::set<typename GeometryObjectD<dim>::LineSegment>& segments,
95 unsigned max_steps,
96 double min_step_size) const override;
97
98 void writeXMLAttr(XMLWriter::Element& dest_xml_object, const AxisNames& axes) const override;
99};
100
103
104
109// TODO add checking of coordinates
112
113 static const char* NAME;
114
115 std::string getTypeName() const override;
116
118
120 typedef typename BaseClass::DVec DVec;
121
123 typedef typename BaseClass::Box Box;
124
125 using BaseClass::getChild;
126
131 explicit Mirror(typename Primitive<dim>::Direction flipDir,
132 shared_ptr<GeometryObjectD<dim>> child = shared_ptr<GeometryObjectD<dim>>())
133 : BaseClass(child), flipDir(flipDir) {}
134
137
138 Box getBoundingBox() const override;
139
140 Box getRealBoundingBox() const override;
141
142 DVec flipped(DVec v) const { return v.flipped(flipDir); }
143
144 DVec flippedIfNeg(DVec v) const { return v[flipDir] >= 0 ? v : v.flipped(flipDir); }
145
146 void extend(Box& toExt) const { toExt.lower[flipDir] = -toExt.upper[flipDir]; }
147
149 extend(res);
150 return res;
151 }
152
153 shared_ptr<Material> getMaterial(const DVec& p) const override;
154
155 bool contains(const DVec& p) const override;
156
157 using GeometryObjectTransform<dim>::getPathsTo;
158
159 Box fromChildCoords(const typename ChildType::Box& child_bbox) const override;
160
161 void getBoundingBoxesToVec(const GeometryObject::Predicate& predicate,
162 std::vector<Box>& dest,
163 const PathHints* path = 0) const override;
164
165 void getObjectsToVec(const GeometryObject::Predicate& predicate,
167 const PathHints* path = 0) const override;
168
169 void getPositionsToVec(const GeometryObject::Predicate& predicate,
170 std::vector<DVec>& dest,
171 const PathHints* path = 0) const override;
172
173 GeometryObject::Subtree getPathsTo(const GeometryObject& el, const PathHints* path = 0) const override;
174
175 GeometryObject::Subtree getPathsAt(const DVec& point, bool all = false) const override;
176
177 std::size_t getChildrenCount() const override;
178
179 shared_ptr<GeometryObject> getChildNo(std::size_t child_no) const override;
180
181 std::size_t getRealChildrenCount() const override;
182
183 shared_ptr<GeometryObject> getRealChildNo(std::size_t child_no) const override;
184
190 return shared_ptr<Mirror<dim>>(new Mirror<dim>(flipDir, this->_child));
191 }
192
193 void addPointsAlongToSet(std::set<double>& points,
194 Primitive<3>::Direction direction,
195 unsigned max_steps,
196 double min_step_size) const override;
197
198 void addLineSegmentsToSet(std::set<typename GeometryObjectD<dim>::LineSegment>& segments,
199 unsigned max_steps,
200 double min_step_size) const override;
201
202 shared_ptr<GeometryObject> shallowCopy() const override;
203
204 void writeXMLAttr(XMLWriter::Element& dest_xml_object, const AxisNames& axes) const override;
205};
206
209
210} // namespace plask
211
212#endif // MIRROR_H