File indexing completed on 2025-01-30 10:17:12
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <string>
0011 #include <utility>
0012
0013 #include "orange/OrangeTypes.hh"
0014
0015 #include "SurfaceFwd.hh"
0016 #include "VariantSurface.hh"
0017
0018 namespace celeritas
0019 {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 class FaceNamer
0030 {
0031 public:
0032
0033 FaceNamer() = default;
0034
0035
0036 explicit inline FaceNamer(std::string&& prefix);
0037
0038
0039 template<class S>
0040 inline std::string operator()(Sense s, S const& surf);
0041
0042
0043 std::string operator()(Sense s, VariantSurface const& surf);
0044
0045
0046 inline std::string operator()(std::string const& s) const;
0047
0048 private:
0049 struct State
0050 {
0051 int num_plane{0};
0052 int num_gq{0};
0053 };
0054
0055
0056 std::string prefix_;
0057
0058
0059 State state_;
0060
0061
0062 struct Impl
0063 {
0064 State* state_;
0065 Sense sense_;
0066
0067
0068
0069 template<Axis T>
0070 std::string operator()(PlaneAligned<T> const&) const;
0071
0072 template<Axis T>
0073 std::string operator()(CylCentered<T> const&) const;
0074
0075 std::string operator()(SphereCentered const&) const;
0076
0077 template<Axis T>
0078 std::string operator()(CylAligned<T> const&) const;
0079
0080 std::string operator()(Plane const&) const;
0081
0082 std::string operator()(Sphere const&) const;
0083
0084 template<Axis T>
0085 std::string operator()(ConeAligned<T> const&) const;
0086
0087 std::string operator()(SimpleQuadric const&) const;
0088
0089 std::string operator()(GeneralQuadric const&) const;
0090
0091 std::string operator()(Involute const&) const;
0092 };
0093 };
0094
0095
0096
0097
0098
0099 FaceNamer::FaceNamer(std::string&& prefix) : prefix_{std::move(prefix)}
0100 {
0101 if (!prefix_.empty() && prefix_.back() != '.')
0102 {
0103 prefix_.push_back('.');
0104 }
0105 }
0106
0107
0108
0109
0110
0111 template<class S>
0112 std::string FaceNamer::operator()(Sense s, S const& surf)
0113 {
0114 std::string result = prefix_;
0115 result += Impl{&state_, s}(surf);
0116 return result;
0117 }
0118
0119
0120
0121
0122
0123
0124
0125
0126 std::string FaceNamer::operator()(std::string const& s) const
0127 {
0128 std::string result = prefix_;
0129 result += s;
0130 return result;
0131 }
0132
0133
0134 }