PLaSK library
Loading...
Searching...
No Matches
rectangular_common.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 */
15#include "regular1d.hpp"
16
17namespace plask {
18
19shared_ptr<MeshAxis> readMeshAxis(XMLReader& reader) {
20 plask::optional<std::string> type = reader.getAttribute("type");
21 if (type) {
22 if (*type == "regular") return readRegularMeshAxis(reader);
23 else if (*type == "ordered") return readRectilinearMeshAxis(reader);
24 else throw XMLBadAttrException(reader, "type", *type, "\"regular\" or \"ordered\"");
25 } else {
26 if (reader.hasAttribute("start")) return readRegularMeshAxis(reader);
27 else return readRectilinearMeshAxis(reader);
28 }
29}
30
32 if (boundary_desc == "bottom") return getBottomBoundary();
33 if (boundary_desc == "left") return getLeftBoundary();
34 if (boundary_desc == "right") return getRightBoundary();
35 if (boundary_desc == "top") return getTopBoundary();
36 return Boundary();
37}
38
40 auto side = boundary_desc.getAttribute("side");
41 auto line = boundary_desc.getAttribute("line");
42 if (side && line) {
44 } else if (side) {
45 if (*side == "bottom")
46 return details::parseBoundaryFromXML<Boundary, 2>(boundary_desc, manager, &getBottomBoundary, &getBottomOfBoundary);
47 if (*side == "left")
48 return details::parseBoundaryFromXML<Boundary, 2>(boundary_desc, manager, &getLeftBoundary, &getLeftOfBoundary);
49 if (*side == "right")
50 return details::parseBoundaryFromXML<Boundary, 2>(boundary_desc, manager, &getRightBoundary, &getRightOfBoundary);
51 if (*side == "top")
52 return details::parseBoundaryFromXML<Boundary, 2>(boundary_desc, manager, &getTopBoundary, &getTopOfBoundary);
53 throw XMLBadAttrException(boundary_desc, "side", *side);
54 } else if (line) {
55 double at = boundary_desc.requireAttribute<double>("at"),
56 start = boundary_desc.requireAttribute<double>("start"),
57 stop = boundary_desc.requireAttribute<double>("stop");
58 boundary_desc.requireTagEnd();
59 if (*line == "vertical")
60 return getVerticalBoundaryNear(at, start, stop);
61 if (*line == "horizontal")
62 return getHorizontalBoundaryNear(at, start, stop);
63 throw XMLBadAttrException(boundary_desc, "line", *line);
64 }
65 return Boundary();
66}
67
68
69
71 if (boundary_desc == "back") return getBackBoundary();
72 if (boundary_desc == "front") return getFrontBoundary();
73 if (boundary_desc == "left") return getLeftBoundary();
74 if (boundary_desc == "right") return getRightBoundary();
75 if (boundary_desc == "bottom") return getBottomBoundary();
76 if (boundary_desc == "top") return getTopBoundary();
77 return Boundary();
78}
79
81 auto side = boundary_desc.requireAttribute("side");
82 /* auto side = boundary_desc.getAttribute("side");
83 auto line = boundary_desc.getAttribute("line");
84 if (side && line) {
85 throw XMLConflictingAttributesException(boundary_desc, "size", "line");
86 } else if (side)*/ {
87 if (side == "back")
88 return details::parseBoundaryFromXML<Boundary, 3>(boundary_desc, manager, &getBackBoundary, &getBackOfBoundary);
89 if (side == "front")
90 return details::parseBoundaryFromXML<Boundary, 3>(boundary_desc, manager, &getFrontBoundary, &getFrontOfBoundary);
91 if (side == "left")
92 return details::parseBoundaryFromXML<Boundary, 3>(boundary_desc, manager, &getLeftBoundary, &getLeftOfBoundary);
93 if (side == "right")
94 return details::parseBoundaryFromXML<Boundary, 3>(boundary_desc, manager, &getRightBoundary, &getRightOfBoundary);
95 if (side == "bottom")
96 return details::parseBoundaryFromXML<Boundary, 3>(boundary_desc, manager, &getBottomBoundary, &getBottomOfBoundary);
97 if (side == "top")
98 return details::parseBoundaryFromXML<Boundary, 3>(boundary_desc, manager, &getTopBoundary, &getTopOfBoundary);
99 throw XMLBadAttrException(boundary_desc, "side", side);
100 } /*else if (line) {
101 double at = boundary_desc.requireAttribute<double>("at"),
102 start = boundary_desc.requireAttribute<double>("start"),
103 stop = boundary_desc.requireAttribute<double>("stop");
104 boundary_desc.requireTagEnd();
105 if (*line == "vertical")
106 return getVerticalBoundaryNear(at, start, stop);
107 if (*line == "horizontal")
108 return getHorizontalBoundaryNear(at, start, stop);
109 throw XMLBadAttrException(boundary_desc, "line", *line);
110 }*/
111 return Boundary();
112}
113
114
115} // namespace plask