cesium-native 0.44.2
Loading...
Searching...
No Matches
Tile.h
1#pragma once
2
3#include <Cesium3DTilesSelection/BoundingVolume.h>
4#include <Cesium3DTilesSelection/Library.h>
5#include <Cesium3DTilesSelection/RasterMappedTo3DTile.h>
6#include <Cesium3DTilesSelection/TileContent.h>
7#include <Cesium3DTilesSelection/TileID.h>
8#include <Cesium3DTilesSelection/TileRefine.h>
9#include <Cesium3DTilesSelection/TileSelectionState.h>
10#include <CesiumUtility/DoublyLinkedList.h>
11
12#include <glm/common.hpp>
13
14#include <atomic>
15#include <limits>
16#include <memory>
17#include <optional>
18#include <span>
19#include <string>
20#include <vector>
21
22namespace Cesium3DTilesSelection {
23class TilesetContentLoader;
24
28enum class TileLoadState {
33 Unloading = -2,
34
40
45 Unloaded = 0,
46
55
59 ContentLoaded = 2,
60
64 Done = 3,
65
70 Failed = 4,
71};
72
96class CESIUM3DTILESSELECTION_API Tile final {
97public:
105 explicit Tile(TilesetContentLoader* pLoader) noexcept;
106
116 TilesetContentLoader* pLoader,
117 std::unique_ptr<TileExternalContent>&& externalContent) noexcept;
118
127 Tile(TilesetContentLoader* pLoader, TileEmptyContent emptyContent) noexcept;
128
133 ~Tile() noexcept = default;
134
140 Tile(const Tile& rhs) = delete;
141
147 Tile(Tile&& rhs) noexcept;
148
154 Tile& operator=(const Tile& rhs) = delete;
155
161 Tile& operator=(Tile&& rhs) noexcept;
162
170 Tile* getParent() noexcept { return this->_pParent; }
171
173 const Tile* getParent() const noexcept { return this->_pParent; }
174
182 std::span<Tile> getChildren() noexcept {
183 return std::span<Tile>(this->_children);
184 }
185
187 std::span<const Tile> getChildren() const noexcept {
188 return std::span<const Tile>(this->_children);
189 }
190
199 void createChildTiles(std::vector<Tile>&& children);
200
211 const BoundingVolume& getBoundingVolume() const noexcept {
212 return this->_boundingVolume;
213 }
214
222 void setBoundingVolume(const BoundingVolume& value) noexcept {
223 this->_boundingVolume = value;
224 }
225
237 const std::optional<BoundingVolume>& getViewerRequestVolume() const noexcept {
238 return this->_viewerRequestVolume;
239 }
240
248 void
249 setViewerRequestVolume(const std::optional<BoundingVolume>& value) noexcept {
250 this->_viewerRequestVolume = value;
251 }
252
262 double getGeometricError() const noexcept { return this->_geometricError; }
263
271 void setGeometricError(double value) noexcept {
272 this->_geometricError = value;
273 }
274
289 double getNonZeroGeometricError() const noexcept;
290
301 bool getUnconditionallyRefine() const noexcept {
302 return glm::isinf(this->_geometricError);
303 }
304
310 void setUnconditionallyRefine() noexcept {
311 this->_geometricError = std::numeric_limits<double>::infinity();
312 }
313
325 TileRefine getRefine() const noexcept { return this->_refine; }
326
334 void setRefine(TileRefine value) noexcept { this->_refine = value; }
335
344 const glm::dmat4x4& getTransform() const noexcept { return this->_transform; }
345
353 void setTransform(const glm::dmat4x4& value) noexcept {
354 this->_transform = value;
355 }
356
364 const TileID& getTileID() const noexcept { return this->_id; }
365
373 void setTileID(const TileID& id) noexcept { this->_id = id; }
374
386 const std::optional<BoundingVolume>&
387 getContentBoundingVolume() const noexcept {
388 return this->_contentBoundingVolume;
389 }
390
400 const std::optional<BoundingVolume>& value) noexcept {
401 this->_contentBoundingVolume = value;
402 }
403
412 return this->_lastSelectionState;
413 }
414
417 return this->_lastSelectionState;
418 }
419
427 void setLastSelectionState(const TileSelectionState& newState) noexcept {
428 this->_lastSelectionState = newState;
429 }
430
435 int64_t computeByteSize() const noexcept;
436
440 std::vector<RasterMappedTo3DTile>& getMappedRasterTiles() noexcept {
441 return this->_rasterTiles;
442 }
443
445 const std::vector<RasterMappedTo3DTile>&
446 getMappedRasterTiles() const noexcept {
447 return this->_rasterTiles;
448 }
449
453 const TileContent& getContent() const noexcept { return _content; }
454
456 TileContent& getContent() noexcept { return _content; }
457
461 bool isRenderable() const noexcept;
462
466 bool isRenderContent() const noexcept;
467
471 bool isExternalContent() const noexcept;
472
476 bool isEmptyContent() const noexcept;
477
481 TilesetContentLoader* getLoader() const noexcept;
482
486 TileLoadState getState() const noexcept;
487
488private:
489 struct TileConstructorImpl {};
490 template <
491 typename... TileContentArgs,
492 typename TileContentEnable = std::enable_if_t<
493 std::is_constructible_v<TileContent, TileContentArgs&&...>,
494 int>>
495 Tile(
496 TileConstructorImpl tag,
497 TileLoadState loadState,
498 TilesetContentLoader* pLoader,
499 TileContentArgs&&... args);
500
501 void setParent(Tile* pParent) noexcept;
502
503 void setState(TileLoadState state) noexcept;
504
520 bool getMightHaveLatentChildren() const noexcept;
521
522 void setMightHaveLatentChildren(bool mightHaveLatentChildren) noexcept;
523
524 // Position in bounding-volume hierarchy.
525 Tile* _pParent;
526 std::vector<Tile> _children;
527
528 // Properties from tileset.json.
529 // These are immutable after the tile leaves TileState::Unloaded.
530 TileID _id;
531 BoundingVolume _boundingVolume;
532 std::optional<BoundingVolume> _viewerRequestVolume;
533 std::optional<BoundingVolume> _contentBoundingVolume;
534 double _geometricError;
535 TileRefine _refine;
536 glm::dmat4x4 _transform;
537
538 // Selection state
539 TileSelectionState _lastSelectionState;
540
541 // tile content
542 CesiumUtility::DoublyLinkedListPointers<Tile> _loadedTilesLinks;
543 TileContent _content;
544 TilesetContentLoader* _pLoader;
545 TileLoadState _loadState;
546 bool _mightHaveLatentChildren;
547
548 // mapped raster overlay
549 std::vector<RasterMappedTo3DTile> _rasterTiles;
550
551 friend class TilesetContentManager;
552 friend class MockTilesetContentManagerTestFixture;
553
554public:
558 typedef CesiumUtility::DoublyLinkedList<Tile, &Tile::_loadedTilesLinks>
560};
561
562} // namespace Cesium3DTilesSelection
The result of applying a CesiumRasterOverlays::RasterOverlayTile to geometry.
A tile content container that can store and query the content type that is currently being owned by t...
A description of the state of a Tile during the rendering process.
A tile in a Tileset.
Definition Tile.h:96
const std::optional< BoundingVolume > & getViewerRequestVolume() const noexcept
Returns the viewer request volume of this tile.
Definition Tile.h:237
const std::optional< BoundingVolume > & getContentBoundingVolume() const noexcept
Returns the BoundingVolume of the renderable content of this tile.
Definition Tile.h:387
const TileID & getTileID() const noexcept
Returns the TileID of this tile.
Definition Tile.h:364
double getNonZeroGeometricError() const noexcept
Gets the tile's geometric error as if by calling getGeometricError, except that if the error is small...
Tile(TilesetContentLoader *pLoader) noexcept
Construct a tile with unknown content and a loader that is used to load the content of this tile....
TileSelectionState & getLastSelectionState() noexcept
Returns the TileSelectionState of this tile.
Definition Tile.h:411
const std::vector< RasterMappedTo3DTile > & getMappedRasterTiles() const noexcept
Returns the raster overlay tiles that have been mapped to this tile.
Definition Tile.h:446
void setGeometricError(double value) noexcept
Set the geometric error of the contents of this tile.
Definition Tile.h:271
void setLastSelectionState(const TileSelectionState &newState) noexcept
Set the TileSelectionState of this tile.
Definition Tile.h:427
void setTileID(const TileID &id) noexcept
Set the TileID of this tile.
Definition Tile.h:373
int64_t computeByteSize() const noexcept
Determines the number of bytes in this tile's geometry and texture data.
void createChildTiles(std::vector< Tile > &&children)
Assigns the given child tiles to this tile.
bool isRenderable() const noexcept
Determines if this tile is currently renderable.
const TileSelectionState & getLastSelectionState() const noexcept
Returns the TileSelectionState of this tile.
Definition Tile.h:416
std::span< const Tile > getChildren() const noexcept
Returns a view on the children of this tile.
Definition Tile.h:187
void setRefine(TileRefine value) noexcept
Set the refinement strategy of this tile.
Definition Tile.h:334
const glm::dmat4x4 & getTransform() const noexcept
Gets the transformation matrix for this tile.
Definition Tile.h:344
std::span< Tile > getChildren() noexcept
Returns a view on the children of this tile.
Definition Tile.h:182
void setTransform(const glm::dmat4x4 &value) noexcept
Set the transformation matrix for this tile.
Definition Tile.h:353
void setViewerRequestVolume(const std::optional< BoundingVolume > &value) noexcept
Set the viewer request volume of this tile.
Definition Tile.h:249
TileRefine getRefine() const noexcept
The refinement strategy of this tile.
Definition Tile.h:325
Tile(TilesetContentLoader *pLoader, TileEmptyContent emptyContent) noexcept
Construct a tile with an empty content and a loader that is associated with this tile....
void setContentBoundingVolume(const std::optional< BoundingVolume > &value) noexcept
Set the BoundingVolume of the renderable content of this tile.
Definition Tile.h:399
Tile(TilesetContentLoader *pLoader, std::unique_ptr< TileExternalContent > &&externalContent) noexcept
Construct a tile with an external content and a loader that is associated with this tile....
const BoundingVolume & getBoundingVolume() const noexcept
Returns the BoundingVolume of this tile.
Definition Tile.h:211
void setBoundingVolume(const BoundingVolume &value) noexcept
Set the BoundingVolume of this tile.
Definition Tile.h:222
void setUnconditionallyRefine() noexcept
Marks that this tile should be unconditionally refined.
Definition Tile.h:310
~Tile() noexcept=default
Default destructor, which clears all resources associated with this tile.
TileContent & getContent() noexcept
Get the content of the tile.
Definition Tile.h:456
const TileContent & getContent() const noexcept
Get the content of the tile.
Definition Tile.h:453
double getGeometricError() const noexcept
Returns the geometric error of this tile.
Definition Tile.h:262
const Tile * getParent() const noexcept
Returns the parent of this tile in the tile hierarchy.
Definition Tile.h:173
The loader interface to load the tile content.
Classes that implement the 3D Tiles standard.
@ ContentLoaded
The tile content has finished loading.
@ Unloading
This tile is in the process of being unloaded, but could not be fully unloaded because an asynchronou...
@ ContentLoading
The tile content is currently being loaded.
@ FailedTemporarily
Something went wrong while loading this tile, but it may be a temporary problem.
@ Unloaded
The tile is not yet loaded at all, beyond the metadata in tileset.json.
@ Failed
Something went wrong while loading this tile and it will not be retried.
@ Done
The tile is completely done loading.
std::variant< CesiumGeometry::BoundingSphere, CesiumGeometry::OrientedBoundingBox, CesiumGeospatial::BoundingRegion, CesiumGeospatial::BoundingRegionWithLooseFittingHeights, CesiumGeospatial::S2CellBoundingVolume > BoundingVolume
A bounding volume.
TileRefine
Refinement strategies for a Cesium3DTilesSelection::Tile.
Definition TileRefine.h:8
std::variant< std::string, CesiumGeometry::QuadtreeTileID, CesiumGeometry::OctreeTileID, CesiumGeometry::UpsampledQuadtreeNode > TileID
An identifier for a Tile inside the tile hierarchy.
Definition TileID.h:39
Utility classes for Cesium.
STL namespace.
A content tag that indicates a tile has no content.
Definition TileContent.h:44