Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:59:58

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file geocel/rasterize/SafetyImager.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/data/CollectionStateStore.hh"
0010 #include "geocel/GeoTraits.hh"
0011 
0012 #include "Image.hh"
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 /*!
0018  * Write safety distances from a geometry.
0019  *
0020  * The file format is JSON lines:
0021  * - first line: metadata
0022  * - each further line: progressive y coordinates
0023  *
0024  * \note This is a very rough-and-ready class that should be restructured and
0025  * integrated with the ray tracer so that it can be executed in parallel on
0026  * GPU. The interface will change and this will be added to the \c celer-geo
0027  * app someday!
0028  */
0029 template<class G>
0030 class SafetyImager
0031 {
0032     static_assert(std::is_base_of_v<GeoParamsInterface, G>);
0033 
0034   public:
0035     //!@{
0036     //! \name Type aliases
0037     using SPConstGeo = std::shared_ptr<G const>;
0038     //!@}
0039 
0040   public:
0041     // Construct with geometry
0042     explicit SafetyImager(SPConstGeo geo);
0043 
0044     // Save an image
0045     void operator()(ImageParams const& image, std::string filename);
0046 
0047   private:
0048     using TraitsT = GeoTraits<G>;
0049     template<Ownership W, MemSpace M>
0050     using StateData = typename TraitsT::template StateData<W, M>;
0051     using HostStateStore = CollectionStateStore<StateData, MemSpace::host>;
0052     using GeoTrackView = typename TraitsT::TrackView;
0053 
0054     SPConstGeo geo_;
0055     HostStateStore host_state_;
0056 };
0057 
0058 //---------------------------------------------------------------------------//
0059 }  // namespace celeritas