QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsTopologicalMesh Class Reference

Wraps a QgsMesh to ensure the consistency of the mesh during editing and helps to access elements from other elements. More...

#include <qgstopologicalmesh.h>

Classes

class  Changes
 Contains topological differences between two states of a topological mesh, only accessible from the QgsTopologicalMesh class. More...
class  TopologicalFaces
 Contains independent faces and topological information about these faces. More...

Public Types

using FaceNeighbors = QVector<int>

Public Member Functions

Changes addFaces (const TopologicalFaces &topologicFaces)
 Adds faces topologicFaces to the topologic mesh.
Changes addFreeVertex (const QgsMeshVertex &vertex)
 Adds a free vertex in the face, that is a vertex that is not included or linked with any faces.
Changes addVertexInFace (int faceIndex, const QgsMeshVertex &vertex)
 Adds a vertex in the face with index faceIndex.
void applyChanges (const Changes &changes)
 Applies the changes.
bool canBeMerged (int vertexIndex1, int vertexIndex2) const
 Returns true if faces separated by vertices with indexes vertexIndex1 and vertexIndex2 can be merged.
bool canBeSplit (int faceIndex) const
 Returns true if face with index faceIndex can be split.
Changes changeXYValue (const QList< int > &verticesIndexes, const QList< QgsPointXY > &newValues)
 Changes the (X,Y) values of the vertices with indexes in vertices indexes with the values in newValues.
Changes changeZValue (const QList< int > &verticesIndexes, const QList< double > &newValues)
 Changes the Z values of the vertices with indexes in vertices indexes with the values in newValues.
QgsMeshEditingError checkConsistency () const
 Checks the consistency of the topological mesh and return false if there is a consistency issue.
bool delaunayConditionForEdge (int vertexIndex1, int vertexIndex2)
 Check if Delaunay condition holds for given edge returns true if delaunay condition holds false otherwise.
bool edgeCanBeFlipped (int vertexIndex1, int vertexIndex2) const
 Returns true if the edge can be flipped (only available for edge shared by two faces with 3 vertices).
QList< int > facesAroundVertex (int vertexIndex) const
 Returns the indexes of faces that are around the vertex with index vertexIndex.
QgsMeshEditingError facesCanBeAdded (const TopologicalFaces &topologicalFaces) const
 Returns whether the faces can be added to the mesh.
QgsMeshEditingError facesCanBeRemoved (const QList< int > &facesIndexes)
 Returns whether faces with index in faceIndexes can be removed/ The method an error object with type QgsMeshEditingError::NoError if the faces can be removed, otherwise returns the corresponding error.
int firstFaceLinked (int vertexIndex) const
 Returns the index of the first face linked, returns -1 if it is a free vertex or out of range index.
Changes flipEdge (int vertexIndex1, int vertexIndex2)
 Flips edge (vertexIndex1, vertexIndex2) The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.
QList< int > freeVerticesIndexes () const
 Returns a list of vertices are not linked to any faces.
Changes insertVertexInFacesEdge (int faceIndex, int position, const QgsMeshVertex &vertex)
 Inserts a vertex in the edge of face with index faceIndex at position .
bool isVertexFree (int vertexIndex) const
 Returns whether the vertex is a free vertex.
bool isVertexOnBoundary (int vertexIndex) const
 Returns whether the vertex is on a boundary.
Changes merge (int vertexIndex1, int vertexIndex2)
 Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2 The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.
QgsMeshmesh () const
 Returns a pointer to the wrapped mesh.
QVector< int > neighborsOfFace (int faceIndex) const
 Returns the indexes of neighbor faces of the face with index faceIndex.
void reindex ()
 Reindexes faces and vertices, after this operation, the topological mesh can't be edited anymore and only the method mesh can be used to access to the raw mesh.
Changes removeFaces (const QList< int > &facesIndexes)
 Removes faces with index in faceIndexes.
Changes removeVertexFillHole (int vertexIndex)
 Removes the vertex with index vertexIndex.
Changes removeVertices (const QList< int > &vertices)
 Removes all the vertices with index in the list vertices If vertices in linked with faces, the operation leads also to remove the faces without filling holes.
bool renumber ()
 Renumbers the indexes of vertices and faces using the Reverse CutHill McKee Algorithm.
void reverseChanges (const Changes &changes)
 Reverses the changes.
Changes splitFace (int faceIndex)
 Splits face with index faceIndex The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.
QgsMeshVertexCirculator vertexCirculator (int vertexIndex) const
 Returns a vertex circulator linked to this mesh around the vertex with index vertexIndex.

Static Public Member Functions

static QgsMeshEditingError checkTopology (const QgsMesh &mesh, int maxVerticesPerFace)
 Checks the topology of the mesh mesh, if error occurs, this mesh can't be edited.
static QgsMeshEditingError checkTopologyOfVerticesAsFace (const QVector< QgsMeshVertex > &vertices, bool &clockwise)
 Checks the topology of the vertices as they are contained in a face and returns indication on direction.
static QgsMeshEditingError counterClockwiseFaces (QgsMeshFace &face, QgsMesh *mesh)
 Checks the topology of the face and sets it counter clockwise if necessary.
static TopologicalFaces createNewTopologicalFaces (const QVector< QgsMeshFace > &faces, bool uniqueSharedVertexAllowed, QgsMeshEditingError &error)
 Creates new topological faces that are not yet included in the mesh.
static QgsTopologicalMesh createTopologicalMesh (QgsMesh *mesh, int maxVerticesPerFace, QgsMeshEditingError &error)
 Creates a topologicaly consistent mesh with mesh, this static method modifies mesh to be topological consistent and return a QgsTopologicalMesh instance that contains and handles this mesh (does not take ownership).
static int vertexPositionInFace (const QgsMesh &mesh, int vertexIndex, int faceIndex)
 Returns vertex position in face.
static int vertexPositionInFace (int vertexIndex, const QgsMeshFace &face)
 Returns vertex position in face.

Friends

class QgsMeshVertexCirculator

Detailed Description

Wraps a QgsMesh to ensure the consistency of the mesh during editing and helps to access elements from other elements.

A topological face must:

  • be convex
  • be oriented counter-clockwise
  • not share a unique vertex with another face
Since
QGIS 3.22

Definition at line 45 of file qgstopologicalmesh.h.

Member Typedef Documentation

◆ FaceNeighbors

using QgsTopologicalMesh::FaceNeighbors = QVector<int>

Definition at line 49 of file qgstopologicalmesh.h.

Member Function Documentation

◆ addFaces()

QgsTopologicalMesh::Changes QgsTopologicalMesh::addFaces ( const TopologicalFaces & topologicFaces)

Adds faces topologicFaces to the topologic mesh.

The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 284 of file qgstopologicalmesh.cpp.

◆ addFreeVertex()

QgsTopologicalMesh::Changes QgsTopologicalMesh::addFreeVertex ( const QgsMeshVertex & vertex)

Adds a free vertex in the face, that is a vertex that is not included or linked with any faces.

The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 1135 of file qgstopologicalmesh.cpp.

◆ addVertexInFace()

QgsTopologicalMesh::Changes QgsTopologicalMesh::addVertexInFace ( int faceIndex,
const QgsMeshVertex & vertex )

Adds a vertex in the face with index faceIndex.

The including face is removed and new faces surrounding the added vertex are added. The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 2297 of file qgstopologicalmesh.cpp.

◆ applyChanges()

void QgsTopologicalMesh::applyChanges ( const Changes & changes)

Applies the changes.

Definition at line 357 of file qgstopologicalmesh.cpp.

◆ canBeMerged()

bool QgsTopologicalMesh::canBeMerged ( int vertexIndex1,
int vertexIndex2 ) const

Returns true if faces separated by vertices with indexes vertexIndex1 and vertexIndex2 can be merged.

Definition at line 2077 of file qgstopologicalmesh.cpp.

◆ canBeSplit()

bool QgsTopologicalMesh::canBeSplit ( int faceIndex) const

Returns true if face with index faceIndex can be split.

Definition at line 2210 of file qgstopologicalmesh.cpp.

◆ changeXYValue()

QgsTopologicalMesh::Changes QgsTopologicalMesh::changeXYValue ( const QList< int > & verticesIndexes,
const QList< QgsPointXY > & newValues )

Changes the (X,Y) values of the vertices with indexes in vertices indexes with the values in newValues.

Definition at line 2566 of file qgstopologicalmesh.cpp.

◆ changeZValue()

QgsTopologicalMesh::Changes QgsTopologicalMesh::changeZValue ( const QList< int > & verticesIndexes,
const QList< double > & newValues )

Changes the Z values of the vertices with indexes in vertices indexes with the values in newValues.

Definition at line 2547 of file qgstopologicalmesh.cpp.

◆ checkConsistency()

QgsMeshEditingError QgsTopologicalMesh::checkConsistency ( ) const

Checks the consistency of the topological mesh and return false if there is a consistency issue.

Definition at line 545 of file qgstopologicalmesh.cpp.

◆ checkTopology()

QgsMeshEditingError QgsTopologicalMesh::checkTopology ( const QgsMesh & mesh,
int maxVerticesPerFace )
static

Checks the topology of the mesh mesh, if error occurs, this mesh can't be edited.

Definition at line 590 of file qgstopologicalmesh.cpp.

◆ checkTopologyOfVerticesAsFace()

QgsMeshEditingError QgsTopologicalMesh::checkTopologyOfVerticesAsFace ( const QVector< QgsMeshVertex > & vertices,
bool & clockwise )
static

Checks the topology of the vertices as they are contained in a face and returns indication on direction.

If the face is clockwise, clockwise is true

Note
Not available in Python bindings
Since
QGIS 3.30

Definition at line 636 of file qgstopologicalmesh.cpp.

◆ counterClockwiseFaces()

QgsMeshEditingError QgsTopologicalMesh::counterClockwiseFaces ( QgsMeshFace & face,
QgsMesh * mesh )
static

Checks the topology of the face and sets it counter clockwise if necessary.

Definition at line 679 of file qgstopologicalmesh.cpp.

◆ createNewTopologicalFaces()

QgsTopologicalMesh::TopologicalFaces QgsTopologicalMesh::createNewTopologicalFaces ( const QVector< QgsMeshFace > & faces,
bool uniqueSharedVertexAllowed,
QgsMeshEditingError & error )
static

Creates new topological faces that are not yet included in the mesh.

Note
Not available in Python bindings

Definition at line 1708 of file qgstopologicalmesh.cpp.

◆ createTopologicalMesh()

QgsTopologicalMesh QgsTopologicalMesh::createTopologicalMesh ( QgsMesh * mesh,
int maxVerticesPerFace,
QgsMeshEditingError & error )
static

Creates a topologicaly consistent mesh with mesh, this static method modifies mesh to be topological consistent and return a QgsTopologicalMesh instance that contains and handles this mesh (does not take ownership).

Definition at line 1666 of file qgstopologicalmesh.cpp.

◆ delaunayConditionForEdge()

bool QgsTopologicalMesh::delaunayConditionForEdge ( int vertexIndex1,
int vertexIndex2 )

Check if Delaunay condition holds for given edge returns true if delaunay condition holds false otherwise.

Since
QGIS 3.42

Definition at line 2590 of file qgstopologicalmesh.cpp.

◆ edgeCanBeFlipped()

bool QgsTopologicalMesh::edgeCanBeFlipped ( int vertexIndex1,
int vertexIndex2 ) const

Returns true if the edge can be flipped (only available for edge shared by two faces with 3 vertices).

Definition at line 1942 of file qgstopologicalmesh.cpp.

◆ facesAroundVertex()

QList< int > QgsTopologicalMesh::facesAroundVertex ( int vertexIndex) const

Returns the indexes of faces that are around the vertex with index vertexIndex.

Definition at line 1809 of file qgstopologicalmesh.cpp.

◆ facesCanBeAdded()

QgsMeshEditingError QgsTopologicalMesh::facesCanBeAdded ( const TopologicalFaces & topologicalFaces) const

Returns whether the faces can be added to the mesh.

Definition at line 1526 of file qgstopologicalmesh.cpp.

◆ facesCanBeRemoved()

QgsMeshEditingError QgsTopologicalMesh::facesCanBeRemoved ( const QList< int > & facesIndexes)

Returns whether faces with index in faceIndexes can be removed/ The method an error object with type QgsMeshEditingError::NoError if the faces can be removed, otherwise returns the corresponding error.

Definition at line 1816 of file qgstopologicalmesh.cpp.

◆ firstFaceLinked()

int QgsTopologicalMesh::firstFaceLinked ( int vertexIndex) const

Returns the index of the first face linked, returns -1 if it is a free vertex or out of range index.

Definition at line 603 of file qgstopologicalmesh.cpp.

◆ flipEdge()

QgsTopologicalMesh::Changes QgsTopologicalMesh::flipEdge ( int vertexIndex1,
int vertexIndex2 )

Flips edge (vertexIndex1, vertexIndex2) The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 1983 of file qgstopologicalmesh.cpp.

◆ freeVerticesIndexes()

QList< int > QgsTopologicalMesh::freeVerticesIndexes ( ) const

Returns a list of vertices are not linked to any faces.

Definition at line 631 of file qgstopologicalmesh.cpp.

◆ insertVertexInFacesEdge()

QgsTopologicalMesh::Changes QgsTopologicalMesh::insertVertexInFacesEdge ( int faceIndex,
int position,
const QgsMeshVertex & vertex )

Inserts a vertex in the edge of face with index faceIndex at position .

The faces that are on each side of the edge are removed and replaced by new faces constructed by a triangulation.

Definition at line 2360 of file qgstopologicalmesh.cpp.

◆ isVertexFree()

bool QgsTopologicalMesh::isVertexFree ( int vertexIndex) const

Returns whether the vertex is a free vertex.

Definition at line 620 of file qgstopologicalmesh.cpp.

◆ isVertexOnBoundary()

bool QgsTopologicalMesh::isVertexOnBoundary ( int vertexIndex) const

Returns whether the vertex is on a boundary.

Definition at line 610 of file qgstopologicalmesh.cpp.

◆ merge()

QgsTopologicalMesh::Changes QgsTopologicalMesh::merge ( int vertexIndex1,
int vertexIndex2 )

Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2 The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 2120 of file qgstopologicalmesh.cpp.

◆ mesh()

QgsMesh * QgsTopologicalMesh::mesh ( ) const

Returns a pointer to the wrapped mesh.

Definition at line 598 of file qgstopologicalmesh.cpp.

◆ neighborsOfFace()

QVector< int > QgsTopologicalMesh::neighborsOfFace ( int faceIndex) const

Returns the indexes of neighbor faces of the face with index faceIndex.

Definition at line 1804 of file qgstopologicalmesh.cpp.

◆ reindex()

void QgsTopologicalMesh::reindex ( )

Reindexes faces and vertices, after this operation, the topological mesh can't be edited anymore and only the method mesh can be used to access to the raw mesh.

Definition at line 716 of file qgstopologicalmesh.cpp.

◆ removeFaces()

QgsTopologicalMesh::Changes QgsTopologicalMesh::removeFaces ( const QList< int > & facesIndexes)

Removes faces with index in faceIndexes.

The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 1835 of file qgstopologicalmesh.cpp.

◆ removeVertexFillHole()

QgsTopologicalMesh::Changes QgsTopologicalMesh::removeVertexFillHole ( int vertexIndex)

Removes the vertex with index vertexIndex.

If the vertex in linked with faces, the operation leads also to remove the faces. In this case, the hole is filled by a triangulation. The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 1180 of file qgstopologicalmesh.cpp.

◆ removeVertices()

QgsTopologicalMesh::Changes QgsTopologicalMesh::removeVertices ( const QList< int > & vertices)

Removes all the vertices with index in the list vertices If vertices in linked with faces, the operation leads also to remove the faces without filling holes.

The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 1496 of file qgstopologicalmesh.cpp.

◆ renumber()

bool QgsTopologicalMesh::renumber ( )

Renumbers the indexes of vertices and faces using the Reverse CutHill McKee Algorithm.

Definition at line 766 of file qgstopologicalmesh.cpp.

◆ reverseChanges()

void QgsTopologicalMesh::reverseChanges ( const Changes & changes)

Reverses the changes.

Definition at line 439 of file qgstopologicalmesh.cpp.

◆ splitFace()

QgsTopologicalMesh::Changes QgsTopologicalMesh::splitFace ( int faceIndex)

Splits face with index faceIndex The method returns a instance of the class QgsTopologicalMesh::Change that can be used to reverse or reapply the operation.

Definition at line 2217 of file qgstopologicalmesh.cpp.

◆ vertexCirculator()

QgsMeshVertexCirculator QgsTopologicalMesh::vertexCirculator ( int vertexIndex) const

Returns a vertex circulator linked to this mesh around the vertex with index vertexIndex.

Note
Not available in Python bindings

Definition at line 513 of file qgstopologicalmesh.cpp.

◆ vertexPositionInFace() [1/2]

int QgsTopologicalMesh::vertexPositionInFace ( const QgsMesh & mesh,
int vertexIndex,
int faceIndex )
static

Returns vertex position in face.

Definition at line 29 of file qgstopologicalmesh.cpp.

◆ vertexPositionInFace() [2/2]

int QgsTopologicalMesh::vertexPositionInFace ( int vertexIndex,
const QgsMeshFace & face )
inlinestatic

Returns vertex position in face.

Definition at line 369 of file qgstopologicalmesh.h.

◆ QgsMeshVertexCirculator

friend class QgsMeshVertexCirculator
friend

Definition at line 419 of file qgstopologicalmesh.h.


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