File indexing completed on 2025-01-18 09:59:34
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "../ImageData.hh"
0011 #include "../ImageLineView.hh"
0012 #include "../Raytracer.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018
0019
0020
0021
0022 struct VolumeIdCalculator
0023 {
0024 template<class GTV>
0025 CELER_FUNCTION int operator()(GTV const& geo) const
0026 {
0027 if (geo.is_outside())
0028 return -1;
0029 return static_cast<int>(geo.volume_id().get());
0030 }
0031 };
0032
0033
0034
0035
0036
0037 template<class GTV, class F>
0038 struct RaytraceExecutor
0039 {
0040
0041
0042
0043 using GeoTrackView = GTV;
0044 using GeoParamsRef = typename GTV::ParamsRef;
0045 using GeoStateRef = typename GTV::StateRef;
0046 using ImgParamsRef = NativeCRef<ImageParamsData>;
0047 using ImgStateRef = NativeRef<ImageStateData>;
0048
0049
0050
0051 GeoParamsRef geo_params;
0052 GeoStateRef geo_state;
0053 ImgParamsRef img_params;
0054 ImgStateRef img_state;
0055
0056 F calc_id;
0057
0058
0059
0060
0061 inline CELER_FUNCTION void operator()(ThreadId tid) const;
0062 };
0063
0064
0065
0066
0067
0068
0069
0070 template<class GTV, class F>
0071 CELER_FUNCTION void RaytraceExecutor<GTV, F>::operator()(ThreadId tid) const
0072 {
0073 CELER_EXPECT(tid < img_params.scalars.dims[0]);
0074 CELER_EXPECT(geo_state.size() == img_params.scalars.dims[0]);
0075
0076
0077 GeoTrackView geo{geo_params, geo_state, TrackSlotId{tid.unchecked_get()}};
0078 ImageLineView line{img_params, img_state, tid.unchecked_get()};
0079 Raytracer trace(geo, calc_id, line);
0080 for (auto col : range(line.max_index()))
0081 {
0082 int val = trace(col);
0083 line.set_pixel(col, val);
0084 }
0085 }
0086
0087
0088 }
0089 }