|
||||
File indexing completed on 2025-01-18 10:05:55
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 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 orange/orangeinp/detail/SenseEvaluator.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/cont/VariantUtils.hh" 0011 #include "orange/OrangeTypes.hh" 0012 #include "orange/surf/VariantSurface.hh" 0013 0014 #include "../CsgTree.hh" 0015 0016 namespace celeritas 0017 { 0018 namespace orangeinp 0019 { 0020 namespace detail 0021 { 0022 //---------------------------------------------------------------------------// 0023 /*! 0024 * Evaluate whether a point is inside a CSG tree node. 0025 * 0026 * This is a construction-time helper that combines \c SenseCalculator with \c 0027 * LogicEvaluator. Its intended use is primarily for testing. 0028 */ 0029 class SenseEvaluator 0030 { 0031 public: 0032 //!@{ 0033 //! \name Type aliases 0034 using result_type = SignedSense; 0035 using VecSurface = std::vector<VariantSurface>; 0036 //!@} 0037 0038 public: 0039 // Construct with a CSG tree, surfaces, and a point 0040 inline SenseEvaluator(CsgTree const& tree, 0041 VecSurface const& surfaces, 0042 Real3 const& pos); 0043 0044 //! Visit from a node ID 0045 result_type operator()(NodeId const& n) const; 0046 0047 //!@{ 0048 //! \name Visit a node directly 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 |