cesium-native 0.43.0
Loading...
Searching...
No Matches
Tile.h
1#pragma once
2
3#include "BoundingVolume.h"
4#include "Library.h"
5#include "RasterMappedTo3DTile.h"
6#include "TileContent.h"
7#include "TileID.h"
8#include "TileRefine.h"
9#include "TileSelectionState.h"
10
11#include <CesiumUtility/DoublyLinkedList.h>
12
13#include <glm/common.hpp>
14
15#include <atomic>
16#include <limits>
17#include <memory>
18#include <optional>
19#include <span>
20#include <string>
21#include <vector>
22
23namespace Cesium3DTilesSelection {
24class TilesetContentLoader;
25
29enum class TileLoadState {
34 Unloading = -2,
35
41
46 Unloaded = 0,
47
56
60 ContentLoaded = 2,
61
65 Done = 3,
66
71 Failed = 4,
72};
73
97class CESIUM3DTILESSELECTION_API Tile final {
98public:
106 explicit Tile(TilesetContentLoader* pLoader) noexcept;
107
117 TilesetContentLoader* pLoader,
118 std::unique_ptr<TileExternalContent>&& externalContent) noexcept;
119
128 Tile(TilesetContentLoader* pLoader, TileEmptyContent emptyContent) noexcept;
129
134 ~Tile() noexcept = default;
135
141 Tile(const Tile& rhs) = delete;
142
148 Tile(Tile&& rhs) noexcept;
149
155 Tile& operator=(const Tile& rhs) = delete;
156
162 Tile& operator=(Tile&& rhs) noexcept;
163
171 Tile* getParent() noexcept { return this->_pParent; }
172
174 const Tile* getParent() const noexcept { return this->_pParent; }
175
183 std::span<Tile> getChildren() noexcept {
184 return std::span<Tile>(this->_children);
185 }
186
188 std::span<const Tile> getChildren() const noexcept {
189 return std::span<const Tile>(this->_children);
190 }
191
200 void createChildTiles(std::vector<Tile>&& children);
201
212 const BoundingVolume& getBoundingVolume() const noexcept {
213 return this->_boundingVolume;
214 }
215
223 void setBoundingVolume(const BoundingVolume& value) noexcept {
224 this->_boundingVolume = value;
225 }
226
238 const std::optional<BoundingVolume>& getViewerRequestVolume() const noexcept {
239 return this->_viewerRequestVolume;
240 }
241
249 void
250 setViewerRequestVolume(const std::optional<BoundingVolume>& value) noexcept {
251 this->_viewerRequestVolume = value;
252 }
253
263 double getGeometricError() const noexcept { return this->_geometricError; }
264
272 void setGeometricError(double value) noexcept {
273 this->_geometricError = value;
274 }
275
290 double getNonZeroGeometricError() const noexcept;
291
302 bool getUnconditionallyRefine() const noexcept {
303 return glm::isinf(this->_geometricError);
304 }
305
311 void setUnconditionallyRefine() noexcept {
312 this->_geometricError = std::numeric_limits<double>::infinity();
313 }
314
326 TileRefine getRefine() const noexcept { return this->_refine; }
327
335 void setRefine(TileRefine value) noexcept { this->_refine = value; }
336
345 const glm::dmat4x4& getTransform() const noexcept { return this->_transform; }
346
354 void setTransform(const glm::dmat4x4& value) noexcept {
355 this->_transform = value;
356 }
357
365 const TileID& getTileID() const noexcept { return this->_id; }
366
374 void setTileID(const TileID& id) noexcept { this->_id = id; }
375
387 const std::optional<BoundingVolume>&
388 getContentBoundingVolume() const noexcept {
389 return this->_contentBoundingVolume;
390 }
391
401 const std::optional<BoundingVolume>& value) noexcept {
402 this->_contentBoundingVolume = value;
403 }
404
413 return this->_lastSelectionState;
414 }
415
418 return this->_lastSelectionState;
419 }
420
428 void setLastSelectionState(const TileSelectionState& newState) noexcept {
429 this->_lastSelectionState = newState;
430 }
431
436 int64_t computeByteSize() const noexcept;
437
441 std::vector<RasterMappedTo3DTile>& getMappedRasterTiles() noexcept {
442 return this->_rasterTiles;
443 }
444
446 const std::vector<RasterMappedTo3DTile>&
447 getMappedRasterTiles() const noexcept {
448 return this->_rasterTiles;
449 }
450
454 const TileContent& getContent() const noexcept { return _content; }
455
457 TileContent& getContent() noexcept { return _content; }
458
462 bool isRenderable() const noexcept;
463
467 bool isRenderContent() const noexcept;
468
472 bool isExternalContent() const noexcept;
473
477 bool isEmptyContent() const noexcept;
478
482 TilesetContentLoader* getLoader() const noexcept;
483
487 TileLoadState getState() const noexcept;
488
489private:
490 struct TileConstructorImpl {};
491 template <
492 typename... TileContentArgs,
493 typename TileContentEnable = std::enable_if_t<
494 std::is_constructible_v<TileContent, TileContentArgs&&...>,
495 int>>
496 Tile(
497 TileConstructorImpl tag,
498 TileLoadState loadState,
499 TilesetContentLoader* pLoader,
500 TileContentArgs&&... args);
501
502 void setParent(Tile* pParent) noexcept;
503
504 void setState(TileLoadState state) noexcept;
505
521 bool getMightHaveLatentChildren() const noexcept;
522
523 void setMightHaveLatentChildren(bool mightHaveLatentChildren) noexcept;
524
525 // Position in bounding-volume hierarchy.
526 Tile* _pParent;
527 std::vector<Tile> _children;
528
529 // Properties from tileset.json.
530 // These are immutable after the tile leaves TileState::Unloaded.
531 TileID _id;
532 BoundingVolume _boundingVolume;
533 std::optional<BoundingVolume> _viewerRequestVolume;
534 std::optional<BoundingVolume> _contentBoundingVolume;
535 double _geometricError;
536 TileRefine _refine;
537 glm::dmat4x4 _transform;
538
539 // Selection state
540 TileSelectionState _lastSelectionState;
541
542 // tile content
543 CesiumUtility::DoublyLinkedListPointers<Tile> _loadedTilesLinks;
544 TileContent _content;
545 TilesetContentLoader* _pLoader;
546 TileLoadState _loadState;
547 bool _mightHaveLatentChildren;
548
549 // mapped raster overlay
550 std::vector<RasterMappedTo3DTile> _rasterTiles;
551
552 friend class TilesetContentManager;
553 friend class MockTilesetContentManagerTestFixture;
554
555public:
559 typedef CesiumUtility::DoublyLinkedList<Tile, &Tile::_loadedTilesLinks>
561};
562
563} // 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:97
const std::optional< BoundingVolume > & getViewerRequestVolume() const noexcept
Returns the viewer request volume of this tile.
Definition Tile.h:238
const std::optional< BoundingVolume > & getContentBoundingVolume() const noexcept
Returns the BoundingVolume of the renderable content of this tile.
Definition Tile.h:388
const TileID & getTileID() const noexcept
Returns the TileID of this tile.
Definition Tile.h:365
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:412
const std::vector< RasterMappedTo3DTile > & getMappedRasterTiles() const noexcept
Returns the raster overlay tiles that have been mapped to this tile.
Definition Tile.h:447
void setGeometricError(double value) noexcept
Set the geometric error of the contents of this tile.
Definition Tile.h:272
void setLastSelectionState(const TileSelectionState &newState) noexcept
Set the TileSelectionState of this tile.
Definition Tile.h:428
void setTileID(const TileID &id) noexcept
Set the TileID of this tile.
Definition Tile.h:374
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:417
std::span< const Tile > getChildren() const noexcept
Returns a view on the children of this tile.
Definition Tile.h:188
void setRefine(TileRefine value) noexcept
Set the refinement strategy of this tile.
Definition Tile.h:335
const glm::dmat4x4 & getTransform() const noexcept
Gets the transformation matrix for this tile.
Definition Tile.h:345
std::span< Tile > getChildren() noexcept
Returns a view on the children of this tile.
Definition Tile.h:183
void setTransform(const glm::dmat4x4 &value) noexcept
Set the transformation matrix for this tile.
Definition Tile.h:354
void setViewerRequestVolume(const std::optional< BoundingVolume > &value) noexcept
Set the viewer request volume of this tile.
Definition Tile.h:250
TileRefine getRefine() const noexcept
The refinement strategy of this tile.
Definition Tile.h:326
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:400
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:212
void setBoundingVolume(const BoundingVolume &value) noexcept
Set the BoundingVolume of this tile.
Definition Tile.h:223
void setUnconditionallyRefine() noexcept
Marks that this tile should be unconditionally refined.
Definition Tile.h:311
~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:457
const TileContent & getContent() const noexcept
Get the content of the tile.
Definition Tile.h:454
double getGeometricError() const noexcept
Returns the geometric error of this tile.
Definition Tile.h:263
const Tile * getParent() const noexcept
Returns the parent of this tile in the tile hierarchy.
Definition Tile.h:174
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:40
Utility classes for Cesium.
STL namespace.
A content tag that indicates a tile has no content.
Definition TileContent.h:45