File indexing completed on 2026-01-07 10:01:43
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "geocel/SurfaceData.hh"
0012 #include "geocel/VolumeSurfaceView.hh"
0013 #include "celeritas/geo/GeoTrackView.hh"
0014
0015 namespace celeritas
0016 {
0017 namespace optical
0018 {
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 class VolumeSurfaceSelector
0042 {
0043 public:
0044
0045 inline CELER_FUNCTION
0046 VolumeSurfaceSelector(NativeCRef<SurfaceParamsData> const& params,
0047 VolumeId pre_volume,
0048 VolumeInstanceId pre_volume_inst);
0049
0050
0051 inline CELER_FUNCTION
0052 VolumeSurfaceSelector(NativeCRef<SurfaceParamsData> const& params,
0053 GeoTrackView const& geo);
0054
0055
0056 inline CELER_FUNCTION SurfaceId
0057 operator()(VolumeId post_volume, VolumeInstanceId post_volume_inst) const;
0058
0059
0060 inline CELER_FUNCTION SurfaceId operator()(GeoTrackView const&) const;
0061
0062 private:
0063 NativeCRef<SurfaceParamsData> const& params_;
0064 VolumeId pre_volume_;
0065 VolumeInstanceId pre_volume_inst_;
0066 };
0067
0068
0069
0070
0071
0072
0073
0074 CELER_FUNCTION VolumeSurfaceSelector::VolumeSurfaceSelector(
0075 NativeCRef<SurfaceParamsData> const& params,
0076 VolumeId pre_volume,
0077 VolumeInstanceId pre_volume_inst)
0078 : params_(params)
0079 , pre_volume_(pre_volume)
0080 , pre_volume_inst_(pre_volume_inst)
0081 {
0082 CELER_EXPECT(pre_volume_ < params_.volume_surfaces.size());
0083 CELER_EXPECT(pre_volume_inst_);
0084 }
0085
0086
0087
0088
0089
0090 CELER_FUNCTION VolumeSurfaceSelector::VolumeSurfaceSelector(
0091 NativeCRef<SurfaceParamsData> const& params, GeoTrackView const& geo)
0092 : VolumeSurfaceSelector(params, geo.volume_id(), geo.volume_instance_id())
0093 {
0094 CELER_EXPECT(!geo.is_outside());
0095 }
0096
0097
0098
0099
0100
0101
0102
0103 CELER_FUNCTION SurfaceId VolumeSurfaceSelector::operator()(
0104 VolumeId post_volume, VolumeInstanceId post_volume_inst) const
0105 {
0106 VolumeSurfaceView pre_surface{params_, pre_volume_};
0107
0108 if (auto surface_id
0109 = pre_surface.find_interface(pre_volume_inst_, post_volume_inst))
0110 {
0111 return surface_id;
0112 }
0113
0114 if (auto surface_id = pre_surface.boundary_id())
0115 {
0116 return surface_id;
0117 }
0118
0119 return VolumeSurfaceView{params_, post_volume}.boundary_id();
0120 }
0121
0122
0123
0124
0125
0126 CELER_FUNCTION SurfaceId
0127 VolumeSurfaceSelector::operator()(GeoTrackView const& geo) const
0128 {
0129 if (geo.is_outside())
0130 return SurfaceId{};
0131
0132 return (*this)(geo.volume_id(), geo.volume_instance_id());
0133 }
0134
0135
0136 }
0137 }