Class: QgsMeshEditor

class qgis.core.QgsMeshEditor

Bases: PyQt5.QtCore.QObject

Class that makes edit operation on a mesh

New in version 3.22.

QgsMeshEditor(meshLayer: QgsMeshLayer) Constructor with a specified layer meshLayer

Methods

addFace

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

addPointsAsVertices

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

advancedEdit

Applies an advance editing on the edited mesh, see QgsMeshAdvancedEditing

canBeMerged

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

changeXYValues

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

changeZValues

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

checkConsistency

Return True if the edited mesh is consistent

childEvent

connectNotify

customEvent

disconnectNotify

edgeCanBeFlipped

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

extent

Returns the extent of the edited mesh

faceCanBeAdded

Returns True if a face can be added to the mesh

faceCanBeSplit

Returns True if face with index faceIndex can be split

flipEdge

Flips edge (vertexIndex1, vertexIndex2)

freeVerticesIndexes

Returns all the free vertices indexes

initialize

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

isFaceGeometricallyCompatible

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

isModified

Returns whether the mesh has been modified

isSignalConnected

isVertexFree

Returns whether the vertex with index vertexIndex is a free vertex

isVertexOnBoundary

Returns whether the vertex with index vertexIndex is on a boundary

merge

Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2

receivers

removeFaces

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

removeVertices

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

sender

senderSignalIndex

splitFaces

Splits faces with index faceIndexes.

stopEditing

Stops editing

timerEvent

Signals

meshEdited

Emitted when the mesh is edited [signal]

addFace(self, vertexIndexes: Iterable[int])QgsMeshEditingError

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

Parameters

vertexIndexes (Iterable[int]) –

Return type

QgsMeshEditingError

addPointsAsVertices(self, point: Iterable[QgsPoint], tolerance: float)int

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

Parameters
  • point (Iterable[QgsPoint]) –

  • tolerance (float) –

Return type

int

advancedEdit(self, editing: QgsMeshAdvancedEditing)

Applies an advance editing on the edited mesh, see QgsMeshAdvancedEditing

Parameters

editing (QgsMeshAdvancedEditing) –

canBeMerged(self, vertexIndex1: int, vertexIndex2: int)bool

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

Parameters
  • vertexIndex1 (int) –

  • vertexIndex2 (int) –

Return type

bool

changeXYValues(self, verticesIndexes: Iterable[int], newValues: Iterable[QgsPointXY])

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

Parameters
  • verticesIndexes (Iterable[int]) –

  • newValues (Iterable[QgsPointXY]) –

changeZValues(self, verticesIndexes: Iterable[int], newValues: Iterable[float])

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

Parameters
  • verticesIndexes (Iterable[int]) –

  • newValues (Iterable[float]) –

checkConsistency(self)bool

Return True if the edited mesh is consistent

Return type

bool

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
edgeCanBeFlipped(self, vertexIndex1: int, vertexIndex2: int)bool

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

Parameters
  • vertexIndex1 (int) –

  • vertexIndex2 (int) –

Return type

bool

extent(self)QgsRectangle

Returns the extent of the edited mesh

Return type

QgsRectangle

faceCanBeAdded(self, face: Iterable[int])bool

Returns True if a face can be added to the mesh

Parameters

face (Iterable[int]) –

Return type

bool

faceCanBeSplit(self, faceIndex: int)bool

Returns True if face with index faceIndex can be split

Parameters

faceIndex (int) –

Return type

bool

flipEdge(self, vertexIndex1: int, vertexIndex2: int)

Flips edge (vertexIndex1, vertexIndex2)

Parameters
  • vertexIndex1 (int) –

  • vertexIndex2 (int) –

freeVerticesIndexes(self)List[int]

Returns all the free vertices indexes

Return type

List[int]

initialize(self)QgsMeshEditingError

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

Return type

QgsMeshEditingError

isFaceGeometricallyCompatible(self, face: Iterable[int])bool

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

Parameters

face (Iterable[int]) –

Return type

bool

isModified(self)bool

Returns whether the mesh has been modified

Return type

bool

isSignalConnected(self, QMetaMethod)bool
isVertexFree(self, vertexIndex: int)bool

Returns whether the vertex with index vertexIndex is a free vertex

Parameters

vertexIndex (int) –

Return type

bool

isVertexOnBoundary(self, vertexIndex: int)bool

Returns whether the vertex with index vertexIndex is on a boundary

Parameters

vertexIndex (int) –

Return type

bool

merge(self, vertexIndex1: int, vertexIndex2: int)

Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2

Parameters
  • vertexIndex1 (int) –

  • vertexIndex2 (int) –

meshEdited

Emitted when the mesh is edited [signal]

receivers(self, PYQT_SIGNAL)int
removeFaces(self, facesToRemove: Iterable[int])QgsMeshEditingError

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

Parameters

facesToRemove (Iterable[int]) –

Return type

QgsMeshEditingError

removeVertices(self, verticesToRemoveIndexes: Iterable[int], fillHoles: bool = False)QgsMeshEditingError

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

Parameters
  • verticesToRemoveIndexes (Iterable[int]) –

  • fillHoles (bool = False) –

Return type

QgsMeshEditingError

sender(self)QObject
senderSignalIndex(self)int
splitFaces(self, faceIndexes: Iterable[int])int

Splits faces with index faceIndexes. Only faces that can be split are split. Returns the count of faces effictively split

Parameters

faceIndexes (Iterable[int]) –

Return type

int

stopEditing(self)

Stops editing

timerEvent(self, QTimerEvent)