PLaSK library
Loading...
Searching...
No Matches
separator.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_SEPARATOR_H
15
#define PLASK__GEOMETRY_SEPARATOR_H
16
21
#include "
object.hpp
"
22
23
namespace
plask
{
24
36
template
<
int
dim>
struct
PLASK_API
GeometryObjectSeparator
:
public
GeometryObjectD
<dim> {
37
typedef
typename
GeometryObjectD<dim>::DVec
DVec
;
38
typedef
typename
GeometryObjectD<dim>::Box
Box
;
39
using
GeometryObjectD
<dim>::getBoundingBox;
40
using
GeometryObjectD
<dim>
::shared_from_this
;
41
42
GeometryObject::Type
getType()
const override
;
43
44
static
const
char
*
NAME
;
45
46
std::string getTypeName()
const override
;
47
53
shared_ptr<Material>
getMaterial(
const
DVec
& p)
const override
;
54
55
// void getLeafsInfoToVec(std::vector<std::tuple<shared_ptr<const GeometryObject>, Box, DVec>>& dest, const
56
// PathHints* path = 0) const override;
57
58
void
getBoundingBoxesToVec(
const
GeometryObject::Predicate
& predicate,
59
std::vector<Box>&
dest
,
60
const
PathHints
* path = 0)
const override
;
61
62
void
getObjectsToVec(
const
GeometryObject::Predicate
& predicate,
63
std::vector<
shared_ptr<const GeometryObject>
>&
dest
,
64
const
PathHints
* path = 0)
const override
;
65
66
void
getPositionsToVec(
const
GeometryObject::Predicate
& predicate,
67
std::vector<DVec>&
dest
,
68
const
PathHints
* = 0)
const override
;
69
70
/* inline void getLeafsToVec(std::vector< shared_ptr<const GeometryObject> >& dest) const override {
71
dest.push_back(this->shared_from_this());
72
}
73
74
inline std::vector< shared_ptr<const GeometryObject> > getLeafs() const override {
75
return { this->shared_from_this() };
76
}*/
77
78
bool
hasInSubtree(
const
GeometryObject
& el)
const override
;
79
80
GeometryObject::Subtree
getPathsTo(
const
GeometryObject
& el,
const
PathHints
* path = 0)
const override
;
81
82
GeometryObject::Subtree
getPathsAt(
const
DVec
& point,
bool
=
false
)
const override
;
83
84
std::size_t
getChildrenCount
()
const override
{
return
0; }
85
86
shared_ptr<GeometryObject>
getChildNo(std::size_t
child_no
)
const override
;
87
88
shared_ptr<const GeometryObject>
changedVersion(
const
GeometryObject::Changer
&
changer
,
89
Vec<3, double>
* translation = 0)
const override
;
90
91
// void extractToVec(const GeometryObject::Predicate& predicate, std::vector< shared_ptr<const GeometryObjectD<dim>
92
// > >& dest, const PathHints* = 0) const {
93
// if (predicate(*this)) dest.push_back(static_pointer_cast< const GeometryObjectD<dim>
94
// >(this->shared_from_this()));
95
// }
96
97
shared_ptr<GeometryObject>
deepCopy(
98
std::map<
const
GeometryObject
*,
shared_ptr<GeometryObject>
>&
copied
)
const override
;
99
100
bool
contains(
const
DVec& p)
const override
;
101
102
void
addPointsAlongToSet
(std::set<double>& points,
103
Primitive<3>::Direction
direction,
104
unsigned
max_steps,
105
double
min_step_size)
const override
{}
106
107
void
addLineSegmentsToSet
(std::set<
typename
GeometryObjectD<dim>::LineSegment
>& segments,
108
unsigned
max_steps,
109
double
min_step_size)
const override
{}
110
111
/*bool intersects(const Box& area) const override {
112
return this->getBoundingBox().intersects(area); //TODO ?? maybe set area to empty
113
}*/
114
};
115
116
PLASK_API_EXTERN_TEMPLATE_STRUCT
(
GeometryObjectSeparator<2>
)
117
PLASK_API_EXTERN_TEMPLATE_STRUCT
(
GeometryObjectSeparator<3>
)
118
119
125
template
<
int
dim,
int
direction>
struct
Gap1D
:
public
GeometryObjectSeparator
<dim> {
126
static_assert
(direction < dim,
"direction must be from 0 to dim-1"
);
127
128
typedef
GeometryObjectSeparator<dim>
BaseClass
;
129
130
typedef
typename
BaseClass::DVec
DVec
;
131
typedef
typename
BaseClass::Box
Box
;
132
133
static
constexpr
const
char
* NAME =
"gap"
;
134
static
constexpr
const
char
* XML_SIZE_ATTR =
"size"
;
135
136
std::string
getTypeName
()
const override
{
return
NAME; }
137
139
double
size
;
140
145
Gap1D
(
double
size = 0.0) : size(size) {}
146
147
Box
getBoundingBox
()
const override
{
148
auto
size_vec
=
Primitive<dim>::ZERO_VEC
;
149
size_vec
[direction] = size;
150
return
Box
(
Primitive<dim>::ZERO_VEC
,
size_vec
);
151
}
152
157
void
setSize
(
double
new_size
) {
158
size =
new_size
;
159
this->fireChanged(
GeometryObject::Event::EVENT_RESIZE
);
160
}
161
162
void
writeXMLAttr
(
XMLWriter::Element
&
dest_xml_object
,
const
AxisNames
& axes)
const override
{
163
BaseClass::writeXMLAttr(
dest_xml_object
, axes);
164
dest_xml_object
.attr(XML_SIZE_ATTR, size);
165
}
166
167
shared_ptr<GeometryObject>
shallowCopy
()
const override
{
return
make_shared<Gap1D>
(size); }
168
};
169
170
}
// namespace plask
171
172
#endif
// PLASK__GEOMETRY_SEPARATOR_H
plask
geometry
separator.hpp
Generated by
1.9.8