QGIS API Documentation  3.21.0-Master (5b68dc587e)
Classes | Signals | Public Member Functions | Friends | List of all members
QgsMeshEditor Class Reference

Class that makes edit operation on a mesh. More...

#include <qgsmesheditor.h>

Inheritance diagram for QgsMeshEditor:
Inheritance graph
[legend]

Signals

void meshEdited ()
 Emitted when the mesh is edited. More...
 

Public Member Functions

 QgsMeshEditor (QgsMesh *nativeMesh, QgsTriangularMesh *triangularMesh, QObject *parent=nullptr)
 Constructor with a specific mesh nativeMesh and an associatd triangular mesh triangularMesh. More...
 
 QgsMeshEditor (QgsMeshLayer *meshLayer)
 Constructor with a specified layer meshLayer. More...
 
 ~QgsMeshEditor ()
 
QgsMeshEditingError addFace (const QVector< int > &vertexIndexes)
 Adds a face face to the mesh with vertex indexes vertexIndexes, returns topological errors if this operation fails (operation is not realized) More...
 
QgsMeshEditingError addFaces (const QVector< QgsMeshFace > &faces)
 Adds faces faces to the mesh, returns topological errors if this operation fails (operation is not realized) More...
 
int addPointsAsVertices (const QVector< QgsPoint > &point, double tolerance)
 Adds points as vertices in triangular mesh coordinate in the mesh. More...
 
int addVertices (const QVector< QgsMeshVertex > &vertices, double tolerance)
 Adds vertices in triangular mesh coordinate in the mesh. More...
 
void advancedEdit (QgsMeshAdvancedEditing *editing)
 Applies an advance editing on the edited mesh, see QgsMeshAdvancedEditing. More...
 
bool canBeMerged (int vertexIndex1, int vertexIndex2) const
 Returns true if faces separated by vertices with indexes vertexIndex1 and vertexIndex2 can be merged. More...
 
bool canBeTransformed (const QList< int > &facesToCheck, const std::function< const QgsMeshVertex(int)> &transformFunction) const
 Returns true if faces with index in transformedFaces can be transformed without obtaining topologic or geometrical errors condidering the transform function transformFunction. More...
 
void changeCoordinates (const QList< int > &verticesIndexes, const QList< QgsPoint > &newCoordinates)
 Changes the (X,Y,Z) coordinates values of the vertices with indexes in vertices indexes with the values in newValues. More...
 
void changeXYValues (const QList< int > &verticesIndexes, const QList< QgsPointXY > &newValues)
 Changes the (X,Y) coordinates values of the vertices with indexes in vertices indexes with the values in newValues. More...
 
void changeZValues (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. More...
 
bool checkConsistency () const
 Return true if the edited mesh is consistent. More...
 
QgsMeshDatasetGroupcreateZValueDatasetGroup ()
 Creates and returns a scalar dataset group with value on vertex that is can be used to access the Z value of the edited mesh. More...
 
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) More...
 
bool edgeIsClose (QgsPointXY point, double tolerance, int &faceIndex, int &edgePosition)
 Returns true if an edge of face is closest than the tolerance from the point in triangular mesh coordinate Returns also the face index and the edge position in faceIndex and edgePosition. More...
 
QgsRectangle extent () const
 Returns the extent of the edited mesh. More...
 
bool faceCanBeAdded (const QgsMeshFace &face)
 Returns true if a face can be added to the mesh. More...
 
bool faceCanBeSplit (int faceIndex) const
 Returns true if face with index faceIndex can be split. More...
 
void flipEdge (int vertexIndex1, int vertexIndex2)
 Flips edge (vertexIndex1, vertexIndex2) More...
 
QList< int > freeVerticesIndexes () const
 Returns all the free vertices indexes. More...
 
QgsMeshEditingError initialize ()
 Initialize the mesh editor and return errors if the internal native mesh have topologic errors. More...
 
bool isFaceGeometricallyCompatible (const QgsMeshFace &face)
 Returns true if the face does not intersect or contains any other elements (faces or vertices) The topological compatibility is not checked. More...
 
bool isModified () const
 Returns whether the mesh has been modified. More...
 
bool isVertexFree (int vertexIndex) const
 Returns whether the vertex with index vertexIndex is a free vertex. More...
 
bool isVertexOnBoundary (int vertexIndex) const
 Returns whether the vertex with index vertexIndex is on a boundary. More...
 
void merge (int vertexIndex1, int vertexIndex2)
 Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2. More...
 
bool reindex (bool renumbering)
 Reindexes the mesh, that is remove unusued index of face and vertices, this operation void the undo/redo stack. More...
 
QgsMeshEditingError removeFaces (const QList< int > &facesToRemove)
 Removes faces faces to the mesh, returns topological errors if this operation fails (operation is not realized) More...
 
QgsMeshEditingError removeVertices (const QList< int > &verticesToRemoveIndexes, bool fillHoles=false)
 Removes vertices with indexes in the list verticesToRemoveIndexes in the mesh if fillHoles is set to true, this operation will fill holes created in the mesh, if not remove the surrounding faces. More...
 
void resetTriangularMesh (QgsTriangularMesh *triangularMesh)
 Resets the triangular mesh. More...
 
int splitFaces (const QList< int > &faceIndexes)
 Splits faces with index faceIndexes. More...
 
void stopEditing ()
 Stops editing. More...
 
QgsTopologicalMeshtopologicalMesh ()
 Returns a reference to the topological mesh. More...
 
QgsTriangularMeshtriangularMesh ()
 Returns a pointer to the triangular mesh. More...
 
int validFacesCount () const
 Returns the count of valid faces, that is non void faces in the mesh. More...
 
int validVerticesCount () const
 Returns the count of valid vertices, that is non void vertices in the mesh. More...
 
QgsMeshVertexCirculator vertexCirculator (int vertexIndex) const
 Returns a vertex circulator linked to this mesh around the vertex with index vertexIndex. More...
 

Friends

class QgsMeshLayerUndoCommandAddFaces
 
class QgsMeshLayerUndoCommandAddVertices
 
class QgsMeshLayerUndoCommandAdvancedEditing
 
class QgsMeshLayerUndoCommandChangeCoordinates
 
class QgsMeshLayerUndoCommandChangeXYValue
 
class QgsMeshLayerUndoCommandChangeZValue
 
class QgsMeshLayerUndoCommandFlipEdge
 
class QgsMeshLayerUndoCommandMerge
 
class QgsMeshLayerUndoCommandMeshEdit
 
class QgsMeshLayerUndoCommandRemoveFaces
 
class QgsMeshLayerUndoCommandRemoveVertices
 
class QgsMeshLayerUndoCommandSetZValue
 
class QgsMeshLayerUndoCommandSplitFaces
 
class TestQgsMeshEditor
 

Detailed Description

Class that makes edit operation on a mesh.

Since
QGIS 3.22

Definition at line 64 of file qgsmesheditor.h.

Constructor & Destructor Documentation

◆ QgsMeshEditor() [1/2]

QgsMeshEditor::QgsMeshEditor ( QgsMeshLayer meshLayer)

Constructor with a specified layer meshLayer.

Definition at line 33 of file qgsmesheditor.cpp.

◆ QgsMeshEditor() [2/2]

QgsMeshEditor::QgsMeshEditor ( QgsMesh nativeMesh,
QgsTriangularMesh triangularMesh,
QObject *  parent = nullptr 
)

Constructor with a specific mesh nativeMesh and an associatd triangular mesh triangularMesh.

Definition at line 46 of file qgsmesheditor.cpp.

◆ ~QgsMeshEditor()

QgsMeshEditor::~QgsMeshEditor ( )
default

Member Function Documentation

◆ addFace()

QgsMeshEditingError QgsMeshEditor::addFace ( const QVector< int > &  vertexIndexes)

Adds a face face to the mesh with vertex indexes vertexIndexes, returns topological errors if this operation fails (operation is not realized)

Definition at line 533 of file qgsmesheditor.cpp.

◆ addFaces()

QgsMeshEditingError QgsMeshEditor::addFaces ( const QVector< QgsMeshFace > &  faces)

Adds faces faces to the mesh, returns topological errors if this operation fails (operation is not realized)

Definition at line 513 of file qgsmesheditor.cpp.

◆ addPointsAsVertices()

int QgsMeshEditor::addPointsAsVertices ( const QVector< QgsPoint > &  point,
double  tolerance 
)

Adds points as vertices in triangular mesh coordinate in the mesh.

Vertex is effectivly added if the transform from triangular coordinate to layer coordinate succeeds or if any vertices are next the added vertex (under tolerance distance). The method returns the number of vertices effectivly added.

Note
this operation remove including face if exists and replace it by new faces surrounding the vertex if the mesh hasn't topological error before this operation, the toological operation always succeed

Definition at line 581 of file qgsmesheditor.cpp.

◆ addVertices()

int QgsMeshEditor::addVertices ( const QVector< QgsMeshVertex > &  vertices,
double  tolerance 
)

Adds vertices in triangular mesh coordinate in the mesh.

Vertex is effectivly added if the transform from triangular coordinate to layer coordinate succeeds or if any vertices are next the added vertex (under tolerance distance). The method returns the number of vertices effectivly added.

Note
this operation remove including face if exists and replace it by new faces surrounding the vertex if the mesh hasn't topological error before this operation, the toological operation always succeed.

Definition at line 538 of file qgsmesheditor.cpp.

◆ advancedEdit()

void QgsMeshEditor::advancedEdit ( QgsMeshAdvancedEditing editing)

Applies an advance editing on the edited mesh, see QgsMeshAdvancedEditing.

Definition at line 741 of file qgsmesheditor.cpp.

◆ canBeMerged()

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

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

Definition at line 456 of file qgsmesheditor.cpp.

◆ canBeTransformed()

bool QgsMeshEditor::canBeTransformed ( const QList< int > &  facesToCheck,
const std::function< const QgsMeshVertex(int)> &  transformFunction 
) const

Returns true if faces with index in transformedFaces can be transformed without obtaining topologic or geometrical errors condidering the transform function transformFunction.

The transform function takes a vertex index in parameter and return a QgsMeshVertex object with transformed coordinates. This transformation is done in layer coordinates

Note
Even only the faces with indexes in transformdFaces are checked to avoid testing all the mesh, all the mesh are supposed to path through this transform function (but it is possible that transform function is not able to transform all vertices). Moving free vertices of the mesh are also checked.

Definition at line 616 of file qgsmesheditor.cpp.

◆ changeCoordinates()

void QgsMeshEditor::changeCoordinates ( const QList< int > &  verticesIndexes,
const QList< QgsPoint > &  newCoordinates 
)

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

The caller has the responsibility to check if changing the vertices coordinates does not lead to topological errors New coordinates are in layer CRS.

Definition at line 736 of file qgsmesheditor.cpp.

◆ changeXYValues()

void QgsMeshEditor::changeXYValues ( const QList< int > &  verticesIndexes,
const QList< QgsPointXY > &  newValues 
)

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

The caller has the responsibility to check if changing the vertices coordinates does not lead to topological errors. New values are in layer CRS.

Definition at line 730 of file qgsmesheditor.cpp.

◆ changeZValues()

void QgsMeshEditor::changeZValues ( 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 611 of file qgsmesheditor.cpp.

◆ checkConsistency()

bool QgsMeshEditor::checkConsistency ( ) const

Return true if the edited mesh is consistent.

Definition at line 351 of file qgsmesheditor.cpp.

◆ createZValueDatasetGroup()

QgsMeshDatasetGroup * QgsMeshEditor::createZValueDatasetGroup ( )

Creates and returns a scalar dataset group with value on vertex that is can be used to access the Z value of the edited mesh.

The caller takes ownership.

Definition at line 55 of file qgsmesheditor.cpp.

◆ edgeCanBeFlipped()

bool QgsMeshEditor::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 443 of file qgsmesheditor.cpp.

◆ edgeIsClose()

bool QgsMeshEditor::edgeIsClose ( QgsPointXY  point,
double  tolerance,
int &  faceIndex,
int &  edgePosition 
)

Returns true if an edge of face is closest than the tolerance from the point in triangular mesh coordinate Returns also the face index and the edge position in faceIndex and edgePosition.

Definition at line 375 of file qgsmesheditor.cpp.

◆ extent()

QgsRectangle QgsMeshEditor::extent ( ) const

Returns the extent of the edited mesh.

Definition at line 885 of file qgsmesheditor.cpp.

◆ faceCanBeAdded()

bool QgsMeshEditor::faceCanBeAdded ( const QgsMeshFace face)

Returns true if a face can be added to the mesh.

Definition at line 167 of file qgsmesheditor.cpp.

◆ faceCanBeSplit()

bool QgsMeshEditor::faceCanBeSplit ( int  faceIndex) const

Returns true if face with index faceIndex can be split.

Definition at line 469 of file qgsmesheditor.cpp.

◆ flipEdge()

void QgsMeshEditor::flipEdge ( int  vertexIndex1,
int  vertexIndex2 
)

Flips edge (vertexIndex1, vertexIndex2)

Definition at line 448 of file qgsmesheditor.cpp.

◆ freeVerticesIndexes()

QList< int > QgsMeshEditor::freeVerticesIndexes ( ) const

Returns all the free vertices indexes.

Definition at line 922 of file qgsmesheditor.cpp.

◆ initialize()

QgsMeshEditingError QgsMeshEditor::initialize ( )

Initialize the mesh editor and return errors if the internal native mesh have topologic errors.

Definition at line 64 of file qgsmesheditor.cpp.

◆ isFaceGeometricallyCompatible()

bool QgsMeshEditor::isFaceGeometricallyCompatible ( const QgsMeshFace face)

Returns true if the face does not intersect or contains any other elements (faces or vertices) The topological compatibility is not checked.

Definition at line 78 of file qgsmesheditor.cpp.

◆ isModified()

bool QgsMeshEditor::isModified ( ) const

Returns whether the mesh has been modified.

Definition at line 890 of file qgsmesheditor.cpp.

◆ isVertexFree()

bool QgsMeshEditor::isVertexFree ( int  vertexIndex) const

Returns whether the vertex with index vertexIndex is a free vertex.

Definition at line 932 of file qgsmesheditor.cpp.

◆ isVertexOnBoundary()

bool QgsMeshEditor::isVertexOnBoundary ( int  vertexIndex) const

Returns whether the vertex with index vertexIndex is on a boundary.

Definition at line 927 of file qgsmesheditor.cpp.

◆ merge()

void QgsMeshEditor::merge ( int  vertexIndex1,
int  vertexIndex2 
)

Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2.

Definition at line 461 of file qgsmesheditor.cpp.

◆ meshEdited

void QgsMeshEditor::meshEdited ( )
signal

Emitted when the mesh is edited.

◆ reindex()

bool QgsMeshEditor::reindex ( bool  renumbering)

Reindexes the mesh, that is remove unusued index of face and vertices, this operation void the undo/redo stack.

If renumbering is true, a renumbering is operated to optimize the vertices indexes.

Returns false if the operation fail.

Definition at line 898 of file qgsmesheditor.cpp.

◆ removeFaces()

QgsMeshEditingError QgsMeshEditor::removeFaces ( const QList< int > &  facesToRemove)

Removes faces faces to the mesh, returns topological errors if this operation fails (operation is not realized)

Definition at line 432 of file qgsmesheditor.cpp.

◆ removeVertices()

QgsMeshEditingError QgsMeshEditor::removeVertices ( const QList< int > &  verticesToRemoveIndexes,
bool  fillHoles = false 
)

Removes vertices with indexes in the list verticesToRemoveIndexes in the mesh if fillHoles is set to true, this operation will fill holes created in the mesh, if not remove the surrounding faces.

If removing these vertices leads to a topological errors, the method will return the corresponding error and the operatio is canceled

Definition at line 586 of file qgsmesheditor.cpp.

◆ resetTriangularMesh()

void QgsMeshEditor::resetTriangularMesh ( QgsTriangularMesh triangularMesh)

Resets the triangular mesh.

Definition at line 73 of file qgsmesheditor.cpp.

◆ splitFaces()

int QgsMeshEditor::splitFaces ( const QList< int > &  faceIndexes)

Splits faces with index faceIndexes.

Only faces that can be split are split. Returns the count of faces effictively split

Definition at line 474 of file qgsmesheditor.cpp.

◆ stopEditing()

void QgsMeshEditor::stopEditing ( )

Stops editing.

Definition at line 746 of file qgsmesheditor.cpp.

◆ topologicalMesh()

QgsTopologicalMesh & QgsMeshEditor::topologicalMesh ( )

Returns a reference to the topological mesh.

Definition at line 942 of file qgsmesheditor.cpp.

◆ triangularMesh()

QgsTriangularMesh * QgsMeshEditor::triangularMesh ( )

Returns a pointer to the triangular mesh.

Definition at line 947 of file qgsmesheditor.cpp.

◆ validFacesCount()

int QgsMeshEditor::validFacesCount ( ) const

Returns the count of valid faces, that is non void faces in the mesh.

Definition at line 422 of file qgsmesheditor.cpp.

◆ validVerticesCount()

int QgsMeshEditor::validVerticesCount ( ) const

Returns the count of valid vertices, that is non void vertices in the mesh.

Definition at line 427 of file qgsmesheditor.cpp.

◆ vertexCirculator()

QgsMeshVertexCirculator QgsMeshEditor::vertexCirculator ( int  vertexIndex) const

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

If the vertex does not exist or is a free vertex, the cirxulator is invalid. If stopEditing() is called, circulator created before and new circulator are valid and must not be used. It is recommended to destruct all circulator created before calling any edit methods or stopEditing() to save memory usage. Calling initialize() allows creation of new circulator after stopEditing() is called.

Definition at line 937 of file qgsmesheditor.cpp.

Friends And Related Function Documentation

◆ QgsMeshLayerUndoCommandAddFaces

friend class QgsMeshLayerUndoCommandAddFaces
friend

Definition at line 301 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandAddVertices

Definition at line 299 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandAdvancedEditing

Definition at line 311 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandChangeCoordinates

Definition at line 306 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandChangeXYValue

Definition at line 305 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandChangeZValue

Definition at line 304 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandFlipEdge

friend class QgsMeshLayerUndoCommandFlipEdge
friend

Definition at line 307 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandMerge

friend class QgsMeshLayerUndoCommandMerge
friend

Definition at line 308 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandMeshEdit

friend class QgsMeshLayerUndoCommandMeshEdit
friend

Definition at line 298 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandRemoveFaces

Definition at line 302 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandRemoveVertices

Definition at line 300 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandSetZValue

friend class QgsMeshLayerUndoCommandSetZValue
friend

Definition at line 303 of file qgsmesheditor.h.

◆ QgsMeshLayerUndoCommandSplitFaces

friend class QgsMeshLayerUndoCommandSplitFaces
friend

Definition at line 309 of file qgsmesheditor.h.

◆ TestQgsMeshEditor

friend class TestQgsMeshEditor
friend

Definition at line 297 of file qgsmesheditor.h.


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