Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:06:12

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/detail/DepthCalculator.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <unordered_map>
0010 #include <vector>
0011 
0012 #include "corecel/cont/VariantUtils.hh"
0013 
0014 #include "../OrangeInput.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace detail
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Calculate the maximum number of levels deep in a geometry.
0023  */
0024 class DepthCalculator
0025 {
0026   public:
0027     //!@{
0028     //! \name Type aliases
0029     using VecVarUniv = std::vector<VariantUniverseInput>;
0030     //!@}
0031 
0032   public:
0033     // Construct with a reference to all universe inputs
0034     explicit DepthCalculator(VecVarUniv const&);
0035 
0036     // Calculate the depth of the global unit
0037     size_type operator()();
0038 
0039     // Calculate the depth of a unit
0040     size_type operator()(UnitInput const& u);
0041 
0042     // Calculate the depth of a rect array
0043     size_type operator()(RectArrayInput const& u);
0044 
0045   private:
0046     ContainerVisitor<VecVarUniv const&> visit_univ_;
0047     std::size_t num_univ_{0};
0048     std::unordered_map<UniverseId, size_type> depths_;
0049 
0050     // Check cache or calculate
0051     size_type operator()(UniverseId univ_id);
0052 };
0053 
0054 //---------------------------------------------------------------------------//
0055 }  // namespace detail
0056 }  // namespace celeritas