QgsTriangularMesh class

Triangular/Derived Mesh is mesh with vertices in map coordinates.

It creates spatial index for identification of a triangle that contains a particular point on the map.

Constructors, destructors, conversion operators

QgsTriangularMesh() defaulted
Ctor.
~QgsTriangularMesh() defaulted
Dtor.

Public functions

auto centroids() const -> const QVector<QgsMeshVertex>&
Returns centroids of the native faces in map CRS.
auto faceIndexesForRectangle(const QgsRectangle& rectangle) const -> QList<int>
Finds indexes of triangles intersecting given bounding box It uses spatial indexing.
auto faceIndexForPoint(const QgsPointXY& point) const -> int
Finds index of triangle at given point It uses spatial indexing.
auto triangles() const -> const QVector<QgsMeshFace>&
Returns triangles.
auto trianglesToNativeFaces() const -> const QVector<int>&
Returns mapping between triangles and original faces.
void update(QgsMesh* nativeMesh, QgsRenderContext* context)
Constructs triangular mesh from layer's native mesh and context.
auto vertices() const -> const QVector<QgsMeshVertex>&
Returns vertices in map coordinate system.

Function documentation

QList<int> QgsTriangularMesh::faceIndexesForRectangle(const QgsRectangle& rectangle) const

Finds indexes of triangles intersecting given bounding box It uses spatial indexing.

Parameters
rectangle bounding box in map coordinate system
Returns triangle indexes that intersect the rectangle

int QgsTriangularMesh::faceIndexForPoint(const QgsPointXY& point) const

Finds index of triangle at given point It uses spatial indexing.

Parameters
point point in map coordinate system
Returns triangle index that contains the given point, -1 if no such triangle exists

void QgsTriangularMesh::update(QgsMesh* nativeMesh, QgsRenderContext* context)

Constructs triangular mesh from layer's native mesh and context.

Parameters
nativeMesh QgsMesh to access native vertices and faces
context Rendering context to estimate number of triagles to create for an face

Populates spatial index.

const QVector<QgsMeshVertex>& QgsTriangularMesh::vertices() const

Returns vertices in map coordinate system.

The list of consist of vertices from native mesh (0-N) and extra vertices needed to create triangles (N+1 - len)