![]() |
|
|||
File indexing completed on 2025-09-18 09:24:51
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/surf/detail/RecursiveSimplifierImpl.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <variant> 0010 0011 #include "corecel/Macros.hh" 0012 #include "orange/OrangeTypes.hh" 0013 0014 #include "../SurfaceSimplifier.hh" 0015 0016 namespace celeritas 0017 { 0018 namespace detail 0019 { 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Recursively simplify, then call the given function on the final surface. 0023 * 0024 * This implementation class allows std::visit to be used with the surface 0025 * while retaining updates to the associated Sense that the user requested. 0026 */ 0027 template<class F> 0028 class RecursiveSimplifierImpl 0029 { 0030 public: 0031 //! Construct with reference to function and values to be used 0032 RecursiveSimplifierImpl(F& func, Sense sense, real_type abs_tol) 0033 : func_{func}, sense_{sense}, simplify_{&sense_, abs_tol} 0034 { 0035 } 0036 0037 //! Invoke recursively with a specific surface type 0038 template<class S> 0039 void operator()(S const& surf) 0040 { 0041 auto result = simplify_(surf); 0042 CELER_ASSUME(!result.valueless_by_exception()); 0043 if (std::holds_alternative<std::monostate>(result)) 0044 { 0045 // Could not simplify further: call back with sense and surface 0046 return func_(sense_, surf); 0047 } 0048 else 0049 { 0050 return std::visit(*this, result); 0051 } 0052 } 0053 0054 //! Monostate should never be reached 0055 void operator()(std::monostate) { CELER_ASSERT_UNREACHABLE(); } 0056 0057 private: 0058 F& func_; 0059 Sense sense_; 0060 SurfaceSimplifier simplify_; 0061 }; 0062 0063 //---------------------------------------------------------------------------// 0064 } // namespace detail 0065 } // 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 |
![]() ![]() |