Class: QgsMeshEditor¶
Handles edit operations on a mesh layer.
Added in version 3.22.
Class Hierarchy¶
Base classes¶
- class qgis.core.QgsMeshEditor[source]¶
Bases:
QObject- __init__(meshLayer: QgsMeshLayer | None)
Constructor with a specified layer
meshLayer- Parameters:
meshLayer (Optional[QgsMeshLayer])
- addFace(self, vertexIndexes: Iterable[int]) QgsMeshEditingError[source]¶
Adds a face
faceto the mesh with vertex indexesvertexIndexes, returns topological errors if this operation fails (operation is not realized)- Parameters:
vertexIndexes (Iterable[int])
- Return type:
- addPointsAsVertices(self, point: Iterable[QgsPoint], tolerance: float) int[source]¶
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
tolerancedistance). 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
- addVertexWithDelaunayRefinement(self, vertex: QgsPoint, tolerance: float)[source]¶
Add a vertex in a face with Delaunay refinement of neighboring faces All neighboring faces sharing a vertex will be refined to satisfy the Delaunay condition
Added in version 3.42.
- Parameters:
vertex (QgsPoint)
tolerance (float)
- advancedEdit(self, editing: QgsMeshAdvancedEditing | None)[source]¶
Applies an advance editing on the edited mesh, see
QgsMeshAdvancedEditing- Parameters:
editing (Optional[QgsMeshAdvancedEditing])
- canBeMerged(self, vertexIndex1: int, vertexIndex2: int) bool[source]¶
Returns
Trueif faces separated by vertices with indexesvertexIndex1andvertexIndex2can be merged- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- Return type:
bool
- changeCoordinates(self, verticesIndexes: Iterable[int], newCoordinates: Iterable[QgsPoint])[source]¶
Changes the (X,Y,Z) coordinates values of the vertices with indexes in
verticesindexes with the values innewValues. The caller has the responsibility to check if changing the vertices coordinates does not lead to topological errors New coordinates are in layer CRS.- Parameters:
verticesIndexes (Iterable[int])
newCoordinates (Iterable[QgsPoint])
- changeXYValues(self, verticesIndexes: Iterable[int], newValues: Iterable[QgsPointXY])[source]¶
Changes the (X,Y) coordinates values of the vertices with indexes in
verticesIndexeswith the values innewValues. The caller has the responsibility to check if changing the vertices coordinates does not lead to topological errors. New values are in layer CRS.- Parameters:
verticesIndexes (Iterable[int])
newValues (Iterable[QgsPointXY])
- changeZValues(self, verticesIndexes: Iterable[int], newValues: Iterable[float])[source]¶
Changes the Z values of the vertices with indexes in
verticesindexes with the values innewValues- Parameters:
verticesIndexes (Iterable[int])
newValues (Iterable[float])
- checkConsistency(self, error: QgsMeshEditingError) bool[source]¶
Return
Trueif the edited mesh is consistent- Parameters:
error (QgsMeshEditingError)
- Return type:
bool
- createZValueDatasetGroup(self) QgsMeshDatasetGroup | None¶
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.
Warning
This is dangerous API to call – the caller takes ownership of the returned object, but this object MUST exist for the lifetime of the editor. Use with extreme caution.
- Return type:
Optional[QgsMeshDatasetGroup]
- edgeCanBeFlipped(self, vertexIndex1: int, vertexIndex2: int) bool[source]¶
Returns
Trueif the edge can be flipped (only available for edge shared by two faces with 3 vertices)- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- Return type:
bool
- edgeIsClose(self, point: QgsPointXY, tolerance: float)[source]¶
Returns
Trueif an edge of face is closest than the tolerance from thepointin triangular mesh coordinate Returns also the face index and the edge position infaceIndexandedgePosition- Parameters:
point (QgsPointXY)
tolerance (float) -> (bool)
- extent(self) QgsRectangle[source]¶
Returns the extent of the edited mesh
- Return type:
- faceCanBeAdded(self, face: Iterable[int]) bool[source]¶
Returns
Trueif afacecan be added to the meshNote
All vertices related to this face must be already in the mesh.
- Parameters:
face (Iterable[int])
- Return type:
bool
- faceCanBeSplit(self, faceIndex: int) bool[source]¶
Returns
Trueif face with indexfaceIndexcan be split- Parameters:
faceIndex (int)
- Return type:
bool
- fixError(self, error: QgsMeshEditingError) bool[source]¶
Tries to fix the topological
errorin the mesh. ReturnsFalseif the fix failsAdded in version 3.28.
- Parameters:
error (QgsMeshEditingError)
- Return type:
bool
- flipEdge(self, vertexIndex1: int, vertexIndex2: int)[source]¶
Flips edge (
vertexIndex1,vertexIndex2)- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- initialize(self) QgsMeshEditingError[source]¶
Initializes the mesh editor and returns first error if the internal native mesh has topological errors
- Return type:
- initializeWithErrorsFix(self) QgsMeshEditingError[source]¶
Initializes the mesh editor. If topological errors occur,tries to fix these errors and returns error if there is one that couldn’t be fixed
Added in version 3.28.
- Return type:
- isFaceGeometricallyCompatible(self, face: Iterable[int]) bool[source]¶
Returns
Trueif 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
- isVertexFree(self, vertexIndex: int) bool[source]¶
Returns whether the vertex with index
vertexIndexis a free vertex- Parameters:
vertexIndex (int)
- Return type:
bool
- isVertexOnBoundary(self, vertexIndex: int) bool[source]¶
Returns whether the vertex with index
vertexIndexis on a boundary- Parameters:
vertexIndex (int)
- Return type:
bool
- maximumVerticesPerFace(self) int[source]¶
Returns the maximum count of vertices per face that the mesh can support
- Return type:
int
- merge(self, vertexIndex1: int, vertexIndex2: int)[source]¶
Merges faces separated by vertices with indexes
vertexIndex1andvertexIndex2- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- signal meshEdited[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- reindex(self, renumbering: bool) bool[source]¶
Reindexes the mesh, that is remove unusued index of face and vertices, this operation void the undo/redo stack.
If
renumberingis true, a renumbering is operated to optimize the vertices indexes.Returns
Falseif the operation fail.- Parameters:
renumbering (bool)
- Return type:
bool
- removeFaces(self, facesToRemove: Iterable[int]) QgsMeshEditingError[source]¶
Removes faces
facesto the mesh, returns topological errors if this operation fails (operation is not realized)- Parameters:
facesToRemove (Iterable[int])
- Return type:
- removeVerticesFillHoles(self, verticesToRemoveIndexes: Iterable[int]) List[int]¶
Removes vertices with indexes in the list
verticesToRemoveIndexesin the mesh the surrounding faces AND fills the freed space.This operation fills holes by a Delaunay triangulation using the surrounding vertices. Some vertices could no be deleted to avoid topological error even with hole filling (can not be detected before execution). A list of the remaining vertex indexes is returned.
- Parameters:
verticesToRemoveIndexes (Iterable[int])
- Return type:
List[int]
- removeVerticesWithoutFillHoles(self, verticesToRemoveIndexes: Iterable[int]) QgsMeshEditingError[source]¶
Removes vertices with indexes in the list
verticesToRemoveIndexesin the mesh removing the surrounding faces without filling the freed space.If removing these vertices leads to a topological errors, the method will return the corresponding error and the operation is canceled
- Parameters:
verticesToRemoveIndexes (Iterable[int])
- Return type:
- splitFaces(self, faceIndexes: Iterable[int]) int[source]¶
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