|
|
|||
File indexing completed on 2026-11-07 10:11:39
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 celeritas/optical/surface/detail/BuiltinSurfaceModelBuilder.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <map> 0010 #include <memory> 0011 #include <string_view> 0012 #include <vector> 0013 0014 #include "corecel/io/Logger.hh" 0015 #include "celeritas/Types.hh" 0016 #include "celeritas/optical/surface/SurfaceModel.hh" 0017 0018 namespace celeritas 0019 { 0020 namespace optical 0021 { 0022 namespace detail 0023 { 0024 //---------------------------------------------------------------------------// 0025 /*! 0026 * Utility for building built-in surface models from input data. 0027 * 0028 * Wraps the call to build a model with a check on whether the input data is 0029 * empty. If empty, then the model is not built. Keeps track of number of 0030 * models built and constructs new models with the next ID. 0031 */ 0032 class BuiltinSurfaceModelBuilder 0033 { 0034 public: 0035 //!@{ 0036 //! \name Type aliases 0037 using SPModel = std::shared_ptr<SurfaceModel>; 0038 //!@} 0039 0040 public: 0041 // Construct with storage to fill 0042 explicit inline BuiltinSurfaceModelBuilder(std::vector<SPModel>& models); 0043 0044 // Construct a built-in surface model 0045 template<class M> 0046 inline void build(std::map<PhysSurfaceId, typename M::InputT> const&); 0047 0048 // Number of physics surfaces that have been constructed 0049 size_type num_surfaces() const { return num_surf_; } 0050 0051 private: 0052 std::vector<SPModel>& models_; 0053 size_type num_surf_{0}; 0054 }; 0055 0056 //---------------------------------------------------------------------------// 0057 // INLINE DEFINITIONS 0058 //---------------------------------------------------------------------------// 0059 /*! 0060 * Construct with defaults. 0061 */ 0062 BuiltinSurfaceModelBuilder::BuiltinSurfaceModelBuilder( 0063 std::vector<SPModel>& model) 0064 : models_(model) 0065 { 0066 } 0067 0068 //---------------------------------------------------------------------------// 0069 /*! 0070 * Construct a built-in surface model. 0071 * 0072 * Only constructs and adds the surface model if the \c layer_map is not empty. 0073 */ 0074 template<class M> 0075 void BuiltinSurfaceModelBuilder::build( 0076 std::map<PhysSurfaceId, typename M::InputT> const& layer_map) 0077 { 0078 if (!layer_map.empty()) 0079 { 0080 models_.push_back( 0081 std::make_shared<M>(SurfaceModelId(models_.size()), layer_map)); 0082 num_surf_ += layer_map.size(); 0083 } 0084 } 0085 0086 //---------------------------------------------------------------------------// 0087 } // namespace detail 0088 } // namespace optical 0089 } // namespace celeritas
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|