Warning, file /include/orange/orangeinp/Shape.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <type_traits>
0010
0011 #include "IntersectRegion.hh"
0012 #include "ObjectInterface.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace orangeinp
0017 {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class ShapeBase : public ObjectInterface
0038 {
0039 public:
0040
0041 NodeId build(VolumeBuilder&) const final;
0042
0043
0044 void output(JsonPimpl*) const final;
0045
0046
0047 std::string_view label() const final { return label_; }
0048
0049
0050 virtual IntersectRegionInterface const& interior() const = 0;
0051
0052 ~ShapeBase() override = default;
0053
0054 protected:
0055
0056
0057 explicit ShapeBase(std::string&& label);
0058 CELER_DEFAULT_COPY_MOVE(ShapeBase);
0059
0060
0061 private:
0062 std::string label_;
0063 };
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 template<class T>
0080 class Shape final : public ShapeBase
0081 {
0082 static_assert(std::is_base_of_v<IntersectRegionInterface, T>);
0083
0084 public:
0085
0086 template<class... Ts>
0087 Shape(std::string&& label, Ts... region_args)
0088 : ShapeBase{std::move(label)}
0089 , region_{std::forward<Ts>(region_args)...}
0090 {
0091 }
0092
0093
0094 Shape(std::string&& label, T&& region)
0095 : ShapeBase{std::move(label)}, region_{std::move(region)}
0096 {
0097 }
0098
0099
0100 IntersectRegionInterface const& interior() const final { return region_; }
0101
0102 private:
0103 T region_;
0104 };
0105
0106
0107
0108
0109
0110 template<class T>
0111 Shape(std::string&&, T&&) -> Shape<T>;
0112
0113
0114
0115
0116
0117 using BoxShape = Shape<Box>;
0118 using ConeShape = Shape<Cone>;
0119 using CylinderShape = Shape<Cylinder>;
0120 using EllipsoidShape = Shape<Ellipsoid>;
0121 using ExtrudedPolygonShape = Shape<ExtrudedPolygon>;
0122 using GenPrismShape = Shape<GenPrism>;
0123 using InvoluteShape = Shape<Involute>;
0124 using ParallelepipedShape = Shape<Parallelepiped>;
0125 using PrismShape = Shape<Prism>;
0126 using SphereShape = Shape<Sphere>;
0127
0128
0129
0130
0131
0132 extern template class Shape<Box>;
0133 extern template class Shape<Cone>;
0134 extern template class Shape<Cylinder>;
0135 extern template class Shape<Ellipsoid>;
0136 extern template class Shape<ExtrudedPolygon>;
0137 extern template class Shape<GenPrism>;
0138 extern template class Shape<Involute>;
0139 extern template class Shape<Parallelepiped>;
0140 extern template class Shape<Prism>;
0141 extern template class Shape<Sphere>;
0142
0143
0144 }
0145 }