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 layermeshLayer
Methods
Adds a face
face
to the mesh with vertex indexesvertexIndexes
, returns topological errors if this operation fails (operation is not realized)Adds points as vertices in triangular mesh coordinate in the mesh.
Applies an advance editing on the edited mesh, see
QgsMeshAdvancedEditing
Returns
True
if faces separated by vertices with indexesvertexIndex1
andvertexIndex2
can be mergedChanges the (X,Y,Z) coordinates values of the vertices with indexes in
vertices
indexes with the values innewValues
.Changes the (X,Y) coordinates values of the vertices with indexes in
verticesIndexes
with the values innewValues
.Changes the Z values of the vertices with indexes in
vertices
indexes with the values innewValues
Return
True
if the edited mesh is consistentCreates and returns a scalar dataset group with value on vertex that is can be used to access the Z value of the edited mesh.
Returns
True
if the edge can be flipped (only available for edge shared by two faces with 3 vertices)Returns
True
if an edge of face is closest than the tolerance from thepoint
in triangular mesh coordinate Returns also the face index and the edge position infaceIndex
andedgePosition
Returns the extent of the edited mesh
Returns
True
if aface
can be added to the meshReturns
True
if face with indexfaceIndex
can be splitTries to fix the topological
error
in the mesh.Flips edge (
vertexIndex1
,vertexIndex2
)Returns all the free vertices indexes
Initializes the mesh editor and returns first error if the internal native mesh has topological errors
Initializes the mesh editor.
Returns
True
if the face does not intersect or contains any other elements (faces or vertices) The topological compatibility is not checkedReturns whether the mesh has been modified
Returns whether the vertex with index
vertexIndex
is a free vertexReturns whether the vertex with index
vertexIndex
is on a boundaryReturns the maximum count of vertices per face that the mesh can support
Merges faces separated by vertices with indexes
vertexIndex1
andvertexIndex2
Reindexes the mesh, that is remove unusued index of face and vertices, this operation void the undo/redo stack.
Removes faces
faces
to the mesh, returns topological errors if this operation fails (operation is not realized)Removes vertices with indexes in the list
verticesToRemoveIndexes
in the mesh the surrounding faces AND fills the freed space.Removes vertices with indexes in the list
verticesToRemoveIndexes
in the mesh removing the surrounding faces without filling the freed space.Splits faces with index
faceIndexes
.Stops editing
Returns the count of valid faces, that is non void faces in the mesh
Returns the count of valid vertices, that is non void vertices in the mesh
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- addFace(self, vertexIndexes: Iterable[int]) QgsMeshEditingError ¶
Adds a face
face
to 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 ¶
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 indexesvertexIndex1
andvertexIndex2
can be merged- Parameters:
vertexIndex1 (int) –
vertexIndex2 (int) –
- Return type:
bool
- changeCoordinates(self, verticesIndexes: Iterable[int], newCoordinates: Iterable[QgsPoint])¶
Changes the (X,Y,Z) coordinates values of the vertices with indexes in
vertices
indexes 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])¶
Changes the (X,Y) 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 values are in layer CRS.- 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 innewValues
- Parameters:
verticesIndexes (Iterable[int]) –
newValues (Iterable[float]) –
- checkConsistency(self, error: QgsMeshEditingError) bool ¶
Return
True
if the edited mesh is consistent- Parameters:
error (QgsMeshEditingError) –
- Return type:
bool
- childEvent(self, QChildEvent)¶
- connectNotify(self, QMetaMethod)¶
- createZValueDatasetGroup(self) QgsMeshDatasetGroup ¶
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.
- Return type:
- 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
- edgeIsClose(self, point: QgsPointXY, tolerance: float) Tuple[bool, int, int] ¶
Returns
True
if an edge of face is closest than the tolerance from thepoint
in triangular mesh coordinate Returns also the face index and the edge position infaceIndex
andedgePosition
- Parameters:
point (QgsPointXY) –
tolerance (float) –
- Return type:
Tuple[bool, int, int]
- extent(self) QgsRectangle ¶
Returns the extent of the edited mesh
- Return type:
- faceCanBeAdded(self, face: Iterable[int]) bool ¶
Returns
True
if aface
can 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 ¶
Returns
True
if face with indexfaceIndex
can be split- Parameters:
faceIndex (int) –
- Return type:
bool
- fixError(self, error: QgsMeshEditingError) bool ¶
Tries to fix the topological
error
in the mesh. ReturnsFalse
if the fix failsNew in version 3.28.
- Parameters:
error (QgsMeshEditingError) –
- 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 ¶
Initializes the mesh editor and returns first error if the internal native mesh has topological errors
- Return type:
- initializeWithErrorsFix(self) QgsMeshEditingError ¶
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
New in version 3.28.
- Return type:
- 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
- maximumVerticesPerFace(self) int ¶
Returns the maximum count of vertices per face that the mesh can support
- Return type:
int
- merge(self, vertexIndex1: int, vertexIndex2: int)¶
Merges faces separated by vertices with indexes
vertexIndex1
andvertexIndex2
- Parameters:
vertexIndex1 (int) –
vertexIndex2 (int) –
- meshEdited¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- receivers(self, PYQT_SIGNAL) int ¶
- reindex(self, renumbering: bool) bool ¶
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.- Parameters:
renumbering (bool) –
- Return type:
bool
- 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:
- removeVerticesFillHoles(self, verticesToRemoveIndexes: Iterable[int]) List[int] ¶
Removes vertices with indexes in the list
verticesToRemoveIndexes
in 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 ¶
Removes vertices with indexes in the list
verticesToRemoveIndexes
in 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:
- 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)¶
- validFacesCount(self) int ¶
Returns the count of valid faces, that is non void faces in the mesh
- Return type:
int
- validVerticesCount(self) int ¶
Returns the count of valid vertices, that is non void vertices in the mesh
- Return type:
int