|
|
|||
File indexing completed on 2026-01-09 10:20:17
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 orange/g4org/Converter.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <functional> 0010 #include <memory> 0011 #include <unordered_map> 0012 0013 #include "corecel/Config.hh" 0014 0015 #include "orange/OrangeInput.hh" 0016 #include "orange/OrangeTypes.hh" 0017 0018 //---------------------------------------------------------------------------// 0019 // Forward declarations 0020 //---------------------------------------------------------------------------// 0021 0022 class G4LogicalVolume; 0023 0024 namespace celeritas 0025 { 0026 class GeantGeoParams; 0027 0028 struct OrangeInput; 0029 namespace orangeinp 0030 { 0031 class ProtoInterface; 0032 } 0033 0034 namespace g4org 0035 { 0036 //---------------------------------------------------------------------------// 0037 /*! 0038 * Create an ORANGE geometry model from an in-memory Geant4 model. 0039 * 0040 * Return the new world volume and a mapping of Geant4 logical volumes to 0041 * VecGeom-based volume IDs. 0042 * 0043 * The default Geant4 "tolerance" (often used as surface "thickness") is 1e-9 0044 * mm, and the relative tolerance when specifying a length scale is 1e-11 (so 0045 * the default macro length scale is expected to be 100 mm = 10 cm). 0046 * That relative tolerance is *much* too small for any quadric operations or 0047 * angular rotations to be differentiated, so for now we'll stick with the 0048 * ORANGE default tolerance of 1e-8 relative, and we assume a 1mm length scale. 0049 */ 0050 class Converter 0051 { 0052 public: 0053 //!@{ 0054 //! \name Type aliases 0055 using arg_type = GeantGeoParams const&; 0056 using MapLvVolId = std::unordered_map<G4LogicalVolume const*, VolumeId>; 0057 //!@} 0058 0059 //! Input options for the conversion 0060 struct Options 0061 { 0062 //! Write output about volumes being converted 0063 bool verbose{false}; 0064 //! Manually specify a tracking/construction tolerance 0065 Tolerance<> tol; 0066 //! Write interpreted geometry to a JSON file 0067 std::string proto_output_file; 0068 //! Write intermediate debug output (CSG construction) to a JSON file 0069 std::string debug_output_file; 0070 }; 0071 0072 struct result_type 0073 { 0074 OrangeInput input; 0075 MapLvVolId volumes; //! TODO 0076 }; 0077 0078 public: 0079 // Construct with options 0080 explicit Converter(Options&&); 0081 0082 //! Construct with default options 0083 Converter() : Converter{Options{}} {} 0084 0085 // Convert the world 0086 result_type operator()(arg_type); 0087 0088 private: 0089 Options opts_; 0090 }; 0091 0092 //---------------------------------------------------------------------------// 0093 0094 #if !(CELERITAS_USE_GEANT4 \ 0095 && CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE) 0096 inline Converter::Converter(Options&&) 0097 { 0098 CELER_DISCARD(opts_); 0099 } 0100 0101 inline auto Converter::operator()(arg_type) -> result_type 0102 { 0103 CELER_NOT_CONFIGURED("Geant4 with double-precision real_type"); 0104 } 0105 #endif 0106 0107 //---------------------------------------------------------------------------// 0108 } // namespace g4org 0109 } // 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 |
|