File indexing completed on 2025-09-15 09:06:12
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "../OrangeData.hh"
0010
0011 namespace celeritas
0012 {
0013 namespace detail
0014 {
0015
0016
0017
0018
0019
0020
0021 class BIHView
0022 {
0023 public:
0024
0025
0026 using Storage = NativeCRef<BIHTreeData>;
0027
0028
0029
0030 inline CELER_FUNCTION BIHView(BIHTree const& tree, Storage const& storage);
0031
0032
0033 inline CELER_FUNCTION bool is_inner(BIHNodeId id) const;
0034
0035
0036 inline CELER_FUNCTION BIHInnerNode const& inner_node(BIHNodeId id) const;
0037
0038
0039 inline CELER_FUNCTION BIHLeafNode const& leaf_node(BIHNodeId id) const;
0040
0041
0042 inline CELER_FUNCTION FastBBox const& bbox(LocalVolumeId vol_id) const;
0043
0044
0045 inline CELER_FUNCTION Span<LocalVolumeId const>
0046 leaf_vol_ids(BIHLeafNode const& leaf) const;
0047
0048
0049 inline CELER_FUNCTION Span<LocalVolumeId const> inf_vol_ids() const;
0050
0051 private:
0052
0053 BIHTree const& tree_;
0054 Storage const& storage_;
0055 };
0056
0057
0058
0059
0060
0061
0062
0063 CELER_FUNCTION
0064 BIHView::BIHView(BIHTree const& tree, BIHView::Storage const& storage)
0065 : tree_(tree), storage_(storage)
0066 {
0067 CELER_EXPECT(tree);
0068 }
0069
0070
0071
0072
0073
0074 CELER_FUNCTION
0075 bool BIHView::is_inner(BIHNodeId id) const
0076 {
0077 return id.unchecked_get() < tree_.inner_nodes.size();
0078 }
0079
0080
0081
0082
0083
0084 CELER_FUNCTION
0085 BIHInnerNode const& BIHView::inner_node(BIHNodeId id) const
0086 {
0087 CELER_EXPECT(this->is_inner(id));
0088 return storage_.inner_nodes[tree_.inner_nodes[id.unchecked_get()]];
0089 }
0090
0091
0092
0093
0094
0095 CELER_FUNCTION
0096 BIHLeafNode const& BIHView::leaf_node(BIHNodeId id) const
0097 {
0098 CELER_EXPECT(!this->is_inner(id));
0099 return storage_.leaf_nodes[tree_.leaf_nodes[id.unchecked_get()
0100 - tree_.inner_nodes.size()]];
0101 }
0102
0103
0104
0105
0106
0107 CELER_FUNCTION FastBBox const& BIHView::bbox(LocalVolumeId vol_id) const
0108 {
0109 CELER_EXPECT(vol_id.unchecked_get() < tree_.bboxes.size());
0110 return storage_.bboxes[tree_.bboxes[vol_id]];
0111 }
0112
0113
0114
0115
0116
0117 CELER_FUNCTION Span<LocalVolumeId const>
0118 BIHView::leaf_vol_ids(BIHLeafNode const& leaf) const
0119 {
0120 return storage_.local_volume_ids[leaf.vol_ids];
0121 }
0122
0123
0124
0125
0126
0127 CELER_FUNCTION Span<LocalVolumeId const> BIHView::inf_vol_ids() const
0128 {
0129 return storage_.local_volume_ids[tree_.inf_vol_ids];
0130 }
0131
0132
0133 }
0134 }