File indexing completed on 2025-09-17 08:53:44
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <functional>
0010 #include <memory>
0011 #include <optional>
0012 #include <unordered_map>
0013 #include <vector>
0014
0015 #include "celeritas/io/ImportOpticalModel.hh"
0016
0017 #include "Model.hh"
0018 #include "Types.hh"
0019
0020 namespace celeritas
0021 {
0022 class MaterialParams;
0023 struct ImportData;
0024 struct ImportOpticalRayleigh;
0025 struct ImportWavelengthShift;
0026
0027 namespace optical
0028 {
0029 class MaterialParams;
0030 class ImportedModels;
0031 class ImportedMaterials;
0032
0033
0034
0035
0036 class ModelImporter
0037 {
0038 public:
0039
0040
0041 using IMC = ImportModelClass;
0042 using SPConstImported = std::shared_ptr<ImportedModels const>;
0043 using SPConstMaterial = std::shared_ptr<MaterialParams const>;
0044 using SPConstImportedMaterial = std::shared_ptr<ImportedMaterials const>;
0045 using SPConstCoreMaterial
0046 = std::shared_ptr<::celeritas::MaterialParams const>;
0047
0048
0049
0050 struct UserBuildInput
0051 {
0052 SPConstImported imported;
0053 SPConstMaterial material;
0054 SPConstImportedMaterial import_material;
0055 SPConstCoreMaterial core_material;
0056 };
0057
0058
0059
0060 using ModelBuilder = Model::ModelBuilder;
0061 using UserBuildFunction
0062 = std::function<std::optional<ModelBuilder>(UserBuildInput const&)>;
0063 using UserBuildMap = std::unordered_map<IMC, UserBuildFunction>;
0064
0065
0066 public:
0067
0068 ModelImporter(ImportData const& data,
0069 SPConstMaterial material,
0070 SPConstCoreMaterial core_material,
0071 UserBuildMap user_build);
0072
0073
0074 ModelImporter(ImportData const& data,
0075 SPConstMaterial material,
0076 SPConstCoreMaterial core_material);
0077
0078
0079 std::optional<ModelBuilder> operator()(IMC imc) const;
0080
0081 private:
0082 UserBuildInput input_;
0083 UserBuildMap user_build_map_;
0084
0085 SPConstImported const& imported() const { return input_.imported; }
0086 SPConstMaterial const& material() const { return input_.material; }
0087 SPConstImportedMaterial const& import_material() const
0088 {
0089 return input_.import_material;
0090 }
0091 SPConstCoreMaterial const& core_material() const
0092 {
0093 return input_.core_material;
0094 }
0095
0096 ModelBuilder build_absorption() const;
0097 ModelBuilder build_rayleigh() const;
0098 };
0099
0100
0101
0102
0103
0104
0105
0106
0107 struct WarnAndIgnoreModel
0108 {
0109
0110
0111 using UserBuildInput = ModelImporter::UserBuildInput;
0112 using ModelBuilder = ModelImporter::ModelBuilder;
0113
0114
0115
0116 std::optional<ModelBuilder> operator()(UserBuildInput const&) const;
0117
0118
0119 ImportModelClass model;
0120 };
0121
0122
0123 }
0124 }