![]() |
|
|||
File indexing completed on 2025-07-15 08:57:14
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file geocel/GeoParamsInterface.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/Macros.hh" 0011 #include "corecel/cont/Span.hh" // IWYU pragma: export 0012 #include "corecel/io/Label.hh" // IWYU pragma: export 0013 0014 #include "BoundingBox.hh" // IWYU pragma: export 0015 #include "Types.hh" 0016 0017 class G4LogicalVolume; 0018 0019 namespace celeritas 0020 { 0021 //---------------------------------------------------------------------------// 0022 /*! 0023 * Interface class for accessing host geometry metadata. 0024 * 0025 * This class is implemented by \c OrangeParams to allow navigation with the 0026 * ORANGE geometry implementation, \c VecgeomParams for using VecGeom, and \c 0027 * GeantGeoParams for testing with the Geant4-provided navigator. 0028 */ 0029 class GeoParamsInterface 0030 { 0031 public: 0032 //!@{ 0033 //! \name Type aliases 0034 using SpanConstVolumeId = Span<VolumeId const>; 0035 //!@} 0036 0037 public: 0038 //! Whether safety distance calculations are accurate and precise 0039 virtual bool supports_safety() const = 0; 0040 0041 //! Outer bounding box of geometry 0042 virtual BBox const& bbox() const = 0; 0043 0044 //// VOLUMES //// 0045 0046 //! Number of volumes 0047 virtual VolumeId::size_type num_volumes() const = 0; 0048 0049 //! Get the label for a placed volume ID 0050 virtual Label const& id_to_label(VolumeId vol_id) const = 0; 0051 0052 //! Get the volume ID corresponding to a unique name 0053 virtual VolumeId find_volume(std::string const& name) const = 0; 0054 0055 //! Get the volume ID corresponding to a unique label 0056 virtual VolumeId find_volume(Label const& label) const = 0; 0057 0058 //! Get the volume ID corresponding to a Geant4 logical volume 0059 virtual VolumeId find_volume(G4LogicalVolume const* volume) const = 0; 0060 0061 //! Get zero or more volume IDs corresponding to a name 0062 virtual SpanConstVolumeId find_volumes(std::string const& name) const = 0; 0063 0064 //// HELPER FUNCTIONS //// 0065 0066 // Get the volume ID corresponding to a unique name 0067 inline VolumeId find_volume(char const* name) const; 0068 0069 protected: 0070 // Protected destructor prevents deletion of pointer-to-interface 0071 ~GeoParamsInterface() = default; 0072 0073 GeoParamsInterface() = default; 0074 CELER_DEFAULT_COPY_MOVE(GeoParamsInterface); 0075 }; 0076 0077 //---------------------------------------------------------------------------// 0078 /*! 0079 * Interface class for a host geometry that supports surfaces. 0080 */ 0081 class GeoParamsSurfaceInterface : public GeoParamsInterface 0082 { 0083 public: 0084 using GeoParamsInterface::id_to_label; 0085 0086 //! Get the label for a placed volume ID 0087 virtual Label const& id_to_label(SurfaceId surf_id) const = 0; 0088 0089 //! Get the surface ID corresponding to a unique label name 0090 virtual SurfaceId find_surface(std::string const& name) const = 0; 0091 0092 //! Number of distinct surfaces 0093 virtual SurfaceId::size_type num_surfaces() const = 0; 0094 }; 0095 0096 //---------------------------------------------------------------------------// 0097 // INLINE DEFINITIONS 0098 //---------------------------------------------------------------------------// 0099 /*! 0100 * Find the unique volume corresponding to a unique name. 0101 * 0102 * This method is here to disambiguate the implicit std::string and Label 0103 * constructors. 0104 */ 0105 VolumeId GeoParamsInterface::find_volume(char const* name) const 0106 { 0107 return this->find_volume(std::string{name}); 0108 } 0109 0110 //---------------------------------------------------------------------------// 0111 } // 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 |
![]() ![]() |