16#ifndef QGSTOPOLOGICALMESH_H
17#define QGSTOPOLOGICALMESH_H
24template CORE_EXPORT QVector<int>
SIP_SKIP;
25template CORE_EXPORT QList<int>
SIP_SKIP;
26template CORE_EXPORT QVector<QVector<int>>
SIP_SKIP;
67 QVector<QgsMeshFace>
meshFaces()
const {
return mFaces;}
73 QVector<FaceNeighbors> facesNeighborhood()
const;
76 int vertexToFace(
int vertexIndex )
const;
79 QVector<QgsMeshFace> mFaces;
80 QVector<FaceNeighbors> mFacesNeighborhood;
81 QMultiHash<int, int> mVerticesToFace;
82 QList<int> mBoundaries;
101 QVector<QgsMeshFace> addedFaces()
const;
104 QVector<QgsMeshFace> removedFaces()
const;
107 QList<int> removedFaceIndexes()
const;
110 QVector<QgsMeshVertex> addedVertices()
const;
113 QList<int> verticesToRemoveIndexes()
const;
116 QList<int> changedCoordinatesVerticesIndexes()
const;
119 QList<double> newVerticesZValues()
const;
122 QList<QgsPointXY> newVerticesXYValues()
const;
125 QList<QgsPointXY> oldVerticesXYValues()
const;
128 QList<int> nativeFacesIndexesGeometryChanged()
const;
131 bool isEmpty()
const;
134 int mAddedFacesFirstIndex = 0;
160 int addedFaceIndexInMesh(
int internalIndex )
const;
161 int removedFaceIndexInMesh(
int internalIndex )
const;
238 bool canBeMerged(
int vertexIndex1,
int vertexIndex2 )
const;
338 const QVector<QgsMeshFace> &faces,
339 QVector<int> *globalVertexToFace,
341 bool allowUniqueSharedVertex );
344 QSet<int> concernedFacesBy(
const QList<int> &faceIndexes )
const;
347 void referenceAsFreeVertex(
int vertexIndex );
349 void dereferenceAsFreeVertex(
int vertexIndex );
355 bool eitherSideFacesAndVertices(
int vertexIndex1,
359 int &neighborVertex1InFace1,
360 int &neighborVertex1InFace2,
361 int &neighborVertex2inFace1,
362 int &neighborVertex2inFace2 )
const;
364 bool renumberVertices( QVector<int> &oldToNewIndex )
const;
365 bool renumberFaces( QVector<int> &oldToNewIndex )
const;
369 QVector<int> mVertexToFace;
370 QVector<FaceNeighbors> mFacesNeighborhood;
372 QSet<int> mFreeVertices;
374 int mMaximumVerticesPerFace = 0;
409 int turnCounterClockwise()
const;
412 int turnClockwise()
const;
415 int currentFaceIndex()
const;
421 bool goBoundaryClockwise()
const;
424 bool goBoundaryCounterClockwise()
const;
427 int oppositeVertexClockwise()
const;
430 int oppositeVertexCounterClockwise()
const;
433 bool isValid()
const;
436 QList<int> facesAround()
const;
442 const QVector<QgsMeshFace> mFaces;
443 const QVector<QgsTopologicalMesh::FaceNeighbors> mFacesNeighborhood;
444 const int mVertexIndex = -1;
445 mutable int mCurrentFace = -1;
446 mutable int mLastValidFace = -1;
447 bool mIsValid =
false;
448 mutable int mDegree = -1;
450 int positionInCurrentFace()
const;
Class that represents an error during mesh editing.
Convenient class that turn around a vertex and provide information about faces and vertices.
Point geometry type, with support for z-dimension and m-values.
Class that contains topological differences between two states of a topological mesh,...
QList< int > mChangeCoordinateVerticesIndexes
QList< int > mVerticesToFaceRemoved
QVector< FaceNeighbors > mFacesNeighborhoodToRemove
QList< QgsPointXY > mNewXYValues
QList< QgsMeshVertex > mRemovedVertices
QList< std::array< int, 4 > > mNeighborhoodChanges
QList< int > mVerticesToRemoveIndexes
QList< int > mNativeFacesIndexesGeometryChanged
QVector< QgsMeshFace > mFacesToAdd
QVector< FaceNeighbors > mFacesNeighborhoodToAdd
QList< std::array< int, 3 > > mVerticesToFaceChanges
QList< QgsPointXY > mOldXYValues
QList< double > mNewZValues
QVector< QgsMeshVertex > mVerticesToAdd
QVector< int > mVertexToFaceToAdd
QList< int > mFaceIndexesToRemove
QVector< QgsMeshFace > mFacesToRemove
QList< double > mOldZValues
Class that contains independent faces an topological information about this faces.
QVector< QgsMeshFace > meshFaces() const
Returns faces.
Class that wraps a QgsMesh to ensure the consistency of the mesh during editing and help to access to...
static QgsMeshEditingError checkTopologyOfVerticesAsFace(const QVector< QgsMeshVertex > &vertices, bool &clockwise)
Checks the topology of the vertices as they are contained in a face and returns indication on directi...
Changes changeZValue(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.
static QgsTopologicalMesh createTopologicalMesh(QgsMesh *mesh, int maxVerticesPerFace, QgsMeshEditingError &error)
Creates a topologicaly consistent mesh with mesh, this static method modifies mesh to be topological ...
bool isVertexFree(int vertexIndex) const
Returns whether the vertex is a free vertex.
static QgsMeshEditingError counterClockwiseFaces(QgsMeshFace &face, QgsMesh *mesh)
Checks the topology of the face and sets it counter clockwise if necessary.
Changes removeVertexFillHole(int vertexIndex)
Removes the vertex with index vertexIndex.
static QgsMeshEditingError checkTopology(const QgsMesh &mesh, int maxVerticesPerFace)
Checks the topology of the mesh mesh, if error occurs, this mesh can't be edited.
void applyChanges(const Changes &changes)
Applies the changes.
int firstFaceLinked(int vertexIndex) const
Returns the index of the first face linked, returns -1 if it is a free vertex or out of range index.
QgsMeshEditingError checkConsistency() const
Checks the consistency of the topological mesh and return false if there is a consistency issue.
Changes removeVertices(const QList< int > &vertices)
Removes all the vertices with index in the list vertices If vertices in linked with faces,...
Changes changeXYValue(const QList< int > &verticesIndexes, const QList< QgsPointXY > &newValues)
Changes the (X,Y) values of the vertices with indexes in vertices indexes with the values in newValue...
void reindex()
Reindexes faces and vertices, after this operation, the topological mesh can't be edited anymore and ...
QVector< int > neighborsOfFace(int faceIndex) const
Returns the indexes of neighbor faces of the face with index faceIndex.
QgsMeshEditingError facesCanBeAdded(const TopologicalFaces &topologicalFaces) const
Returns whether the faces can be added to the mesh.
bool renumber()
Renumbers the indexes of vertices and faces using the Reverse CutHill McKee Algorithm.
Changes flipEdge(int vertexIndex1, int vertexIndex2)
Flips edge (vertexIndex1, vertexIndex2) The method returns a instance of the class QgsTopologicalMesh...
QgsMeshEditingError facesCanBeRemoved(const QList< int > &facesIndexes)
Returns whether faces with index in faceIndexes can be removed/ The method an error object with type ...
QVector< int > FaceNeighbors
void reverseChanges(const Changes &changes)
Reverses the changes.
Changes addFaces(const TopologicalFaces &topologicFaces)
Adds faces topologicFaces to the topologic mesh.
Changes merge(int vertexIndex1, int vertexIndex2)
Merges faces separated by vertices with indexes vertexIndex1 and vertexIndex2 The method returns a in...
Changes removeFaces(const QList< int > &facesIndexes)
Removes faces with index in faceIndexes.
QList< int > freeVerticesIndexes() const
Returns a list of vertices are not linked to any faces.
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)
Changes addVertexInFace(int faceIndex, const QgsMeshVertex &vertex)
Adds a vertex in the face with index faceIndex.
bool canBeMerged(int vertexIndex1, int vertexIndex2) const
Returns true if faces separated by vertices with indexes vertexIndex1 and vertexIndex2 can be merged.
QList< int > facesAroundVertex(int vertexIndex) const
Returns the indexes of faces that are around the vertex with index vertexIndex.
bool canBeSplit(int faceIndex) const
Returns true if face with index faceIndex can be split.
Changes addFreeVertex(const QgsMeshVertex &vertex)
Adds a free vertex in the face, that is a vertex tha tis not included or linked with any faces.
Changes insertVertexInFacesEdge(int faceIndex, int position, const QgsMeshVertex &vertex)
Inserts a vertex in the edge of face with index faceIndex at position .
QgsMesh * mesh() const
Returns a pointer to the wrapped mesh.
bool isVertexOnBoundary(int vertexIndex) const
Returns whether the vertex is on a boundary.
Changes splitFace(int faceIndex)
Splits face with index faceIndex The method returns a instance of the class QgsTopologicalMesh::Chang...
static TopologicalFaces createNewTopologicalFaces(const QVector< QgsMeshFace > &faces, bool uniqueSharedVertexAllowed, QgsMeshEditingError &error)
Creates new topological faces that are not yet included in the mesh.
QgsMeshVertexCirculator vertexCirculator(int vertexIndex) const
Returns a vertex circulator linked to this mesh around the vertex with index vertexIndex.
QVector< int > QgsMeshFace
List of vertex indexes.
Mesh - vertices, edges and faces.