PLaSK library
Loading...
Searching...
No Matches
clip.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_CLIP_H
15#define PLASK__GEOMETRY_CLIP_H
16
17#include "transform.hpp"
18
19namespace plask {
20
25template <int dim> struct PLASK_API Clip : public GeometryObjectTransform<dim> {
26 static const char* NAME;
27
28 std::string getTypeName() const override { return NAME; }
29
31
34
37
38 using GeometryObjectTransform<dim>::getChild;
39
44
45 // Clip(const Clip<dim>& tocpy) = default;
46
51 explicit Clip(shared_ptr<GeometryObjectD<dim>> child = shared_ptr<GeometryObjectD<dim>>(),
52 const Box& clipBox = Primitive<dim>::INF_BOX)
53 : GeometryObjectTransform<dim>(child), clipBox(clipBox) {}
54
55 explicit Clip(GeometryObjectD<dim>& child, const Box& clipBox = Primitive<dim>::INF_BOX)
56 : GeometryObjectTransform<dim>(child), clipBox(clipBox) {}
57
58 shared_ptr<Material> getMaterial(const DVec& p) const override;
59
60 bool contains(const DVec& p) const override;
61
62 using GeometryObjectTransform<dim>::getPathsTo;
63
64 GeometryObject::Subtree getPathsAt(const DVec& point, bool all = false) const override;
65
66 Box fromChildCoords(const typename ChildType::Box& child_bbox) const override;
67
68 virtual void getPositionsToVec(const GeometryObject::Predicate& predicate,
69 std::vector<DVec>& dest,
70 const PathHints* path = 0) const override;
71
76 shared_ptr<Clip<dim>> copyShallow() const { return plask::make_shared<Clip<dim>>(getChild(), clipBox); }
77
78 shared_ptr<GeometryObject> shallowCopy() const override;
79
86 return plask::make_shared<Clip<dim>>(getChild(), new_clip);
87 }
88
89 void addPointsAlongToSet(std::set<double>& points,
91 unsigned max_steps,
92 double min_step_size) const override;
93
94 void addLineSegmentsToSet(std::set<typename GeometryObjectD<dim>::LineSegment>& segments,
95 unsigned max_steps,
96 double min_step_size) const override;
97
98 protected:
99 void writeXMLAttr(XMLWriter::Element& dest_xml_object, const AxisNames& axes) const override;
100
101 private:
102 void addClippedSegment(std::set<typename GeometryObjectD<dim>::LineSegment>& segments, DVec p0, DVec p1) const;
103};
104
107
110
111} // namespace plask
112
113#endif // PLASK__GEOMETRY_CLIP_H