QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
|
Class that makes edit operation on a mesh. More...
#include <qgsmesheditor.h>
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... | |
QgsMeshEditingError | addFaceWithNewVertices (const QList< int > &vertexIndexes, const QList< QgsMeshVertex > &newVertices) |
Adds a face formed by some vertices vertexIndexes to the mesh, returns topological errors if this operation fails (operation is not realized) The vertices are defined by verticesIndex that contains the index of already existing vertices or the value -1 if the vertex is not existing for now in the mesh. 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 considering 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 verticesIndexes 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 (QgsMeshEditingError &error) const |
Return true if the edited mesh is consistent. More... | |
QgsMeshDatasetGroup * | 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. 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) const |
Returns true if a face can be added to the mesh. More... | |
bool | faceCanBeAddedWithNewVertices (const QList< int > &verticesIndex, const QList< QgsMeshVertex > &newVertices) const |
Returns true if a face formed by some vertices can be added to the mesh. More... | |
bool | faceCanBeSplit (int faceIndex) const |
Returns true if face with index faceIndex can be split. More... | |
bool | fixError (const QgsMeshEditingError &error) |
Tries to fix the topological error in the mesh. 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 () |
Initializes the mesh editor and returns first error if the internal native mesh has topological errors. More... | |
QgsMeshEditingError | initializeWithErrorsFix () |
Initializes the mesh editor. More... | |
bool | isFaceGeometricallyCompatible (const QgsMeshFace &face) const |
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... | |
int | maximumVerticesPerFace () const |
Returns the maximum count of vertices per face that the mesh can support. 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... | |
QList< int > | removeVerticesFillHoles (const QList< int > &verticesToRemoveIndexes) |
Removes vertices with indexes in the list verticesToRemoveIndexes in the mesh the surrounding faces AND fills the freed space. More... | |
QgsMeshEditingError | removeVerticesWithoutFillHoles (const QList< int > &verticesToRemoveIndexes) |
Removes vertices with indexes in the list verticesToRemoveIndexes in the mesh removing the surrounding faces without filling the freed space. 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... | |
QgsTopologicalMesh & | topologicalMesh () |
Returns a reference to the topological mesh. More... | |
QgsTriangularMesh * | triangularMesh () |
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... | |
Class that makes edit operation on a mesh.
Definition at line 67 of file qgsmesheditor.h.
QgsMeshEditor::QgsMeshEditor | ( | QgsMeshLayer * | meshLayer | ) |
Constructor with a specified layer meshLayer.
Definition at line 31 of file qgsmesheditor.cpp.
QgsMeshEditor::QgsMeshEditor | ( | QgsMesh * | nativeMesh, |
QgsTriangularMesh * | triangularMesh, | ||
QObject * | parent = nullptr |
||
) |
Constructor with a specific mesh nativeMesh and an associatd triangular mesh triangularMesh.
Definition at line 44 of file qgsmesheditor.cpp.
|
default |
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 783 of file qgsmesheditor.cpp.
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 763 of file qgsmesheditor.cpp.
QgsMeshEditingError QgsMeshEditor::addFaceWithNewVertices | ( | const QList< int > & | vertexIndexes, |
const QList< QgsMeshVertex > & | newVertices | ||
) |
Adds a face formed by some vertices vertexIndexes to the mesh, returns topological errors if this operation fails (operation is not realized) The vertices are defined by verticesIndex that contains the index of already existing vertices or the value -1 if the vertex is not existing for now in the mesh.
The positions of new vertices are stored in newVertices sorted by their positions in the face.
Definition at line 788 of file qgsmesheditor.cpp.
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.
Definition at line 852 of file qgsmesheditor.cpp.
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.
Definition at line 809 of file qgsmesheditor.cpp.
void QgsMeshEditor::advancedEdit | ( | QgsMeshAdvancedEditing * | editing | ) |
Applies an advance editing on the edited mesh, see QgsMeshAdvancedEditing.
Definition at line 1018 of file qgsmesheditor.cpp.
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 648 of file qgsmesheditor.cpp.
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 considering 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
Definition at line 893 of file qgsmesheditor.cpp.
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 1013 of file qgsmesheditor.cpp.
void QgsMeshEditor::changeXYValues | ( | const QList< int > & | verticesIndexes, |
const QList< QgsPointXY > & | newValues | ||
) |
Changes the (X,Y) coordinates values of the vertices with indexes in verticesIndexes 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 1007 of file qgsmesheditor.cpp.
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 888 of file qgsmesheditor.cpp.
bool QgsMeshEditor::checkConsistency | ( | QgsMeshEditingError & | error | ) | const |
Return true
if the edited mesh is consistent.
Definition at line 537 of file qgsmesheditor.cpp.
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 53 of file qgsmesheditor.cpp.
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 635 of file qgsmesheditor.cpp.
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 562 of file qgsmesheditor.cpp.
QgsRectangle QgsMeshEditor::extent | ( | ) | const |
Returns the extent of the edited mesh.
Definition at line 1214 of file qgsmesheditor.cpp.
bool QgsMeshEditor::faceCanBeAdded | ( | const QgsMeshFace & | face | ) | const |
Returns true
if a face can be added to the mesh.
Definition at line 283 of file qgsmesheditor.cpp.
bool QgsMeshEditor::faceCanBeAddedWithNewVertices | ( | const QList< int > & | verticesIndex, |
const QList< QgsMeshVertex > & | newVertices | ||
) | const |
Returns true
if a face formed by some vertices can be added to the mesh.
The vertices are defined by verticesIndex that contains the index of already existing vertices or the value -1 if the vertex is not existing for now in the mesh. The positions of new vertices are stored in newVertices sorted by their positions in the face.
Definition at line 308 of file qgsmesheditor.cpp.
bool QgsMeshEditor::faceCanBeSplit | ( | int | faceIndex | ) | const |
Returns true
if face with index faceIndex can be split.
Definition at line 661 of file qgsmesheditor.cpp.
bool QgsMeshEditor::fixError | ( | const QgsMeshEditingError & | error | ) |
Tries to fix the topological error in the mesh.
Returns false
if the fix fails
Definition at line 106 of file qgsmesheditor.cpp.
void QgsMeshEditor::flipEdge | ( | int | vertexIndex1, |
int | vertexIndex2 | ||
) |
Flips edge (vertexIndex1, vertexIndex2)
Definition at line 640 of file qgsmesheditor.cpp.
QList< int > QgsMeshEditor::freeVerticesIndexes | ( | ) | const |
Returns all the free vertices indexes.
Definition at line 1253 of file qgsmesheditor.cpp.
QgsMeshEditingError QgsMeshEditor::initialize | ( | ) |
Initializes the mesh editor and returns first error if the internal native mesh has topological errors.
Definition at line 62 of file qgsmesheditor.cpp.
QgsMeshEditingError QgsMeshEditor::initializeWithErrorsFix | ( | ) |
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
Definition at line 87 of file qgsmesheditor.cpp.
bool QgsMeshEditor::isFaceGeometricallyCompatible | ( | const QgsMeshFace & | face | ) | const |
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 270 of file qgsmesheditor.cpp.
bool QgsMeshEditor::isModified | ( | ) | const |
Returns whether the mesh has been modified.
Definition at line 1219 of file qgsmesheditor.cpp.
bool QgsMeshEditor::isVertexFree | ( | int | vertexIndex | ) | const |
Returns whether the vertex with index vertexIndex is a free vertex.
Definition at line 1263 of file qgsmesheditor.cpp.
bool QgsMeshEditor::isVertexOnBoundary | ( | int | vertexIndex | ) | const |
Returns whether the vertex with index vertexIndex is on a boundary.
Definition at line 1258 of file qgsmesheditor.cpp.
int QgsMeshEditor::maximumVerticesPerFace | ( | ) | const |
Returns the maximum count of vertices per face that the mesh can support.
Definition at line 619 of file qgsmesheditor.cpp.
void QgsMeshEditor::merge | ( | int | vertexIndex1, |
int | vertexIndex2 | ||
) |
Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2.
Definition at line 653 of file qgsmesheditor.cpp.
|
signal |
Emitted when the mesh is edited.
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 1227 of file qgsmesheditor.cpp.
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 624 of file qgsmesheditor.cpp.
QList< int > QgsMeshEditor::removeVerticesFillHoles | ( | const QList< int > & | verticesToRemoveIndexes | ) |
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.
Definition at line 879 of file qgsmesheditor.cpp.
QgsMeshEditingError QgsMeshEditor::removeVerticesWithoutFillHoles | ( | const QList< int > & | verticesToRemoveIndexes | ) |
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
Definition at line 857 of file qgsmesheditor.cpp.
void QgsMeshEditor::resetTriangularMesh | ( | QgsTriangularMesh * | triangularMesh | ) |
Resets the triangular mesh.
Definition at line 149 of file qgsmesheditor.cpp.
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 666 of file qgsmesheditor.cpp.
void QgsMeshEditor::stopEditing | ( | ) |
Stops editing.
Definition at line 1023 of file qgsmesheditor.cpp.
QgsTopologicalMesh & QgsMeshEditor::topologicalMesh | ( | ) |
Returns a reference to the topological mesh.
Definition at line 1273 of file qgsmesheditor.cpp.
QgsTriangularMesh * QgsMeshEditor::triangularMesh | ( | ) |
Returns a pointer to the triangular mesh.
Definition at line 1278 of file qgsmesheditor.cpp.
int QgsMeshEditor::validFacesCount | ( | ) | const |
Returns the count of valid faces, that is non void faces in the mesh.
Definition at line 609 of file qgsmesheditor.cpp.
int QgsMeshEditor::validVerticesCount | ( | ) | const |
Returns the count of valid vertices, that is non void vertices in the mesh.
Definition at line 614 of file qgsmesheditor.cpp.
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 1268 of file qgsmesheditor.cpp.
|
friend |
Definition at line 357 of file qgsmesheditor.h.
|
friend |
Definition at line 354 of file qgsmesheditor.h.
|
friend |
Definition at line 367 of file qgsmesheditor.h.
|
friend |
Definition at line 362 of file qgsmesheditor.h.
|
friend |
Definition at line 361 of file qgsmesheditor.h.
|
friend |
Definition at line 360 of file qgsmesheditor.h.
|
friend |
Definition at line 363 of file qgsmesheditor.h.
|
friend |
Definition at line 364 of file qgsmesheditor.h.
|
friend |
Definition at line 353 of file qgsmesheditor.h.
|
friend |
Definition at line 358 of file qgsmesheditor.h.
|
friend |
Definition at line 356 of file qgsmesheditor.h.
|
friend |
Definition at line 355 of file qgsmesheditor.h.
|
friend |
Definition at line 359 of file qgsmesheditor.h.
|
friend |
Definition at line 365 of file qgsmesheditor.h.
|
friend |
Definition at line 352 of file qgsmesheditor.h.