|
||||
File indexing completed on 2025-01-18 10:05:55
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-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/CsgUnit.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <map> 0011 #include <set> 0012 #include <variant> 0013 #include <vector> 0014 0015 #include "corecel/io/Label.hh" 0016 #include "geocel/BoundingBox.hh" 0017 #include "orange/OrangeTypes.hh" 0018 #include "orange/surf/VariantSurface.hh" 0019 #include "orange/transform/VariantTransform.hh" 0020 0021 #include "BoundingZone.hh" 0022 #include "../CsgTree.hh" 0023 #include "../CsgTypes.hh" 0024 0025 namespace celeritas 0026 { 0027 namespace orangeinp 0028 { 0029 namespace detail 0030 { 0031 //---------------------------------------------------------------------------// 0032 /*! 0033 * Constructed CSG geometry data for a unit. 0034 * 0035 * This contains all the construction-time surfaces, volumes, and properties. 0036 * These are stored in a way so that they can be remapped and/or optimized 0037 * further before committing them to the constructed GPU data. 0038 * 0039 * All bounding boxes and transforms are "local" within the CSG unit's 0040 * reference frame, not relative to any other CSG node nor to any parent 0041 * universe. (TODO: add bounds and transforms only for finite regions) 0042 * 0043 * TODO (?) map nodes to set of object pointers, for detailed provenance? 0044 */ 0045 struct CsgUnit 0046 { 0047 //// TYPES //// 0048 0049 using Metadata = Label; 0050 using SetMd = std::set<Metadata>; 0051 using Fill = std::variant<std::monostate, GeoMaterialId, Daughter>; 0052 0053 //! Attributes about a closed volume of space 0054 struct Region 0055 { 0056 BoundingZone bounds; //!< Interior/exterior bbox 0057 TransformId transform_id; //!< Region-to-unit transform 0058 }; 0059 0060 //// DATA //// 0061 0062 //!@{ 0063 //! \name Surfaces 0064 //! Vectors are indexed by LocalSurfaceId. 0065 std::vector<VariantSurface> surfaces; 0066 //!@} 0067 0068 //!@{ 0069 //! \name Nodes 0070 //! Vectors are indexed by NodeId. 0071 CsgTree tree; //!< CSG tree 0072 std::vector<SetMd> metadata; //!< CSG node labels 0073 std::map<NodeId, Region> regions; //!< Bounds and transforms 0074 //!@} 0075 0076 //!@{ 0077 //! \name Volumes 0078 //! Vector is indexed by LocalVolumeId. 0079 std::vector<Fill> fills; //!< Content of each volume 0080 GeoMaterialId background; //!< Optional background fill 0081 //!@} 0082 0083 //!@{ 0084 //! \name Transforms 0085 //! Vectors are indexed by TransformId. 0086 std::vector<VariantTransform> transforms; 0087 //!@} 0088 0089 //// FUNCTIONS //// 0090 0091 // Whether the processed unit is valid for use 0092 explicit inline operator bool() const; 0093 0094 // Whether the unit has no constructed data 0095 inline bool empty() const; 0096 }; 0097 0098 //---------------------------------------------------------------------------// 0099 /*! 0100 * Utility for telling whether a fill is assigned. 0101 */ 0102 inline constexpr bool is_filled(CsgUnit::Fill const& fill) 0103 { 0104 return !std::holds_alternative<std::monostate>(fill); 0105 } 0106 0107 //---------------------------------------------------------------------------// 0108 // INLINE DEFINITIONS 0109 //---------------------------------------------------------------------------// 0110 /*! 0111 * Whether the processed unit is valid for use. 0112 */ 0113 CsgUnit::operator bool() const 0114 { 0115 return this->metadata.size() == this->tree.size() 0116 && !this->tree.volumes().empty() 0117 && this->tree.volumes().size() == this->fills.size(); 0118 ; 0119 } 0120 0121 //---------------------------------------------------------------------------// 0122 /*! 0123 * True if the unit has no constructed data. 0124 */ 0125 bool CsgUnit::empty() const 0126 { 0127 return this->surfaces.empty() && this->metadata.empty() 0128 && this->regions.empty() && this->tree.volumes().empty() 0129 && this->fills.empty() && this->transforms.empty(); 0130 } 0131 0132 //---------------------------------------------------------------------------// 0133 } // namespace detail 0134 } // namespace orangeinp 0135 } // 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 |