|
|
|||
File indexing completed on 2025-12-16 10:23:49
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/orangeinp/detail/SenseEvaluator.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/cont/VariantUtils.hh" 0010 #include "orange/OrangeTypes.hh" 0011 #include "orange/surf/VariantSurface.hh" 0012 0013 #include "../CsgTree.hh" 0014 0015 namespace celeritas 0016 { 0017 namespace orangeinp 0018 { 0019 namespace detail 0020 { 0021 //---------------------------------------------------------------------------// 0022 /*! 0023 * Evaluate whether a point is inside a CSG tree node. 0024 * 0025 * This is a construction-time helper that combines \c SenseCalculator with \c 0026 * LogicEvaluator. Its intended use is primarily for testing. 0027 */ 0028 class SenseEvaluator 0029 { 0030 public: 0031 //!@{ 0032 //! \name Type aliases 0033 using result_type = SignedSense; 0034 using VecSurface = std::vector<VariantSurface>; 0035 //!@} 0036 0037 public: 0038 // Construct with a CSG tree, surfaces, and a point 0039 inline SenseEvaluator(CsgTree const& tree, 0040 VecSurface const& surfaces, 0041 Real3 const& pos); 0042 0043 //! Visit from a node ID 0044 result_type operator()(NodeId const& n) const; 0045 0046 //!@{ 0047 //! \name Visit a node directly 0048 0049 //! Point is always inside 0050 result_type operator()(True const&) const { return SignedSense::inside; } 0051 //! Point is always outside 0052 result_type operator()(False const&) const { return SignedSense::outside; } 0053 // Evaluate a surface 0054 result_type operator()(Surface const&) const; 0055 // Redirect an alias 0056 result_type operator()(Aliased const&) const; 0057 // Negate the daughter result 0058 result_type operator()(Negated const&) const; 0059 // Visit daughter nodes using short circuit logic 0060 result_type operator()(Joined const&) const; 0061 //!@} 0062 0063 private: 0064 ContainerVisitor<CsgTree const&, NodeId> visit_node_; 0065 VecSurface const& surfaces_; 0066 Real3 pos_; 0067 }; 0068 0069 //---------------------------------------------------------------------------// 0070 // INLINE DEFINITIONS 0071 //---------------------------------------------------------------------------// 0072 /*! 0073 * Construct with a CSG tree and the position to test. 0074 */ 0075 SenseEvaluator::SenseEvaluator(CsgTree const& tree, 0076 VecSurface const& surfaces, 0077 Real3 const& pos) 0078 : visit_node_{tree}, surfaces_{surfaces}, pos_{pos} 0079 { 0080 } 0081 0082 //---------------------------------------------------------------------------// 0083 } // namespace detail 0084 } // namespace orangeinp 0085 } // 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 |
|