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
19namespace plask {
20
26template <int dim> struct PLASK_API Intersection : public GeometryObjectTransform<dim> {
27 static const char* NAME;
28
29 std::string getTypeName() const override { return NAME; }
30
32
35
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
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
95 return plask::make_shared<Intersection<dim>>(getChild(), envelope);
96 }
97
98 shared_ptr<GeometryObject> shallowCopy() const override;
99
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,
130 const AxisNames& axes) const override;
131};
132
135
136} // namespace plask
137
138#endif // PLASK__GEOMETRY_INTERSECTION_H