QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
QgsMeshTransformVerticesByExpression Class Reference

Transforms vertices of a mesh by expression. More...

#include <qgsmeshadvancedediting.h>

Inheritance diagram for QgsMeshTransformVerticesByExpression:

Public Member Functions

 QgsMeshTransformVerticesByExpression ()=default
bool calculate (QgsMeshLayer *layer, QgsProject *project=nullptr)
 Calculates the transformed vertices of the mesh layer, returns false if this leads to topological or geometrical errors.
void setExpressions (const QString &expressionX, const QString &expressionY, const QString &expressionZ)
 Sets the expressions for the coordinates transformation.
void setZFromTerrain (bool enable)
 Sets if Z values for vertices should be obtained from project terrain, instead of expression.
QString text () const override
 Returns a short text string describing what this advanced edit does. Default implementation return a void string.
QgsMeshVertex transformedVertex (QgsMeshLayer *layer, int vertexIndex) const
 Returns the transformed vertex from its index vertexIndex for the mesh layer.
Public Member Functions inherited from QgsMeshAdvancedEditing
 QgsMeshAdvancedEditing ()
virtual ~QgsMeshAdvancedEditing ()
void clear ()
 Removes all data provided to the editing or created by the editing.
virtual bool isFinished () const
 Returns whether the advanced edit is finished, if not, this edit has to be applied again with QgsMeshEditor::advancedEdit() until is finished returns true.
QString message () const
 Returns a message that can be provided by the advanced editing when applying is done.
void setInputFaces (const QList< int > faceIndexes)
 Sets the input faces indexes that will be used for the editing.
void setInputVertices (const QList< int > verticesIndexes)
 Sets the input vertices indexes that will be used for the editing.
Public Member Functions inherited from QgsTopologicalMesh::Changes
QVector< QgsMeshFaceaddedFaces () const
 Returns the face that are added with this changes.
QVector< QgsMeshVertexaddedVertices () const
 Returns the added vertices with this changes.
QList< int > changedCoordinatesVerticesIndexes () const
 Returns the indexes of vertices that have changed coordinates.
bool isEmpty () const
 Returns whether changes are empty, that there is nothing to change.
QList< int > nativeFacesIndexesGeometryChanged () const
 Returns a list of the native face indexes that have a geometry changed.
QList< QgsPointXYnewVerticesXYValues () const
 Returns the new (X,Y) values of vertices that have changed their coordinates.
QList< double > newVerticesZValues () const
 Returns the new Z values of vertices that have changed their coordinates.
QList< QgsPointXYoldVerticesXYValues () const
 Returns the old (X,Y) values of vertices that have changed their coordinates.
QList< int > removedFaceIndexes () const
 Returns the indexes of the faces that are removed with this changes.
QVector< QgsMeshFaceremovedFaces () const
 Returns the faces that are removed with this changes.
QList< int > verticesToRemoveIndexes () const
 Returns the indexes of vertices to remove.

Friends

class TestQgsMeshEditor

Additional Inherited Members

Protected Member Functions inherited from QgsTopologicalMesh::Changes
void clearChanges ()
 Clears all changes.
Protected Attributes inherited from QgsMeshAdvancedEditing
QList< int > mInputFaces
QList< int > mInputVertices
bool mIsFinished = false
QString mMessage
Protected Attributes inherited from QgsTopologicalMesh::Changes
int mAddedFacesFirstIndex = 0
QList< int > mChangeCoordinateVerticesIndexes
QList< int > mFaceIndexesToRemove
QVector< FaceNeighborsmFacesNeighborhoodToAdd
QVector< FaceNeighborsmFacesNeighborhoodToRemove
QVector< QgsMeshFacemFacesToAdd
QVector< QgsMeshFacemFacesToRemove
QList< int > mNativeFacesIndexesGeometryChanged
QList< std::array< int, 4 > > mNeighborhoodChanges
QList< QgsPointXYmNewXYValues
QList< double > mNewZValues
QList< QgsPointXYmOldXYValues
QList< double > mOldZValues
QList< QgsMeshVertexmRemovedVertices
QVector< int > mVertexToFaceToAdd
QVector< QgsMeshVertexmVerticesToAdd
QList< std::array< int, 3 > > mVerticesToFaceChanges
QList< int > mVerticesToFaceRemoved
QList< int > mVerticesToRemoveIndexes

Detailed Description

Transforms vertices of a mesh by expression.

Each coordinates are associated with an expression that can be defined with function returning the current coordinates (see setExpressions()):

  • $vertex_x
  • $vertex_y
  • $vertex_z

Example: Transposing a mesh and translate following axe X with a distance of 50 and increase the level of the mesh with an height of 80 when previous X coordinate is under 100 and de crease the level of 150 when X is under 100:

expressionX: "$vertex_y + 50" expressionY: "$vertex_x" expressionZ: "if( $vertex_x <= 100 , $vertex_z + 80 , $vertex_z - 150)"

Since
QGIS 3.22

Definition at line 162 of file qgsmeshadvancedediting.h.

Constructor & Destructor Documentation

◆ QgsMeshTransformVerticesByExpression()

QgsMeshTransformVerticesByExpression::QgsMeshTransformVerticesByExpression ( )
default

Member Function Documentation

◆ calculate()

bool QgsMeshTransformVerticesByExpression::calculate ( QgsMeshLayer * layer,
QgsProject * project = nullptr )

Calculates the transformed vertices of the mesh layer, returns false if this leads to topological or geometrical errors.

The mesh layer must be in edit mode.

Note
This method does not apply new vertices to the mesh layer but only stores the calculated transformation that can be applied later with QgsMeshEditor.advancedEdit()
Parameters
layer
projectQgsProject if it is necessary for the calculation ( for example with
See also
setZFromTerrain() )
Since
QGIS 3.44

Definition at line 614 of file qgsmeshadvancedediting.cpp.

◆ setExpressions()

void QgsMeshTransformVerticesByExpression::setExpressions ( const QString & expressionX,
const QString & expressionY,
const QString & expressionZ )

Sets the expressions for the coordinates transformation.

Note
Expressions are optional for each coordinate, the coordinate will not be transformed if the string is void.

Definition at line 807 of file qgsmeshadvancedediting.cpp.

◆ setZFromTerrain()

void QgsMeshTransformVerticesByExpression::setZFromTerrain ( bool enable)

Sets if Z values for vertices should be obtained from project terrain, instead of expression.

Note
If enable is True, the Z value of the vertex will be obtained from the terrain of the project. The optional parameter project is necessary for function calculate (
See also
calculate() ).
Parameters
enable
Since
QGIS 3.44

Definition at line 847 of file qgsmeshadvancedediting.cpp.

◆ text()

QString QgsMeshTransformVerticesByExpression::text ( ) const
overridevirtual

Returns a short text string describing what this advanced edit does. Default implementation return a void string.

Reimplemented from QgsMeshAdvancedEditing.

Definition at line 802 of file qgsmeshadvancedediting.cpp.

◆ transformedVertex()

QgsMeshVertex QgsMeshTransformVerticesByExpression::transformedVertex ( QgsMeshLayer * layer,
int vertexIndex ) const

Returns the transformed vertex from its index vertexIndex for the mesh layer.

If layer is not the same than the one used to make the calculation, this will create an undefined behavior

Definition at line 823 of file qgsmeshadvancedediting.cpp.

◆ TestQgsMeshEditor

friend class TestQgsMeshEditor
friend

Definition at line 217 of file qgsmeshadvancedediting.h.


The documentation for this class was generated from the following files: