File indexing completed on 2025-09-14 09:01:28
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <vector>
0010
0011 #include "corecel/OpaqueId.hh"
0012
0013 #include "IntersectRegion.hh"
0014 #include "ObjectInterface.hh"
0015 #include "Solid.hh"
0016
0017 namespace celeritas
0018 {
0019 namespace orangeinp
0020 {
0021
0022
0023
0024
0025
0026
0027
0028
0029 class PolySegments
0030 {
0031 public:
0032
0033
0034 using VecReal = std::vector<real_type>;
0035
0036
0037 public:
0038
0039 PolySegments(VecReal&& outer, VecReal&& z);
0040
0041
0042 PolySegments(VecReal&& inner, VecReal&& outer, VecReal&& z);
0043
0044
0045 size_type size() const { return outer_.size() - 1; }
0046
0047
0048 inline VecReal const& inner() const;
0049
0050
0051 VecReal const& outer() const { return outer_; }
0052
0053
0054 VecReal const& z() const { return z_; }
0055
0056
0057 inline Real2 inner(size_type) const;
0058
0059
0060 inline Real2 outer(size_type) const;
0061
0062
0063 inline Real2 z(size_type) const;
0064
0065
0066 bool has_exclusion() const { return !inner_.empty(); }
0067
0068 private:
0069 VecReal inner_;
0070 VecReal outer_;
0071 VecReal z_;
0072 };
0073
0074
0075
0076
0077
0078 auto PolySegments::inner() const -> VecReal const&
0079 {
0080 CELER_EXPECT(has_exclusion());
0081 return inner_;
0082 }
0083
0084
0085
0086
0087
0088 auto PolySegments::inner(size_type i) const -> Real2
0089 {
0090 CELER_EXPECT(this->has_exclusion() && i < this->size());
0091 return {inner_[i], inner_[i + 1]};
0092 }
0093
0094
0095
0096
0097
0098 auto PolySegments::outer(size_type i) const -> Real2
0099 {
0100 CELER_EXPECT(i < this->size());
0101 return {outer_[i], outer_[i + 1]};
0102 }
0103
0104
0105
0106
0107
0108 auto PolySegments::z(size_type i) const -> Real2
0109 {
0110 CELER_EXPECT(i < this->size());
0111 return {z_[i], z_[i + 1]};
0112 }
0113
0114
0115
0116
0117
0118 class PolySolidBase : public ObjectInterface
0119 {
0120 public:
0121
0122 ~PolySolidBase() override;
0123
0124
0125 std::string_view label() const final { return label_; }
0126
0127
0128 PolySegments const& segments() const { return segments_; }
0129
0130
0131 SolidEnclosedAngle enclosed_angle() const { return enclosed_; }
0132
0133 protected:
0134 PolySolidBase(std::string&& label,
0135 PolySegments&& segments,
0136 SolidEnclosedAngle&& enclosed);
0137
0138
0139
0140 CELER_DEFAULT_COPY_MOVE(PolySolidBase);
0141
0142
0143 private:
0144 std::string label_;
0145 PolySegments segments_;
0146 SolidEnclosedAngle enclosed_;
0147 };
0148
0149
0150
0151
0152
0153 class PolyCone final : public PolySolidBase
0154 {
0155 public:
0156
0157 static SPConstObject or_solid(std::string&& label,
0158 PolySegments&& segments,
0159 SolidEnclosedAngle&& enclosed);
0160
0161
0162 PolyCone(std::string&& label,
0163 PolySegments&& segments,
0164 SolidEnclosedAngle&& enclosed);
0165
0166
0167 NodeId build(VolumeBuilder&) const final;
0168
0169
0170 void output(JsonPimpl*) const final;
0171 };
0172
0173
0174
0175
0176
0177 class PolyPrism final : public PolySolidBase
0178 {
0179 public:
0180
0181 static SPConstObject or_solid(std::string&& label,
0182 PolySegments&& segments,
0183 SolidEnclosedAngle&& enclosed,
0184 int num_sides,
0185 real_type orientation);
0186
0187
0188 PolyPrism(std::string&& label,
0189 PolySegments&& segments,
0190 SolidEnclosedAngle&& enclosed,
0191 int num_sides,
0192 real_type orientation);
0193
0194
0195 NodeId build(VolumeBuilder&) const final;
0196
0197
0198 void output(JsonPimpl*) const final;
0199
0200
0201
0202
0203 int num_sides() const { return num_sides_; }
0204
0205 real_type orientation() const { return orientation_; }
0206
0207 private:
0208 int num_sides_;
0209 real_type orientation_;
0210 };
0211
0212
0213 }
0214 }