QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Member Functions | Friends | List of all members
QgsTriangularMesh Class Reference

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

#include <qgstriangularmesh.h>

Public Member Functions

 QgsTriangularMesh ()
 Ctor. More...
 
 ~QgsTriangularMesh ()
 Dtor. More...
 
double averageTriangleSize () const
 Returns the average size of triangles in map unit. More...
 
Q_DECL_DEPRECATED const QVector< QgsMeshVertex > & centroids () const
 Returns centroids of the native faces in map CRS. More...
 
bool contains (const QgsMesh::ElementType &type) const
 Returns whether the mesh contains at mesh elements of given type. More...
 
const QVector< QgsMeshVertex > & edgeCentroids () const
 Returns centroids of the native edges in map CRS. More...
 
QList< int > edgeIndexesForRectangle (const QgsRectangle &rectangle) const
 Finds indexes of edges intersecting given bounding box It uses spatial indexing. More...
 
const QVector< QgsMeshEdge > & edges () const
 Returns edges. More...
 
const QVector< int > & edgesToNativeEdges () const
 Returns mapping between edges and original edges. More...
 
QgsRectangle extent () const
 Returns the extent of the triangular mesh in map coordinates. More...
 
const QVector< QgsMeshVertex > & faceCentroids () const
 Returns centroids of the native faces in map CRS. More...
 
QList< int > faceIndexesForRectangle (const QgsRectangle &rectangle) const
 Finds indexes of triangles intersecting given bounding box It uses spatial indexing. More...
 
int faceIndexForPoint (const QgsPointXY &point) const
 Finds index of triangle at given point It uses spatial indexing. More...
 
int faceIndexForPoint_v2 (const QgsPointXY &point) const
 Finds index of triangle at given point It uses spatial indexing and don't use geos to be faster. More...
 
int levelOfDetail () const
 Returns the corresponding index of level of detail on which this mesh is associated. More...
 
QVector< QgsTriangularMesh * > simplifyMesh (double reductionFactor, int minimumTrianglesCount=10) const
 Returns simplified meshes. More...
 
const QVector< QgsMeshFace > & triangles () const
 Returns triangles. More...
 
const QVector< int > & trianglesToNativeFaces () const
 Returns mapping between triangles and original faces. More...
 
bool update (QgsMesh *nativeMesh, const QgsCoordinateTransform &transform=QgsCoordinateTransform())
 Constructs triangular mesh from layer's native mesh and transform to destination CRS. More...
 
QVector< QVector3D > vertexNormals (float vertScale) const
 Calculates and returns normale vector on each vertex that is part of any face. More...
 
const QVector< QgsMeshVertex > & vertices () const
 Returns vertices in map coordinate system. More...
 

Friends

class TestQgsTriangularMesh
 

Detailed Description

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.

Note
The API is considered EXPERIMENTAL and can be changed without a notice
Since
QGIS 3.2

Definition at line 50 of file qgstriangularmesh.h.

Constructor & Destructor Documentation

◆ QgsTriangularMesh()

QgsTriangularMesh::QgsTriangularMesh ( )
default

Ctor.

◆ ~QgsTriangularMesh()

QgsTriangularMesh::~QgsTriangularMesh ( )
default

Dtor.

Member Function Documentation

◆ averageTriangleSize()

double QgsTriangularMesh::averageTriangleSize ( ) const

Returns the average size of triangles in map unit.

It is calculated using the maximum of the height/width of the bounding box of each triangles.

Since
QGIS 3.14

Definition at line 114 of file qgstriangularmesh.cpp.

◆ centroids()

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

Returns centroids of the native faces in map CRS.

Deprecated:
since QGIS 3.14 use faceCentroids() instead

Definition at line 310 of file qgstriangularmesh.cpp.

◆ contains()

bool QgsTriangularMesh::contains ( const QgsMesh::ElementType type) const

Returns whether the mesh contains at mesh elements of given type.

Since
QGIS 3.14

Definition at line 280 of file qgstriangularmesh.cpp.

◆ edgeCentroids()

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

Returns centroids of the native edges in map CRS.

Since
QGIS 3.14

Definition at line 320 of file qgstriangularmesh.cpp.

◆ edgeIndexesForRectangle()

QList< int > QgsTriangularMesh::edgeIndexesForRectangle ( const QgsRectangle rectangle) const

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

Parameters
rectanglebounding box in map coordinate system
Returns
edges indexes that intersect the rectangle

Definition at line 366 of file qgstriangularmesh.cpp.

◆ edges()

const QVector< QgsMeshEdge > & QgsTriangularMesh::edges ( ) const

Returns edges.

Definition at line 305 of file qgstriangularmesh.cpp.

◆ edgesToNativeEdges()

const QVector< int > & QgsTriangularMesh::edgesToNativeEdges ( ) const

Returns mapping between edges and original edges.

Definition at line 330 of file qgstriangularmesh.cpp.

◆ extent()

QgsRectangle QgsTriangularMesh::extent ( ) const

Returns the extent of the triangular mesh in map coordinates.

Returns
bounding box of the triangular mesh
Since
QGIS 3.14

Definition at line 270 of file qgstriangularmesh.cpp.

◆ faceCentroids()

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

Returns centroids of the native faces in map CRS.

Since
QGIS 3.14

Definition at line 315 of file qgstriangularmesh.cpp.

◆ faceIndexesForRectangle()

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

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

Parameters
rectanglebounding box in map coordinate system
Returns
triangle indexes that intersect the rectangle
Since
QGIS 3.4

Definition at line 361 of file qgstriangularmesh.cpp.

◆ faceIndexForPoint()

int QgsTriangularMesh::faceIndexForPoint ( const QgsPointXY point) const

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

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

Definition at line 335 of file qgstriangularmesh.cpp.

◆ faceIndexForPoint_v2()

int QgsTriangularMesh::faceIndexForPoint_v2 ( const QgsPointXY point) const

Finds index of triangle at given point It uses spatial indexing and don't use geos to be faster.

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

Definition at line 348 of file qgstriangularmesh.cpp.

◆ levelOfDetail()

int QgsTriangularMesh::levelOfDetail ( ) const

Returns the corresponding index of level of detail on which this mesh is associated.

  • 0: base mesh
  • 1: first simplified mesh
  • 2: second simplified mesh (lower level of detail)
  • ...
Since
QGIS 3.14

Definition at line 275 of file qgstriangularmesh.cpp.

◆ simplifyMesh()

QVector< QgsTriangularMesh * > QgsTriangularMesh::simplifyMesh ( double  reductionFactor,
int  minimumTrianglesCount = 10 
) const

Returns simplified meshes.

The first simplified mesh is simplified with a goal of a number of triangles equals to the number of triangles of the base mesh divised by the reduction factor. For the following mesh the same reduction factor is used with the prededent goal of number of triangles. There are as many simplified meshes as necessary to have a the minimum triangles count on the last simplified mesh.

The caller has to take the ownership of returned meshes.

Not implemented for Edge meshes and Mixed meshes

Parameters
reductionFactoris the factor used to reduce the number of triangles of the mesh
minimumTrianglesCountis the minimal faces count on simplified mesh
Since
QGIS 3.14

Definition at line 396 of file qgstriangularmesh.cpp.

◆ triangles()

const QVector< QgsMeshFace > & QgsTriangularMesh::triangles ( ) const

Returns triangles.

Definition at line 300 of file qgstriangularmesh.cpp.

◆ trianglesToNativeFaces()

const QVector< int > & QgsTriangularMesh::trianglesToNativeFaces ( ) const

Returns mapping between triangles and original faces.

Definition at line 325 of file qgstriangularmesh.cpp.

◆ update()

bool QgsTriangularMesh::update ( QgsMesh nativeMesh,
const QgsCoordinateTransform transform = QgsCoordinateTransform() 
)

Constructs triangular mesh from layer's native mesh and transform to destination CRS.

Populates spatial index.

Parameters
nativeMeshQgsMesh to access native vertices and faces
transformTransformation from layer CRS to destination (e.g. map) CRS. With invalid transform, it keeps the native mesh CRS
Returns
true if the mesh is effectivly updated, and false if not

Definition at line 122 of file qgstriangularmesh.cpp.

◆ vertexNormals()

QVector< QVector3D > QgsTriangularMesh::vertexNormals ( float  vertScale) const

Calculates and returns normale vector on each vertex that is part of any face.

Returns
all normales at vertices
Since
QGIS 3.12

Definition at line 371 of file qgstriangularmesh.cpp.

◆ vertices()

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)

Definition at line 295 of file qgstriangularmesh.cpp.

Friends And Related Function Documentation

◆ TestQgsTriangularMesh

friend class TestQgsTriangularMesh
friend

Definition at line 250 of file qgstriangularmesh.h.


The documentation for this class was generated from the following files: