QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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 TINYGLTF_NO_STB_IMAGE // we use QImage-based reading of images
28#define TINYGLTF_NO_STB_IMAGE_WRITE // we don't need writing of images
29#include "tiny_gltf.h"
30
31#define SIP_NO_FILE
32
33// Definition copied from format spec: https://github.com/CesiumGS/quantized-mesh
34#pragma pack (push, 1)
36{
37 // The center of the tile in Earth-centered Fixed coordinates.
38 double CenterX;
39 double CenterY;
40 double CenterZ;
41
42 // The minimum and maximum heights in the area covered by this tile.
43 // The minimum may be lower and the maximum may be higher than
44 // the height of any vertex in this tile in the case that the min/max vertex
45 // was removed during mesh simplification, but these are the appropriate
46 // values to use for analysis or visualization.
49
50 // The tile’s bounding sphere. The X,Y,Z coordinates are again expressed
51 // in Earth-centered Fixed coordinates, and the radius is in meters.
56
57 // The horizon occlusion point, expressed in the ellipsoid-scaled Earth-centered Fixed frame.
58 // If this point is below the horizon, the entire tile is below the horizon.
59 // See http://cesiumjs.org/2013/04/25/Horizon-culling/ for more information.
63
64 uint32_t vertexCount;
65};
66#pragma pack (pop)
67
74{
75 public:
77};
78
79struct CORE_EXPORT QgsQuantizedMeshTile
80{
82 std::vector<uint16_t> mVertexCoords;
83 std::vector<float> mNormalCoords;
84 std::vector<uint32_t> mTriangleIndices;
85 std::vector<uint32_t> mWestVertices;
86 std::vector<uint32_t> mSouthVertices;
87 std::vector<uint32_t> mEastVertices;
88 std::vector<uint32_t> mNorthVertices;
89 std::map<uint8_t, std::vector<char>> mExtensions;
90
91 QgsQuantizedMeshTile( const QByteArray &data );
92 // For some reason, commonly available QM tiles often have a very high (as
93 // much as 50%) percentage of degenerate triangles. They don't harm our
94 // rendering, but removing them could improve performance and makes working
95 // with the data easier.
97 void generateNormals();
98 tinygltf::Model toGltf( bool addSkirt = false, double skirtDepth = 0, bool withTextureCoords = false );
99 // Make sure to call removeDegenerateTriangles() beforehand!
100 QgsMesh toMesh( QgsRectangle tileBounds );
101};
102
103#endif // QGSQUANTIZEDMESHTILED_H
QgsException(const QString &message)
Constructor for QgsException, with the specified error message.
Exception thrown on failure to parse Quantized Mesh tile (malformed data).
QgsException(const QString &message)
Constructor for QgsException, with the specified error message.
A rectangle specified with double values.
Mesh - vertices, edges and faces.
std::vector< float > mNormalCoords
std::vector< uint32_t > mTriangleIndices
tinygltf::Model toGltf(bool addSkirt=false, double skirtDepth=0, bool withTextureCoords=false)
QgsQuantizedMeshTile(const QByteArray &data)
std::vector< uint32_t > mNorthVertices
std::vector< uint32_t > mWestVertices
QgsMesh toMesh(QgsRectangle tileBounds)
QgsQuantizedMeshHeader mHeader
std::vector< uint32_t > mEastVertices
std::map< uint8_t, std::vector< char > > mExtensions
std::vector< uint16_t > mVertexCoords
std::vector< uint32_t > mSouthVertices