|
|
|||
File indexing completed on 2026-10-29 09:13:54
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 geocel/VolumeView.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Assert.hh" 0010 #include "corecel/Macros.hh" 0011 #include "corecel/Types.hh" 0012 #include "corecel/cont/LdgSpan.hh" 0013 #include "geocel/Types.hh" 0014 0015 #include "VolumeData.hh" 0016 0017 namespace celeritas 0018 { 0019 //---------------------------------------------------------------------------// 0020 /*! 0021 * Access material and connectivity for a single logical volume. 0022 * 0023 * This GPU-compatible view provides per-volume access to the geometry 0024 * material ID and parent/child edges in the volume instance graph. 0025 * 0026 * \par Example: 0027 * \code 0028 VolumeView view{params.host_ref(), vol_id}; 0029 GeoMatId mat = view.material(); 0030 for (VolumeInstanceId vi : view.children()) { ... } 0031 * \endcode 0032 */ 0033 class VolumeView 0034 { 0035 public: 0036 //!@{ 0037 //! \name Type aliases 0038 using ParamsRef = NativeCRef<VolumeParamsData>; 0039 using SpanVolInst = LdgSpan<VolumeInstanceId const>; 0040 //!@} 0041 0042 public: 0043 // Construct with shared data and a volume ID 0044 explicit inline CELER_FUNCTION VolumeView(ParamsRef const& params, 0045 VolumeId vol_id); 0046 0047 //! Volume being viewed 0048 CELER_FUNCTION VolumeId volume_id() const { return vol_id_; } 0049 0050 // Get the geometry material ID for this volume 0051 inline CELER_FUNCTION GeoMatId material() const; 0052 0053 // Get the incoming edges (volume instances that place this volume) 0054 inline CELER_FUNCTION SpanVolInst parents() const; 0055 0056 // Get the outgoing edges (child instances placed inside this volume) 0057 inline CELER_FUNCTION SpanVolInst children() const; 0058 0059 private: 0060 ParamsRef const& params_; 0061 VolumeId vol_id_; 0062 0063 inline CELER_FUNCTION VolumeRecord const& record() const; 0064 }; 0065 0066 //---------------------------------------------------------------------------// 0067 // INLINE DEFINITIONS 0068 //---------------------------------------------------------------------------// 0069 /*! 0070 * Construct with shared data and a volume ID. 0071 */ 0072 CELER_FUNCTION VolumeView::VolumeView(ParamsRef const& params, VolumeId vol_id) 0073 : params_(params), vol_id_(vol_id) 0074 { 0075 CELER_EXPECT(vol_id_ < params_.volumes.size()); 0076 } 0077 0078 //---------------------------------------------------------------------------// 0079 /*! 0080 * Get the geometry material ID for this volume. 0081 */ 0082 CELER_FUNCTION GeoMatId VolumeView::material() const 0083 { 0084 return this->record().material; 0085 } 0086 0087 //---------------------------------------------------------------------------// 0088 /*! 0089 * Get the incoming edges (volume instances that place this volume). 0090 */ 0091 CELER_FUNCTION auto VolumeView::parents() const -> SpanVolInst 0092 { 0093 return params_.vi_storage[this->record().parents]; 0094 } 0095 0096 //---------------------------------------------------------------------------// 0097 /*! 0098 * Get the outgoing edges (child instances placed inside this volume). 0099 */ 0100 CELER_FUNCTION auto VolumeView::children() const -> SpanVolInst 0101 { 0102 return params_.vi_storage[this->record().children]; 0103 } 0104 0105 //---------------------------------------------------------------------------// 0106 CELER_FORCEINLINE_FUNCTION VolumeRecord const& VolumeView::record() const 0107 { 0108 return params_.volumes[vol_id_]; 0109 } 0110 0111 //---------------------------------------------------------------------------// 0112 } // 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 |
|