PLaSK library
Loading...
Searching...
No Matches
intersection.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_INTERSECTION_H
15
#define PLASK__GEOMETRY_INTERSECTION_H
16
17
#include "
transform.hpp
"
18
19
namespace
plask
{
20
26
template
<
int
dim>
struct
PLASK_API
Intersection
:
public
GeometryObjectTransform
<dim> {
27
static
const
char
*
NAME
;
28
29
std::string
getTypeName
()
const override
{
return
NAME; }
30
31
typedef
typename
GeometryObjectTransform<dim>::ChildType
ChildType
;
32
34
typedef
typename
GeometryObjectTransform<dim>::DVec
DVec
;
35
37
typedef
typename
GeometryObjectTransform<dim>::Box
Box
;
38
39
using
GeometryObjectTransform
<dim>::getChild;
40
44
shared_ptr<ChildType>
envelope
;
45
46
shared_ptr<ChildType>
getEnvelope
()
const
{
return
envelope; }
47
48
void
setEnvelope
(shared_ptr<ChildType>
clipShape
) {
49
if
(this->envelope ==
clipShape
)
return
;
50
this->envelope =
clipShape
;
51
this->fireChanged(
GeometryObject::Event::EVENT_RESIZE
);
52
}
53
54
// Intersection(const Intersection<dim>& tocpy) = default;
55
60
explicit
Intersection
(shared_ptr<
GeometryObjectD<dim>
> child = shared_ptr<
GeometryObjectD<dim>
>(),
61
shared_ptr<
GeometryObjectD<dim>
>
clipShape
= shared_ptr<
GeometryObjectD<dim>
>())
62
:
GeometryObjectTransform
<dim>(child), envelope(
clipShape
) {}
63
68
explicit
Intersection
(
GeometryObjectD<dim>
& child,
69
shared_ptr<
GeometryObjectD<dim>
>
clipShape
= shared_ptr<
GeometryObjectD<dim>
>())
70
:
GeometryObjectTransform
<dim>(child), envelope(
clipShape
) {}
71
72
shared_ptr<Material>
getMaterial(
const
DVec& p)
const override
;
73
74
bool
contains(
const
DVec& p)
const override
;
75
76
using
GeometryObjectTransform
<dim>::getPathsTo;
77
78
GeometryObject::Subtree
getPathsAt(
const
DVec& point,
bool
all
=
false
)
const override
;
79
80
Box fromChildCoords(
const
typename
ChildType::Box&
child_bbox
)
const override
;
81
82
void
getBoundingBoxesToVec(
const
GeometryObject::Predicate
& predicate,
83
std::vector<Box>&
dest
,
84
const
PathHints
* path = 0)
const override
;
85
86
void
getPositionsToVec(
const
GeometryObject::Predicate
& predicate,
87
std::vector<DVec>&
dest
,
88
const
PathHints
* path = 0)
const override
;
89
94
shared_ptr<Intersection<dim>
>
copyShallow
()
const
{
95
return
plask::make_shared<Intersection<dim>
>(getChild(), envelope);
96
}
97
98
shared_ptr<GeometryObject>
shallowCopy()
const override
;
99
105
shared_ptr<Intersection<dim>
>
copyShallow
(shared_ptr<
GeometryObjectD<dim>
>
clipShape
)
const
{
106
return
plask::make_shared<Intersection<dim>
>(getChild(),
clipShape
);
107
}
108
109
void
addPointsAlongToSet(std::set<double>& points,
110
Primitive<3>::Direction
direction,
111
unsigned
max_steps,
112
double
min_step_size)
const override
;
113
114
void
addLineSegmentsToSet(std::set<
typename
GeometryObjectD<dim>::LineSegment
>& segments,
115
unsigned
max_steps,
116
double
min_step_size)
const override
;
117
123
inline
bool
inEnvelope
(
const
typename
Intersection<dim>::DVec
& p)
const
{
124
return
!envelope || envelope->contains(p);
125
}
126
127
protected
:
128
void
writeXMLChildren(
XMLWriter::Element
&
dest_xml_object
,
129
GeometryObject::WriteXMLCallback
&
write_cb
,
130
const
AxisNames
& axes)
const override
;
131
};
132
133
PLASK_API_EXTERN_TEMPLATE_STRUCT
(
Intersection<2>
)
134
PLASK_API_EXTERN_TEMPLATE_STRUCT
(
Intersection<3>
)
135
136
}
// namespace plask
137
138
#endif
// PLASK__GEOMETRY_INTERSECTION_H
plask
geometry
intersection.hpp
Generated by
1.9.8