PLaSK library

Loading...
Searching...
No Matches
transform_space_cartesian.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__TRANSFORM_SPACE_CARTESIAN_H
15#define PLASK__TRANSFORM_SPACE_CARTESIAN_H
16
17#include "transform.hpp"
18
19 namespace plask {
20
25 class PLASK_API Extrusion: public GeometryObjectTransformSpace<3, 2> {
26
27 typedef GeometryObjectTransformSpace<3, 2> BaseClass;
28
29 double length;
30
31 public:
32
33 typedef BaseClass::ChildType ChildType;
34
35 // Size of the calculation space.
36 // spaceSize;
37
38 explicit Extrusion(shared_ptr<ChildType> child, double length): BaseClass(child), length(length) {}
39
40 explicit Extrusion(double length = 0.0/*, spaceSize*/): length(length)/*, spaceSize(spaceSize)*/ {}
41
42 static const char* NAME;
43
44 std::string getTypeName() const override;
45
46 double getLength() const { return length; }
47
52 void setLength(double new_length);
53
54 bool contains(const DVec& p) const override;
55
56 //TODO good but unused
57 //virtual bool intersects(const Box& area) const;
58
59 shared_ptr<Material> getMaterial(const DVec& p) const override;
60
61 //virtual void getLeafsInfoToVec(std::vector<std::tuple<shared_ptr<const GeometryObject>, Box, DVec>>& dest, const PathHints* path = 0) const;
62
63 Box fromChildCoords(const typename ChildType::Box& child_bbox) const override;
64
65 //std::vector< plask::shared_ptr< const plask::GeometryObject > > getLeafs() const override;
66
67 shared_ptr<GeometryObject> shallowCopy() const override;
68
69 using GeometryObjectTransformSpace<3, 2>::getPathsTo;
70
71 GeometryObject::Subtree getPathsAt(const DVec& point, bool all=false) const override;
72
73 void writeXMLAttr(XMLWriter::Element &dest_xml_object, const AxisNames &axes) const override;
74
75 void getPositionsToVec(const GeometryObject::Predicate& predicate, std::vector<DVec>& dest, const PathHints* path = 0) const override;
76
77 // void extractToVec(const GeometryObject::Predicate &predicate, std::vector< shared_ptr<const GeometryObjectD<3> > >&dest, const PathHints *path = 0) const;
78
79 private:
81 bool canBeInside(const DVec& p) const { return 0.0 <= p.lon() && p.lon() <= length; }
82
84 bool canIntersect(const Box& area) const { return !(area.lower.lon() > length || area.upper.lon() < 0.0); }
85
91 static ChildVec childVec(const DVec& p) { return ChildVec(p.tran(), p.vert()); }
92
98 static ChildBox childBox(const Box& r) { return ChildBox(childVec(r.lower), childVec(r.upper)); }
99
106 static DVec parentVec(const ChildVec& p, double lon) { return DVec(lon, p.tran(), p.vert()); }
107
113 Box parentBox(const ChildBox& r) const { return Box(parentVec(r.lower, 0.0), parentVec(r.upper, length)); }
114
115 void addPointsAlongToSet(std::set<double>& points,
116 Primitive<3>::Direction direction,
117 unsigned max_steps,
118 double min_step_size) const override;
119
120 void addLineSegmentsToSet(std::set<typename GeometryObjectD<3>::LineSegment>& segments,
121 unsigned max_steps,
122 double min_step_size) const override;
123};
124
125} // namespace plask
126
127#endif // TRANSFORM_SPACE_CARTESIAN_H