|
|
|||
File indexing completed on 2026-11-09 10:29:09
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/VolumeBuilder.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Config.hh" 0010 0011 #include "corecel/cont/InitializedValue.hh" 0012 #include "corecel/io/Label.hh" 0013 #include "orange/transform/VariantTransform.hh" 0014 0015 #include "../CsgTypes.hh" 0016 0017 namespace celeritas 0018 { 0019 namespace orangeinp 0020 { 0021 namespace detail 0022 { 0023 //---------------------------------------------------------------------------// 0024 class CsgUnitBuilder; 0025 struct BoundingZone; 0026 0027 //---------------------------------------------------------------------------// 0028 /*! 0029 * Construct volumes out of objects. 0030 * 0031 * This class maintains a stack of transforms used by nested objects. It 0032 * ultimately returns a node ID corresponding to the CSG node (and bounding box 0033 * etc.) of the constructed object. 0034 * 0035 * To add a transform, store the result of \c make_scoped_transform within a 0036 * scoping block (generally the calling function). The resulting RAII class 0037 * prevents an imbalance from manual calls to "push" and "pop". For an example 0038 * usage, see \c celeritas::orangeinp::Transformed::build . 0039 */ 0040 class VolumeBuilder 0041 { 0042 public: 0043 //!@{ 0044 //! \name Type aliases 0045 using Metadata = Label; 0046 using Tol = Tolerance<>; 0047 //!@} 0048 0049 private: 0050 // Private types and type aliases 0051 struct VBTransformPopper; 0052 using ScopedTransform = InitializedValue<VolumeBuilder*, VBTransformPopper>; 0053 0054 public: 0055 // Construct with unit builder (and volume name??) 0056 explicit VolumeBuilder(CsgUnitBuilder* ub); 0057 0058 //// ACCESSORS //// 0059 0060 // Get the construction tolerance 0061 Tol const& tol() const; 0062 0063 //!@{ 0064 //! Access the unit builder for construction 0065 CsgUnitBuilder const& unit_builder() const { return *ub_; } 0066 CsgUnitBuilder& unit_builder() { return *ub_; } 0067 //!@} 0068 0069 // Access the local-to-global transform during construction 0070 VariantTransform const& local_transform() const; 0071 0072 //// MUTATORS //// 0073 0074 // Add a region to the CSG tree, automatically calculating bounding zone 0075 NodeId insert_region(Metadata&& md, Joined&& j); 0076 0077 // Add a region to the CSG tree, including a better bounding zone 0078 NodeId insert_region(Metadata&& md, Joined&& j, BoundingZone&& bz); 0079 0080 // Add a negated region to the CSG tree 0081 NodeId insert_region(Metadata&& md, Negated&& n); 0082 0083 // Apply a transform within this scope 0084 [[nodiscard]] ScopedTransform make_scoped_transform( 0085 VariantTransform const& t); 0086 0087 private: 0088 //// DATA //// 0089 0090 CsgUnitBuilder* ub_; 0091 std::vector<TransformId> transforms_; 0092 0093 //// PRIVATE METHODS //// 0094 0095 // Add a new variant transform 0096 void push_transform(VariantTransform&& vt); 0097 0098 // Pop the last transform, used only by PopVBTransformOnDestruct 0099 void pop_transform() noexcept(!CELERITAS_DEBUG); 0100 }; 0101 0102 //---------------------------------------------------------------------------// 0103 //! Finalizer for ScopedTransform 0104 struct VolumeBuilder::VBTransformPopper 0105 { 0106 inline void operator()(VolumeBuilder* vb) noexcept(!CELERITAS_DEBUG) 0107 { 0108 CELER_EXPECT(vb); 0109 vb->pop_transform(); 0110 } 0111 }; 0112 0113 //---------------------------------------------------------------------------// 0114 } // namespace detail 0115 } // namespace orangeinp 0116 } // 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 |
|