QGIS API Documentation
4.3.0-Master (9dce731a7a1)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
tiledscene
qgsquantizedmeshtiles.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsquantizedmeshtiles.h
3
----------------------------
4
begin : May 2024
5
copyright : (C) 2024 by David Koňařík
6
email : dvdkon at konarici dot cz
7
8
***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
17
#ifndef QGSQUANTIZEDMESHTILED_H
18
#define QGSQUANTIZEDMESHTILED_H
19
20
#include "qgis_core.h"
21
#include "
qgsexception.h
"
22
#include "
qgsmeshdataprovider.h
"
23
#include "
qgsrectangle.h
"
24
25
#include <qbytearray.h>
26
27
#define SIP_NO_FILE
28
29
#define TINYGLTF_NO_STB_IMAGE
// we use QImage-based reading of images
30
#define TINYGLTF_NO_STB_IMAGE_WRITE
// we don't need writing of images
31
#include "tiny_gltf.h"
32
33
34
// Definition copied from format spec: https://github.com/CesiumGS/quantized-mesh
35
#pragma pack( push, 1 )
36
struct
QgsQuantizedMeshHeader
37
{
38
// The center of the tile in Earth-centered Fixed coordinates.
39
double
CenterX
;
40
double
CenterY
;
41
double
CenterZ
;
42
43
// The minimum and maximum heights in the area covered by this tile.
44
// The minimum may be lower and the maximum may be higher than
45
// the height of any vertex in this tile in the case that the min/max vertex
46
// was removed during mesh simplification, but these are the appropriate
47
// values to use for analysis or visualization.
48
float
MinimumHeight
;
49
float
MaximumHeight
;
50
51
// The tile’s bounding sphere. The X,Y,Z coordinates are again expressed
52
// in Earth-centered Fixed coordinates, and the radius is in meters.
53
double
BoundingSphereCenterX
;
54
double
BoundingSphereCenterY
;
55
double
BoundingSphereCenterZ
;
56
double
BoundingSphereRadius
;
57
58
// The horizon occlusion point, expressed in the ellipsoid-scaled Earth-centered Fixed frame.
59
// If this point is below the horizon, the entire tile is below the horizon.
60
// See http://cesiumjs.org/2013/04/25/Horizon-culling/ for more information.
61
double
HorizonOcclusionPointX
;
62
double
HorizonOcclusionPointY
;
63
double
HorizonOcclusionPointZ
;
64
65
uint32_t
vertexCount
;
66
};
67
#pragma pack( pop )
68
74
class
CORE_EXPORT
QgsQuantizedMeshParsingException
:
public
QgsException
75
{
76
public
:
77
using
QgsException::QgsException
;
78
};
79
80
struct
CORE_EXPORT
QgsQuantizedMeshTile
81
{
82
QgsQuantizedMeshHeader
mHeader
;
83
std::vector<uint16_t>
mVertexCoords
;
84
std::vector<float>
mNormalCoords
;
85
std::vector<uint32_t>
mTriangleIndices
;
86
std::vector<uint32_t>
mWestVertices
;
87
std::vector<uint32_t>
mSouthVertices
;
88
std::vector<uint32_t>
mEastVertices
;
89
std::vector<uint32_t>
mNorthVertices
;
90
std::map<uint8_t, std::vector<char>>
mExtensions
;
91
92
QgsQuantizedMeshTile
(
const
QByteArray &data );
93
// For some reason, commonly available QM tiles often have a very high (as
94
// much as 50%) percentage of degenerate triangles. They don't harm our
95
// rendering, but removing them could improve performance and makes working
96
// with the data easier.
97
void
removeDegenerateTriangles
();
98
void
generateNormals
();
99
tinygltf::Model
toGltf
(
bool
addSkirt =
false
,
double
skirtDepth = 0,
bool
withTextureCoords =
false
);
100
// Make sure to call removeDegenerateTriangles() beforehand!
101
QgsMesh
toMesh
(
QgsRectangle
tileBounds );
102
};
103
104
#endif
// QGSQUANTIZEDMESHTILED_H
QgsException::QgsException
QgsException(const QString &message)
Constructor for QgsException, with the specified error message.
Definition
qgsexception.h:39
QgsQuantizedMeshParsingException
Exception thrown on failure to parse Quantized Mesh tile (malformed data).
Definition
qgsquantizedmeshtiles.h:75
QgsQuantizedMeshParsingException::QgsException
QgsException(const QString &message)
Constructor for QgsException, with the specified error message.
Definition
qgsexception.h:39
QgsRectangle
A rectangle specified with double values.
Definition
qgsrectangle.h:47
qgsexception.h
qgsmeshdataprovider.h
qgsrectangle.h
QgsMesh
Mesh - vertices, edges and faces.
Definition
qgsmeshdataprovider.h:53
QgsQuantizedMeshHeader
Definition
qgsquantizedmeshtiles.h:37
QgsQuantizedMeshHeader::BoundingSphereCenterX
double BoundingSphereCenterX
Definition
qgsquantizedmeshtiles.h:53
QgsQuantizedMeshHeader::CenterY
double CenterY
Definition
qgsquantizedmeshtiles.h:40
QgsQuantizedMeshHeader::vertexCount
uint32_t vertexCount
Definition
qgsquantizedmeshtiles.h:65
QgsQuantizedMeshHeader::BoundingSphereCenterY
double BoundingSphereCenterY
Definition
qgsquantizedmeshtiles.h:54
QgsQuantizedMeshHeader::MaximumHeight
float MaximumHeight
Definition
qgsquantizedmeshtiles.h:49
QgsQuantizedMeshHeader::MinimumHeight
float MinimumHeight
Definition
qgsquantizedmeshtiles.h:48
QgsQuantizedMeshHeader::BoundingSphereRadius
double BoundingSphereRadius
Definition
qgsquantizedmeshtiles.h:56
QgsQuantizedMeshHeader::HorizonOcclusionPointX
double HorizonOcclusionPointX
Definition
qgsquantizedmeshtiles.h:61
QgsQuantizedMeshHeader::CenterZ
double CenterZ
Definition
qgsquantizedmeshtiles.h:41
QgsQuantizedMeshHeader::CenterX
double CenterX
Definition
qgsquantizedmeshtiles.h:39
QgsQuantizedMeshHeader::BoundingSphereCenterZ
double BoundingSphereCenterZ
Definition
qgsquantizedmeshtiles.h:55
QgsQuantizedMeshHeader::HorizonOcclusionPointZ
double HorizonOcclusionPointZ
Definition
qgsquantizedmeshtiles.h:63
QgsQuantizedMeshHeader::HorizonOcclusionPointY
double HorizonOcclusionPointY
Definition
qgsquantizedmeshtiles.h:62
QgsQuantizedMeshTile::mNormalCoords
std::vector< float > mNormalCoords
Definition
qgsquantizedmeshtiles.h:84
QgsQuantizedMeshTile::removeDegenerateTriangles
void removeDegenerateTriangles()
Definition
qgsquantizedmeshtiles.cpp:174
QgsQuantizedMeshTile::mTriangleIndices
std::vector< uint32_t > mTriangleIndices
Definition
qgsquantizedmeshtiles.h:85
QgsQuantizedMeshTile::toGltf
tinygltf::Model toGltf(bool addSkirt=false, double skirtDepth=0, bool withTextureCoords=false)
Definition
qgsquantizedmeshtiles.cpp:228
QgsQuantizedMeshTile::QgsQuantizedMeshTile
QgsQuantizedMeshTile(const QByteArray &data)
Definition
qgsquantizedmeshtiles.cpp:108
QgsQuantizedMeshTile::generateNormals
void generateNormals()
Definition
qgsquantizedmeshtiles.cpp:190
QgsQuantizedMeshTile::mNorthVertices
std::vector< uint32_t > mNorthVertices
Definition
qgsquantizedmeshtiles.h:89
QgsQuantizedMeshTile::mWestVertices
std::vector< uint32_t > mWestVertices
Definition
qgsquantizedmeshtiles.h:86
QgsQuantizedMeshTile::toMesh
QgsMesh toMesh(QgsRectangle tileBounds)
Definition
qgsquantizedmeshtiles.cpp:525
QgsQuantizedMeshTile::mHeader
QgsQuantizedMeshHeader mHeader
Definition
qgsquantizedmeshtiles.h:82
QgsQuantizedMeshTile::mEastVertices
std::vector< uint32_t > mEastVertices
Definition
qgsquantizedmeshtiles.h:88
QgsQuantizedMeshTile::mExtensions
std::map< uint8_t, std::vector< char > > mExtensions
Definition
qgsquantizedmeshtiles.h:90
QgsQuantizedMeshTile::mVertexCoords
std::vector< uint16_t > mVertexCoords
Definition
qgsquantizedmeshtiles.h:83
QgsQuantizedMeshTile::mSouthVertices
std::vector< uint32_t > mSouthVertices
Definition
qgsquantizedmeshtiles.h:87
Generated on
for QGIS API Documentation by
1.17.0