Class: QgsTopologicalMesh¶
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
Added in version 3.22.
Methods
Adds faces topologicFaces to the topologic mesh. |
|
Adds a free vertex in the face, that is a vertex that is not included or linked with any faces. |
|
Adds a vertex in the face with index faceIndex. |
|
Applies the changes |
|
Returns |
|
Returns |
|
Changes the (X,Y) values of the vertices with indexes in vertices indexes with the values in newValues |
|
Changes the Z values of the vertices with indexes in vertices indexes with the values in newValues |
|
Checks the consistency of the topological mesh and return |
|
Check if Delaunay condition holds for given edge returns |
|
Returns |
|
Returns the indexes of faces that are around the vertex with index vertexIndex |
|
Returns whether the faces can be added to the mesh |
|
Returns whether faces with index in faceIndexes can be removed The method an error object with type |
|
Returns the index of the first face linked, returns -1 if it is a free vertex or out of range index |
|
Flips edge (vertexIndex1, vertexIndex2) The method returns a instance of the class QgsTopologicalMesh.Change that can be used to reverse or reapply the operation. |
|
Returns a list of vertices are not linked to any faces |
|
Inserts a vertex in the edge of face with index faceIndex at position . |
|
Returns whether the vertex is a free vertex |
|
Returns whether the vertex is on a boundary |
|
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. |
|
Returns a pointer to the wrapped mesh |
|
Returns the indexes of neighbor faces of the face with index faceIndex |
|
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. |
|
Removes faces with index in faceIndexes. |
|
Removes the vertex with index vertexIndex. |
|
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. |
|
Renumbers the indexes of vertices and faces using the Reverse CutHill McKee Algorithm |
|
Reverses the changes |
|
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. |
Static Methods
Checks the topology of the mesh mesh, if error occurs, this mesh can't be edited |
|
Checks the topology of the face and sets it counter clockwise if necessary |
|
Creates a topologicaly consistent mesh with mesh, this static method modifies mesh to be topological consistent and return a |
|
Returns vertex position in face |
- class qgis.core.QgsTopologicalMesh[source]¶
Bases:
object
- class Changes[source]¶
Bases:
object
Contains topological differences between two states of a topological mesh, only accessible from the
QgsTopologicalMesh
class.Added in version 3.22.
- addedVertices(self) List[QgsPoint] ¶
Returns the added vertices with this changes
- Return type:
List[QgsPoint]
- changedCoordinatesVerticesIndexes(self) List[int] ¶
Returns the indexes of vertices that have changed coordinates
- Return type:
List[int]
- isEmpty(self) bool [source]¶
Returns whether changes are empty, that there is nothing to change
- Return type:
bool
- nativeFacesIndexesGeometryChanged(self) List[int] ¶
Returns a list of the native face indexes that have a geometry changed
- Return type:
List[int]
- newVerticesXYValues(self) List[QgsPointXY] ¶
Returns the new (X,Y) values of vertices that have changed their coordinates
- Return type:
List[QgsPointXY]
- newVerticesZValues(self) List[float] ¶
Returns the new Z values of vertices that have changed their coordinates
- Return type:
List[float]
- oldVerticesXYValues(self) List[QgsPointXY] ¶
Returns the old (X,Y) values of vertices that have changed their coordinates
- Return type:
List[QgsPointXY]
- removedFaceIndexes(self) List[int] ¶
Returns the indexes of the faces that are removed with this changes
- Return type:
List[int]
- verticesToRemoveIndexes(self) List[int] ¶
Returns the indexes of vertices to remove
- Return type:
List[int]
- class TopologicalFaces[source]¶
Bases:
object
Contains independent faces and topological information about these faces.
This class supports unique shared vertices between faces.
Added in version 3.22.
- addFaces(self, topologicFaces: QgsTopologicalMesh.TopologicalFaces) QgsTopologicalMesh.Changes [source]¶
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.- Parameters:
topologicFaces (QgsTopologicalMesh.TopologicalFaces)
- Return type:
- addFreeVertex(self, vertex: QgsPoint) QgsTopologicalMesh.Changes [source]¶
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.- Parameters:
vertex (QgsPoint)
- Return type:
- addVertexInFace(self, faceIndex: int, vertex: QgsPoint) QgsTopologicalMesh.Changes [source]¶
Adds a
vertex
in the face with indexfaceIndex
. 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.- Parameters:
faceIndex (int)
vertex (QgsPoint)
- Return type:
- applyChanges(self, changes: QgsTopologicalMesh.Changes)[source]¶
Applies the changes
- Parameters:
changes (QgsTopologicalMesh.Changes)
- canBeMerged(self, vertexIndex1: int, vertexIndex2: int) bool [source]¶
Returns
True
if faces separated by vertices with indexesvertexIndex1
andvertexIndex2
can be merged- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- Return type:
bool
- canBeSplit(self, faceIndex: int) bool [source]¶
Returns
True
if face with indexfaceIndex
can be split- Parameters:
faceIndex (int)
- Return type:
bool
- changeXYValue(self, verticesIndexes: Iterable[int], newValues: Iterable[QgsPointXY]) QgsTopologicalMesh.Changes [source]¶
Changes the (X,Y) values of the vertices with indexes in
vertices
indexes with the values innewValues
- Parameters:
verticesIndexes (Iterable[int])
newValues (Iterable[QgsPointXY])
- Return type:
- changeZValue(self, verticesIndexes: Iterable[int], newValues: Iterable[float]) QgsTopologicalMesh.Changes [source]¶
Changes the Z values of the vertices with indexes in
vertices
indexes with the values innewValues
- Parameters:
verticesIndexes (Iterable[int])
newValues (Iterable[float])
- Return type:
- checkConsistency(self) QgsMeshEditingError [source]¶
Checks the consistency of the topological mesh and return
False
if there is a consistency issue- Return type:
- static checkTopology(mesh: QgsMesh, maxVerticesPerFace: int) QgsMeshEditingError [source]¶
Checks the topology of the mesh
mesh
, if error occurs, this mesh can’t be edited- Parameters:
mesh (QgsMesh)
maxVerticesPerFace (int)
- Return type:
- static counterClockwiseFaces(face: Iterable[int], mesh: QgsMesh | None) QgsMeshEditingError [source]¶
Checks the topology of the face and sets it counter clockwise if necessary
- Parameters:
face (Iterable[int])
mesh (Optional[QgsMesh])
- Return type:
- static createTopologicalMesh(mesh: QgsMesh | None, maxVerticesPerFace: int, error: QgsMeshEditingError) QgsTopologicalMesh [source]¶
Creates a topologicaly consistent mesh with
mesh
, this static method modifiesmesh
to be topological consistent and return aQgsTopologicalMesh
instance that contains and handles this mesh (does not take ownership).- Parameters:
mesh (Optional[QgsMesh])
maxVerticesPerFace (int)
error (QgsMeshEditingError)
- Return type:
- delaunayConditionForEdge(self, vertexIndex1: int, vertexIndex2: int) bool [source]¶
Check if Delaunay condition holds for given edge returns
True
if delaunay condition holdsFalse
otherwiseAdded in version 3.42.
- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- Return type:
bool
- edgeCanBeFlipped(self, vertexIndex1: int, vertexIndex2: int) bool [source]¶
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
- facesAroundVertex(self, vertexIndex: int) List[int] ¶
Returns the indexes of faces that are around the vertex with index
vertexIndex
- Parameters:
vertexIndex (int)
- Return type:
List[int]
- facesCanBeAdded(self, topologicalFaces: QgsTopologicalMesh.TopologicalFaces) QgsMeshEditingError [source]¶
Returns whether the faces can be added to the mesh
- Parameters:
topologicalFaces (QgsTopologicalMesh.TopologicalFaces)
- Return type:
- facesCanBeRemoved(self, facesIndexes: Iterable[int]) QgsMeshEditingError [source]¶
Returns whether faces with index in
faceIndexes
can be removed The method an error object with typeQgsMeshEditingError
.NoError if the faces can be removed, otherwise returns the corresponding error- Parameters:
facesIndexes (Iterable[int])
- Return type:
- firstFaceLinked(self, vertexIndex: int) int [source]¶
Returns the index of the first face linked, returns -1 if it is a free vertex or out of range index
- Parameters:
vertexIndex (int)
- Return type:
int
- flipEdge(self, vertexIndex1: int, vertexIndex2: int) QgsTopologicalMesh.Changes [source]¶
Flips edge (
vertexIndex1
,vertexIndex2
) The method returns a instance of the class QgsTopologicalMesh.Change that can be used to reverse or reapply the operation.- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- Return type:
- freeVerticesIndexes(self) List[int] ¶
Returns a list of vertices are not linked to any faces
- Return type:
List[int]
- insertVertexInFacesEdge(self, faceIndex: int, position: int, vertex: QgsPoint) QgsTopologicalMesh.Changes [source]¶
Inserts a
vertex
in the edge of face with indexfaceIndex
atposition
. The faces that are on each side of the edge are removed and replaced by new faces constructed by a triangulation.- Parameters:
faceIndex (int)
position (int)
vertex (QgsPoint)
- Return type:
- isVertexFree(self, vertexIndex: int) bool [source]¶
Returns whether the vertex is a free vertex
- Parameters:
vertexIndex (int)
- Return type:
bool
- isVertexOnBoundary(self, vertexIndex: int) bool [source]¶
Returns whether the vertex is on a boundary
- Parameters:
vertexIndex (int)
- Return type:
bool
- merge(self, vertexIndex1: int, vertexIndex2: int) QgsTopologicalMesh.Changes [source]¶
Merges faces separated by vertices with indexes
vertexIndex1
andvertexIndex2
The method returns a instance of the class QgsTopologicalMesh.Change that can be used to reverse or reapply the operation.- Parameters:
vertexIndex1 (int)
vertexIndex2 (int)
- Return type:
- mesh(self) QgsMesh | None [source]¶
Returns a pointer to the wrapped mesh
- Return type:
Optional[QgsMesh]
- neighborsOfFace(self, faceIndex: int) List[int] ¶
Returns the indexes of neighbor faces of the face with index
faceIndex
- Parameters:
faceIndex (int)
- Return type:
List[int]
- reindex(self)[source]¶
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.
- removeFaces(self, facesIndexes: Iterable[int]) QgsTopologicalMesh.Changes [source]¶
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.- Parameters:
facesIndexes (Iterable[int])
- Return type:
- removeVertexFillHole(self, vertexIndex: int) QgsTopologicalMesh.Changes [source]¶
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.- Parameters:
vertexIndex (int)
- Return type:
- removeVertices(self, vertices: Iterable[int]) QgsTopologicalMesh.Changes [source]¶
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.- Parameters:
vertices (Iterable[int])
- Return type:
- renumber(self) bool [source]¶
Renumbers the indexes of vertices and faces using the Reverse CutHill McKee Algorithm
- Return type:
bool
- reverseChanges(self, changes: QgsTopologicalMesh.Changes)[source]¶
Reverses the changes
- Parameters:
changes (QgsTopologicalMesh.Changes)
- splitFace(self, faceIndex: int) QgsTopologicalMesh.Changes [source]¶
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.- Parameters:
faceIndex (int)
- Return type: