Skip to content

Commit

Permalink
Force mesh by polylines (#44962)
Browse files Browse the repository at this point in the history
[mesh] [feature] allow modify mesh frame elevation by force/break lines
  • Loading branch information
vcloarec committed Sep 9, 2021
1 parent a7586e9 commit 4601394
Show file tree
Hide file tree
Showing 21 changed files with 2,524 additions and 40 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -928,6 +928,7 @@
<file>themes/default/mActionNewMeshLayer.svg</file>
<file>themes/default/mActionMeshTransformByExpression.svg</file>
<file>themes/default/mIconVertexCoordinates.svg</file>
<file>themes/default/mActionMeshEditForceByVectorLines.svg</file>
<file>themes/default/mIconGeometryCollectionLayer.svg</file>
<file>themes/default/mIconGps.svg</file>
<file>themes/default/mActionNewGpx.svg</file>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions python/core/auto_generated/mesh/qgsmeshadvancedediting.sip.in
Expand Up @@ -50,6 +50,12 @@ Returns a message that can be provided by the advanced editing when applying is
void clear();
%Docstring
Removes all data provided to the editing or created by the editing
%End

virtual bool isFinished() const;
%Docstring
Returns whether the advanced edit is finished,
if not, tis edit has to be applied again with :py:func:`QgsMeshEditor.advancedEdit()` until is finished returns ``True``
%End

protected:
Expand Down
6 changes: 6 additions & 0 deletions python/core/auto_generated/mesh/qgsmesheditor.sip.in
Expand Up @@ -189,6 +189,12 @@ Returns whether the vertex with index ``vertexIndex`` is a free vertex
bool checkConsistency() const;
%Docstring
Return ``True`` if the edited mesh is consistent
%End

bool edgeIsClose( QgsPointXY point, double tolerance, int &faceIndex, int &edgePosition );
%Docstring
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``
%End

signals:
Expand Down
112 changes: 112 additions & 0 deletions python/core/auto_generated/mesh/qgsmeshforcebypolylines.sip.in
@@ -0,0 +1,112 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/mesh/qgsmeshforcebypolylines.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsMeshEditForceByLine : QgsMeshAdvancedEditing
{
%Docstring(signature="appended")

Class derived from :py:class:`QgsMeshAdvancedEditing` that forces mesh based on a line

Forcing lines consist of line that the faces are forced to follow, that is edges of encountered faces have to be on theses lines.

Caller of this class has to set the line with :py:func:`~setInputLine` before applying the edition with :py:func:`QgsMeshEditor.advancedEdit()`

Other option has also to be set before calling :py:func:`QgsMeshEditor.advancedEdit()`

.. versionadded:: 3.22
%End

%TypeHeaderCode
#include "qgsmeshforcebypolylines.h"
%End
public:

QgsMeshEditForceByLine();
%Docstring
Constructor
%End

void setInputLine( const QgsPoint &pt1, const QgsPoint &pt2, double tolerance, bool newVertexOnIntersection );
%Docstring
Sets the input forcing line in rendering coordinates
%End

void setTolerance( double tolerance );
%Docstring
Sets the tolerance in redering coordinate system unit
%End

void setAddVertexOnIntersection( bool addVertex );
%Docstring
Sets whether vertices will be added when the lines will intersect internal edges of faces, default is ``False``
%End

void setDefaultZValue( double defaultZValue );
%Docstring
Sets the default value of Z coordinate to use for new vertices, this value will be used if the Z value
%End

void setInterpolateZValueOnMesh( bool interpolateZValueOnMesh );
%Docstring
Sets whether the new created vertices will have their value interpolated from the existing mesh.
If not, Z value will be interpolated from the lines,
in case these line are not 3D, the default value will be used (:py:func:`setDefaultZValue`)
%End

};



class QgsMeshEditForceByPolylines : QgsMeshEditForceByLine
{
%Docstring(signature="appended")

Class derived from QgsMeshEditForceByLine that forces mesh based on polyline.

Forcing lines consist of line that the faces are forced to follow, that is edges of encountered faces have to be on theses lines.

Caller of this class has to add the lines from :py:class:`QgsGeometry` instances with :py:func:`~QgsMeshEditForceByLine.addLineFromGeometry` or :py:func:`~QgsMeshEditForceByLine.addLinesFromGeometries`
before applying the edition with :py:func:`QgsMeshEditor.advancedEdit()`

.. versionadded:: 3.22
%End

%TypeHeaderCode
#include "qgsmeshforcebypolylines.h"
%End
public:

QgsMeshEditForceByPolylines();
%Docstring
Constructor
%End

virtual bool isFinished() const;


void addLineFromGeometry( const QgsGeometry &geom );
%Docstring
Adds a input forcing line geometry in rendering coordinates
%End

void addLinesFromGeometries( const QList<QgsGeometry> geometries );
%Docstring
Adds a list of input forcing lines geometry in rendering coordinates
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/mesh/qgsmeshforcebypolylines.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -437,6 +437,7 @@
%Include auto_generated/mesh/qgsmeshtracerenderer.sip
%Include auto_generated/mesh/qgsmeshcalculator.sip
%Include auto_generated/mesh/qgsmeshadvancedediting.sip
%Include auto_generated/mesh/qgsmeshforcebypolylines.sip
%Include auto_generated/pointcloud/qgspointcloudattribute.sip
%Include auto_generated/pointcloud/qgspointcloudattributebyramprenderer.sip
%Include auto_generated/pointcloud/qgspointcloudattributemodel.sip
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/mesh/qgsmeshtriangulation.cpp
Expand Up @@ -433,6 +433,8 @@ QgsTopologicalMesh::Changes QgsMeshEditingDelaunayTriangulation::apply( QgsMeshE
if ( !removedVerticesFromTriangulation.isEmpty() )
mMessage = QObject::tr( "%1 vertices have not been included in the triangulation" ).arg( removedVerticesFromTriangulation.count() );

mIsFinished = true;

if ( triangulationReady && !giveUp )
return meshEditor->topologicalMesh().addFaces( topologicFaces );
else
Expand Down

0 comments on commit 4601394

Please sign in to comment.