QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
Classes | 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>

Classes

class  Changes
 The Changes class is used to make changes of the triangular and to keep traces of this changes If a Changes instance is applied (see QgsTriangularMesh::applyChanges()), these changes can be reversed (see QgsTriangularMesh::reverseChanges()) as long as other changes are not applied. More...
 

Public Member Functions

 QgsTriangularMesh ()
 
 ~QgsTriangularMesh ()
 
void applyChanges (const Changes &changes)
 Applies the changes on the triangular mesh (see Changes)
 
double averageTriangleSize () const
 Returns the average size of triangles in map unit.
 
Q_DECL_DEPRECATED const QVector< QgsMeshVertex > & centroids () const
 Returns centroids of the native faces in map CRS.
 
bool contains (const QgsMesh::ElementType &type) const
 Returns whether the mesh contains mesh elements of given type.
 
const QVector< QgsMeshVertex > & edgeCentroids () const
 Returns centroids of the native edges in map CRS.
 
QList< int > edgeIndexesForRectangle (const QgsRectangle &rectangle) const
 Finds indexes of edges intersecting given bounding box It uses spatial indexing.
 
const QVector< QgsMeshEdge > & edges () const
 Returns edges.
 
const QVector< int > & edgesToNativeEdges () const
 Returns mapping between edges and original edges.
 
QgsRectangle extent () const
 Returns the extent of the triangular mesh in map coordinates.
 
const QVector< QgsMeshVertex > & faceCentroids () const
 Returns centroids of the native faces in map CRS.
 
QList< int > faceIndexesForRectangle (const QgsRectangle &rectangle) const
 Finds indexes of triangles intersecting given bounding box It uses spatial indexing.
 
int faceIndexForPoint (const QgsPointXY &point) const
 Finds index of triangle at given point It uses spatial indexing.
 
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.
 
int levelOfDetail () const
 Returns the corresponding index of level of detail on which this mesh is associated.
 
QgsRectangle nativeExtent ()
 Returns the extent of the mesh in the native mesh coordinates system, returns empty extent if the transformation fails.
 
int nativeFaceIndexForPoint (const QgsPointXY &point) const
 Finds index of native face at given point It uses spatial indexing.
 
QList< int > nativeFaceIndexForRectangle (const QgsRectangle &rectangle) const
 Finds indexes of native faces which bounding boxes intersect given bounding box It uses spatial indexing.
 
QgsMeshVertex nativeToTriangularCoordinates (const QgsMeshVertex &vertex) const
 Transforms the vertex from native coordinates system to triangular mesh coordinates system.
 
void reverseChanges (const Changes &changes, const QgsMesh &nativeMesh)
 Reverses the changes on the triangular mesh (see Changes)
 
QVector< QgsTriangularMesh * > simplifyMesh (double reductionFactor, int minimumTrianglesCount=10) const
 Returns simplified meshes.
 
QgsPointXY transformFromLayerToTrianglesCoordinates (const QgsPointXY &point) const
 Transforms a point from layer coordinates system to triangular Mesh coordinates system.
 
const QVector< QgsMeshFace > & triangles () const
 Returns triangles.
 
const QVector< int > & trianglesToNativeFaces () const
 Returns mapping between triangles and original faces.
 
QgsMeshVertex triangularToNativeCoordinates (const QgsMeshVertex &vertex) const
 Transforms the vertex from triangular mesh coordinates system to native coordinates system.
 
bool update (QgsMesh *nativeMesh)
 Constructs triangular mesh from layer's native mesh using the coordinate transform already set.
 
bool update (QgsMesh *nativeMesh, const QgsCoordinateTransform &transform)
 Constructs triangular mesh from layer's native mesh and transform to destination CRS.
 
QVector< QVector3D > vertexNormals (float vertScale) const
 Calculates and returns normal vector on each vertex that is part of any face.
 
const QVector< QgsMeshVertex > & vertices () const
 Returns vertices in map coordinate system.
 

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 51 of file qgstriangularmesh.h.

Constructor & Destructor Documentation

◆ QgsTriangularMesh()

QgsTriangularMesh::QgsTriangularMesh ( )
default

◆ ~QgsTriangularMesh()

QgsTriangularMesh::~QgsTriangularMesh ( )
default

Member Function Documentation

◆ applyChanges()

void QgsTriangularMesh::applyChanges ( const Changes changes)

Applies the changes on the triangular mesh (see Changes)

Since
QGIS 3.22

Definition at line 729 of file qgstriangularmesh.cpp.

◆ 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 149 of file qgstriangularmesh.cpp.

◆ centroids()

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

Returns centroids of the native faces in map CRS.

Deprecated:
QGIS 3.14. Use faceCentroids() instead.

Definition at line 372 of file qgstriangularmesh.cpp.

◆ contains()

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

Returns whether the mesh contains mesh elements of given type.

Since
QGIS 3.14

Definition at line 334 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 382 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 470 of file qgstriangularmesh.cpp.

◆ edges()

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

Returns edges.

Definition at line 367 of file qgstriangularmesh.cpp.

◆ edgesToNativeEdges()

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

Returns mapping between edges and original edges.

Definition at line 392 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 315 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 377 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 465 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 419 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 452 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 329 of file qgstriangularmesh.cpp.

◆ nativeExtent()

QgsRectangle QgsTriangularMesh::nativeExtent ( )

Returns the extent of the mesh in the native mesh coordinates system, returns empty extent if the transformation fails.

Since
QGIS 3.22

Definition at line 292 of file qgstriangularmesh.cpp.

◆ nativeFaceIndexForPoint()

int QgsTriangularMesh::nativeFaceIndexForPoint ( const QgsPointXY point) const

Finds index of native face at given point It uses spatial indexing.

Parameters
pointpoint in map coordinate system
Returns
native face index that contains the given point, -1 if no such faces exists
Since
QGIS 3.22

Definition at line 432 of file qgstriangularmesh.cpp.

◆ nativeFaceIndexForRectangle()

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

Finds indexes of native faces which bounding boxes intersect given bounding box It uses spatial indexing.

Parameters
rectanglebounding box in map coordinate system
Returns
native face indexes that have bounding box that intersect the rectangle
Since
QGIS 3.22

Definition at line 444 of file qgstriangularmesh.cpp.

◆ nativeToTriangularCoordinates()

QgsMeshVertex QgsTriangularMesh::nativeToTriangularCoordinates ( const QgsMeshVertex vertex) const

Transforms the vertex from native coordinates system to triangular mesh coordinates system.

Returns empty vertex if the transform fails.

Since
QGIS 3.22

Definition at line 282 of file qgstriangularmesh.cpp.

◆ reverseChanges()

void QgsTriangularMesh::reverseChanges ( const Changes changes,
const QgsMesh nativeMesh 
)

Reverses the changes on the triangular mesh (see Changes)

Since
QGIS 3.22

Definition at line 861 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 equal to the number of triangles of the base mesh divided by the reduction factor. For the following mesh the same reduction factor is used with the preceding goal of number of triangles. There are as many simplified meshes as necessary to have 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 503 of file qgstriangularmesh.cpp.

◆ transformFromLayerToTrianglesCoordinates()

QgsPointXY QgsTriangularMesh::transformFromLayerToTrianglesCoordinates ( const QgsPointXY point) const

Transforms a point from layer coordinates system to triangular Mesh coordinates system.

Parameters
pointpoint in layer coordinate system
Returns
point in triangular mesh coordinate
Since
QGIS 3.22

Definition at line 397 of file qgstriangularmesh.cpp.

◆ triangles()

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

Returns triangles.

Definition at line 362 of file qgstriangularmesh.cpp.

◆ trianglesToNativeFaces()

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

Returns mapping between triangles and original faces.

Definition at line 387 of file qgstriangularmesh.cpp.

◆ triangularToNativeCoordinates()

QgsMeshVertex QgsTriangularMesh::triangularToNativeCoordinates ( const QgsMeshVertex vertex) const

Transforms the vertex from triangular mesh coordinates system to native coordinates system.

Returns empty vertex if the transform fails.

Since
QGIS 3.22

Definition at line 287 of file qgstriangularmesh.cpp.

◆ update() [1/2]

bool QgsTriangularMesh::update ( QgsMesh nativeMesh)

Constructs triangular mesh from layer's native mesh using the coordinate transform already set.

Populates spatial index.

Parameters
nativeMeshQgsMesh to access native vertices and faces
Returns
true if the mesh is effectivly updated, and false if not
Note
if the coordinate transform is not already set, it uses the native mesh CRS
Since
QGIS 3.28

Definition at line 257 of file qgstriangularmesh.cpp.

◆ update() [2/2]

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

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 157 of file qgstriangularmesh.cpp.

◆ vertexNormals()

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

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

Returns
all normals at vertices
Since
QGIS 3.12

Definition at line 475 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 357 of file qgstriangularmesh.cpp.

Friends And Related Symbol Documentation

◆ TestQgsTriangularMesh

friend class TestQgsTriangularMesh
friend

Definition at line 384 of file qgstriangularmesh.h.


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