File indexing completed on 2025-01-30 10:17:12
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/cont/EnumClassUtils.hh"
0011 #include "corecel/math/Algorithms.hh"
0012 #include "orange/OrangeTypes.hh"
0013
0014 #include "SurfaceFwd.hh"
0015
0016 namespace celeritas
0017 {
0018
0019
0020
0021
0022
0023
0024
0025
0026 template<SurfaceType S>
0027 struct SurfaceTypeTraits;
0028
0029 #define ORANGE_SURFACE_TRAITS(ENUM_VALUE, CLS) \
0030 template<> \
0031 struct SurfaceTypeTraits<SurfaceType::ENUM_VALUE> \
0032 : public EnumToClass<SurfaceType, SurfaceType::ENUM_VALUE, CLS> \
0033 { \
0034 }
0035
0036
0037 ORANGE_SURFACE_TRAITS(px, PlaneAligned<Axis::x>);
0038 ORANGE_SURFACE_TRAITS(py, PlaneAligned<Axis::y>);
0039 ORANGE_SURFACE_TRAITS(pz, PlaneAligned<Axis::z>);
0040 ORANGE_SURFACE_TRAITS(cxc, CylCentered<Axis::x>);
0041 ORANGE_SURFACE_TRAITS(cyc, CylCentered<Axis::y>);
0042 ORANGE_SURFACE_TRAITS(czc, CylCentered<Axis::z>);
0043 ORANGE_SURFACE_TRAITS(sc, SphereCentered);
0044 ORANGE_SURFACE_TRAITS(cx, CylAligned<Axis::x>);
0045 ORANGE_SURFACE_TRAITS(cy, CylAligned<Axis::y>);
0046 ORANGE_SURFACE_TRAITS(cz, CylAligned<Axis::z>);
0047 ORANGE_SURFACE_TRAITS(p, Plane);
0048 ORANGE_SURFACE_TRAITS(s, Sphere);
0049 ORANGE_SURFACE_TRAITS(kx, ConeAligned<Axis::x>);
0050 ORANGE_SURFACE_TRAITS(ky, ConeAligned<Axis::y>);
0051 ORANGE_SURFACE_TRAITS(kz, ConeAligned<Axis::z>);
0052 ORANGE_SURFACE_TRAITS(sq, SimpleQuadric);
0053 ORANGE_SURFACE_TRAITS(gq, GeneralQuadric);
0054 ORANGE_SURFACE_TRAITS(inv, Involute);
0055
0056
0057 #undef ORANGE_SURFACE_TRAITS
0058
0059
0060
0061
0062
0063
0064
0065
0066 template<class F>
0067 CELER_CONSTEXPR_FUNCTION decltype(auto)
0068 visit_surface_type(F&& func, SurfaceType st)
0069 {
0070 #define ORANGE_ST_VISIT_CASE(TYPE) \
0071 case SurfaceType::TYPE: \
0072 return celeritas::forward<F>(func)( \
0073 SurfaceTypeTraits<SurfaceType::TYPE>{})
0074
0075 switch (st)
0076 {
0077 ORANGE_ST_VISIT_CASE(px);
0078 ORANGE_ST_VISIT_CASE(py);
0079 ORANGE_ST_VISIT_CASE(pz);
0080 ORANGE_ST_VISIT_CASE(cxc);
0081 ORANGE_ST_VISIT_CASE(cyc);
0082 ORANGE_ST_VISIT_CASE(czc);
0083 ORANGE_ST_VISIT_CASE(sc);
0084 ORANGE_ST_VISIT_CASE(cx);
0085 ORANGE_ST_VISIT_CASE(cy);
0086 ORANGE_ST_VISIT_CASE(cz);
0087 ORANGE_ST_VISIT_CASE(p);
0088 ORANGE_ST_VISIT_CASE(s);
0089 ORANGE_ST_VISIT_CASE(kx);
0090 ORANGE_ST_VISIT_CASE(ky);
0091 ORANGE_ST_VISIT_CASE(kz);
0092 ORANGE_ST_VISIT_CASE(sq);
0093 ORANGE_ST_VISIT_CASE(gq);
0094 case SurfaceType::inv:
0095
0096
0097 CELER_ASSERT_UNREACHABLE();
0098 default:
0099 CELER_ASSERT_UNREACHABLE();
0100 }
0101 #undef ORANGE_ST_VISIT_CASE
0102 }
0103
0104
0105 }