PLaSK library

Loading...
Searching...
No Matches
separator.cpp
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#include "separator.hpp"
15
16#define PLASK_SEPARATOR2D_NAME ("separator" PLASK_GEOMETRY_TYPE_NAME_SUFFIX_2D)
17#define PLASK_SEPARATOR3D_NAME ("separator" PLASK_GEOMETRY_TYPE_NAME_SUFFIX_3D)
18
19 namespace plask {
20
21 template < int dim >
22 GeometryObject::Type GeometryObjectSeparator<dim>::getType() const { return GeometryObject::TYPE_SEPARATOR; }
23
24 template < int dim >
25 const char* GeometryObjectSeparator<dim>::NAME = dim == 2 ? PLASK_SEPARATOR2D_NAME : PLASK_SEPARATOR3D_NAME;
26
27 template < int dim >
28std::string GeometryObjectSeparator<dim>::getTypeName() const { return NAME; }
29
30 template < int dim >
31 shared_ptr<Material> GeometryObjectSeparator<dim>::getMaterial(const typename GeometryObjectSeparator<dim>::DVec &/*p*/) const {
32 return shared_ptr<Material>();
33}
34
35/*template < int dim >
36 void GeometryObjectSeparator<dim>::getLeafsInfoToVec(std::vector<std::tuple<shared_ptr<const GeometryObject>, GeometryObjectSeparator<dim>::Box, GeometryObjectSeparator<dim>::DVec> > &dest, const PathHints *path) const {
37 // do nothing
38}*/
39
40 template < int dim >
41 void GeometryObjectSeparator<dim>::getBoundingBoxesToVec(const GeometryObject::Predicate &/*predicate*/, std::vector<typename GeometryObjectSeparator<dim>::Box> &/*dest*/, const PathHints* /*path*/) const {
42 //do nothing
43 //if (predicate(*this)) dest.push_back(this->getBoundingBox());
44}
45
46 template < int dim >
47 void GeometryObjectSeparator<dim>::getObjectsToVec(const GeometryObject::Predicate &predicate, std::vector<shared_ptr<const GeometryObject> > &dest, const PathHints* /*path*/) const {
48 if (predicate(*this)) dest.push_back(this->shared_from_this());
49}
50
51 template < int dim >
52 void GeometryObjectSeparator<dim>::getPositionsToVec(const GeometryObject::Predicate &predicate, std::vector<typename GeometryObjectSeparator<dim>::DVec> &dest, const PathHints *) const {
53 if (predicate(*this)) dest.push_back(Primitive<dim>::ZERO_VEC);
54}
55
56 template < int dim >
57 bool GeometryObjectSeparator<dim>::hasInSubtree(const GeometryObject &el) const {
58 return &el == this;
59}
60
61 template < int dim >
62 GeometryObject::Subtree GeometryObjectSeparator<dim>::getPathsTo(const GeometryObject &el, const PathHints* /*path*/) const {
63 return GeometryObject::Subtree( &el == this ? this->shared_from_this() : shared_ptr<const GeometryObject>() );
64}
65
66 template < int dim >
67 GeometryObject::Subtree GeometryObjectSeparator<dim>::getPathsAt(const typename GeometryObjectSeparator<dim>::DVec &point, bool) const {
68 return GeometryObject::Subtree( this->contains(point) ? this->shared_from_this() : shared_ptr<const GeometryObject>() );
69}
70
71 template < int dim >
72 shared_ptr<GeometryObject> GeometryObjectSeparator<dim>::getChildNo(std::size_t /*child_no*/) const {
73 throw OutOfBoundsException("geometryObjectLeaf::getChildNo", "child_no");
74}
75
76 template < int dim >
77 shared_ptr<const GeometryObject> GeometryObjectSeparator<dim>::changedVersion(const GeometryObject::Changer &changer, Vec<3, double> *translation) const {
78 shared_ptr<GeometryObject> result(const_pointer_cast<GeometryObject>(this->shared_from_this()));
79 changer.apply(result, translation);
80 return result;
81}
82
83 template < int dim >
84 shared_ptr<GeometryObject> GeometryObjectSeparator<dim>::deepCopy(std::map<const GeometryObject*, shared_ptr<GeometryObject>>& copied) const {
85 auto found = copied.find(this);
86 if (found != copied.end()) return found->second;
87 shared_ptr<GeometryObject> result = this->shallowCopy();
88 copied[this] = result;
89 return result;
90}
91
92
93 template < int dim >
94 bool GeometryObjectSeparator<dim>::contains(const typename GeometryObjectSeparator<dim>::DVec &/*p*/) const {
95 return false;
96}
97
98
99
100
101
102 template struct PLASK_API GeometryObjectSeparator<2>;
103 template struct PLASK_API GeometryObjectSeparator<3>;
104
105
106
107}