cesium-native 0.43.0
Loading...
Searching...
No Matches
Availability.h
1#pragma once
2
3#include "Library.h"
4
5#include <cstdint>
6#include <memory>
7#include <optional>
8#include <span>
9#include <utility>
10#include <variant>
11#include <vector>
12
13namespace CesiumGeometry {
14
15namespace AvailabilityUtilities {
16uint8_t countOnesInByte(uint8_t _byte);
17uint32_t countOnesInBuffer(std::span<const std::byte> buffer);
18} // namespace AvailabilityUtilities
19
23struct CESIUMGEOMETRY_API ConstantAvailability {
28};
29
34struct CESIUMGEOMETRY_API SubtreeBufferView {
38 uint32_t byteOffset;
42 uint32_t byteLength;
47 uint8_t buffer;
48};
49
59typedef std::variant<ConstantAvailability, SubtreeBufferView> AvailabilityView;
60
87
92struct CESIUMGEOMETRY_API AvailabilityNode {
99 std::optional<AvailabilitySubtree> subtree;
100
104 std::vector<std::unique_ptr<AvailabilityNode>> childNodes;
105
110
118 void setLoadedSubtree(
119 AvailabilitySubtree&& subtree_,
120 uint32_t maxChildrenSubtrees) noexcept;
121};
122
126struct CESIUMGEOMETRY_API AvailabilityTree {
130 std::unique_ptr<AvailabilityNode> pRoot;
131};
132
137class CESIUMGEOMETRY_API AvailabilityAccessor {
138public:
146 const AvailabilityView& view,
147 const AvailabilitySubtree& subtree) noexcept;
148
156 bool isBufferView() const noexcept {
157 return pBufferView != nullptr && bufferAccessor;
158 }
159
167 bool isConstant() const noexcept { return pConstant != nullptr; }
168
175 bool getConstant() const { return pConstant->constant; }
176
184 const std::span<const std::byte>& getBufferAccessor() const {
185 return *bufferAccessor;
186 }
187
195 const std::byte& operator[](size_t i) const {
196 return bufferAccessor.value()[i];
197 }
198
206 size_t size() const { return pBufferView->byteLength; }
207
208private:
209 const SubtreeBufferView* pBufferView;
210 const ConstantAvailability* pConstant;
211 std::optional<std::span<const std::byte>> bufferAccessor;
212};
213} // namespace CesiumGeometry
Accessor for use with AvailabilityView in order to safely obtain the contents of the view.
const std::span< const std::byte > & getBufferAccessor() const
Obtains an accessor to the buffer used by the AvailabilityView.
size_t size() const
Obtains the size of the buffer used by the AvailabilityView.
bool isBufferView() const noexcept
Is this AvailabilityAccessor accessing a SubtreeBufferView?
const std::byte & operator[](size_t i) const
Obtains the byte at the given index from the buffer used by the AvailabilityView.
AvailabilityAccessor(const AvailabilityView &view, const AvailabilitySubtree &subtree) noexcept
Creates a new AvailabilityAccessor.
bool getConstant() const
Obtains the constant value of the AvailabilityView.
bool isConstant() const noexcept
Is this AvailabilityAccessor accessing a ConstantAvailability?
Basic geometry classes for Cesium.
std::variant< ConstantAvailability, SubtreeBufferView > AvailabilityView
A view into availability information for part of the availability tree. This could be either a consta...
Availability nodes wrap AvailabilitySubtree objects and link them together to form a downwardly trave...
AvailabilityNode() noexcept
Creates an empty instance;.
std::optional< AvailabilitySubtree > subtree
The subtree data for this node.
std::vector< std::unique_ptr< AvailabilityNode > > childNodes
The child nodes for this subtree node.
The subtree data for an AvailabilityNode, containing information on tile, content,...
AvailabilityView contentAvailability
The availability information corresponding to TileAvailabilityFlags::CONTENT_AVAILABLE.
std::vector< std::vector< std::byte > > buffers
Subtree buffers that may be referenced by a SubtreeBufferView.
AvailabilityView subtreeAvailability
The availability information corresponding to TileAvailabilityFlags::SUBTREE_AVAILABLE and TileAvaila...
AvailabilityView tileAvailability
The availability information corresponding to TileAvailabilityFlags::TILE_AVAILABLE.
A downwardly-traversable tree of AvailabilityNode objects.
std::unique_ptr< AvailabilityNode > pRoot
The root AvailabilityNode of this tree.
An availability value that is a constant boolean value.
bool constant
The constant value.
An availability value that needs to be obtained using an offset into a buffer.
uint32_t byteLength
The number of bytes after the offset to read until.
uint8_t buffer
The index into AvailabilitySubtree::buffers that this SubtreeBufferView corresponds to.
uint32_t byteOffset
The offset into the buffer to read from.