QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsmeshforcebypolylines.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmeshforcebypolylines.h - QgsMeshForceByPolylines
3
4 ---------------------
5 begin : 5.9.2021
6 copyright : (C) 2021 by Vincent Cloarec
7 email : vcloarec at gmail dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSMESHFORCEBYPOLYLINES_H
17#define QGSMESHFORCEBYPOLYLINES_H
18
19
20#include "qgis_core.h"
21#include "qgstopologicalmesh.h"
22#include "qgstriangularmesh.h"
23#include "qgsabstractgeometry.h"
25
40{
41 public:
42
45
47 void setInputLine( const QgsPoint &pt1, const QgsPoint &pt2, double tolerance, bool newVertexOnIntersection );
48
50 void setTolerance( double tolerance );
51
53 void setAddVertexOnIntersection( bool addVertex );
54
56 void setDefaultZValue( double defaultZValue );
57
63 void setInterpolateZValueOnMesh( bool interpolateZValueOnMesh );
64
65 private:
66 QgsPoint mPoint1;
67 QgsPoint mPoint2;
68 bool mNewVertexOnIntersection = false;
69 double mTolerance = 1e-8;
70 double mDefaultZValue = 0;
71 bool mInterpolateZValueOnMesh = false;
72
73 QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
74
75 virtual void finish();
76
77 //members and method used for the calculation
78 QgsMeshEditor *mEditor = nullptr;
79 QList<int> mRemovedFaces;
80 QList<int> mHoleOnLeft; // contains the border vertices of hole to fill on the right of the line (line go up)
81 QList<int> mNeighborOnLeft; //contains the neighbor face on the right of the line (line go up)
82 QList<int> mHoleOnRight; // contains the border vertices of hole to fill on the right of the line (line go up)
83 QList<int> mNeighborOnRight; // contains the neighbor face on the right of the line (line go up)
84 QList<int> mNewVerticesIndexesOnLine; //the new vertices intersecting edges except
85 bool mEndOnPoint2 = false;
86 int mPoint2VertexIndex = -1;
87 int mCurrentSnappedVertex = -1; // Last snapped point
88 QgsPoint mCurrentPointPosition;
89
90 bool mFirstPointChecked = false;
91 bool mSecondPointChecked = false;
92
93 void interpolateZValueOnMesh( QgsPoint &point ) const;
94 void interpolateZValueOnMesh( int faceIndex, QgsPoint &point ) const;
95 void interpolateZValue( QgsMeshVertex &point, const QgsPoint &otherPoint1, const QgsPoint &otherPoint2 );
96
97
98 bool buildForcedElements();
99
100 bool edgeIntersection( int vertex1,
101 int vertex2,
102 int &closestSnappedVertex,
103 QgsPoint &intersectionPoint,
104 bool outAllowed );
105
106 bool searchIntersectionEdgeFromSnappedVertex(
107 int &intersectionFaceIndex,
108 int &previousSnappedVertex,
109 int &currentSnappedVertexIndex,
110 QgsPoint &intersectionPoint,
111 int &edgePosition,
112 QSet<int> &treatedFaces );
113
114 // Insert a new vertex and returns its local index (0 is first index in th
115 int insertNewVertex( const QgsMeshVertex &vertex );
116
117 bool triangulateHoles( const QList<int> &holeOnLeft,
118 const QList<int> &neighborOnLeft,
119 bool isLeftHole,
120 QList<std::array<int, 2> > &newFacesOnLine,
121 std::array<int, 2> &extremeFaces );
122
123 bool finishForcingLine();
124
125 friend class TestQgsMeshEditor;
127};
128
129
130
145{
146 public:
147
150
151 QString text() const override;
152 bool isFinished() const override;
153
160 void addLineFromGeometry( const QgsGeometry &geom );
161
168 void addLinesFromGeometries( const QList<QgsGeometry> geometries );
169
170 private:
171 QList<QgsPointSequence> mPolylines;
172 int mCurrentPolyline = 0;
173 int mCurrentSegment = 0;
174
175 void incrementSegment();
176
178 QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
179
180};
181
182#endif // QGSMESHFORCEBYPOLYLINES_H
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
Abstract class that can be derived to implement advanced editing on mesh.
virtual QgsTopologicalMesh::Changes apply(QgsMeshEditor *meshEditor)=0
Apply a change to mesh Editor.
virtual bool isFinished() const
Returns whether the advanced edit is finished, if not, this edit has to be applied again with QgsMesh...
virtual QString text() const
Returns a short text string describing what this advanced edit does. Default implementation return a ...
Class derived from QgsMeshAdvancedEditing that forces mesh based on a line.
QgsMeshEditForceByLine()=default
Constructor.
void setInputLine(const QgsPoint &pt1, const QgsPoint &pt2, double tolerance, bool newVertexOnIntersection)
Sets the input forcing line in rendering coordinates.
Class derived from QgsMeshEditForceByLine that forces mesh based on polyline.
QgsMeshEditForceByPolylines()=default
Constructor.
Class that makes edit operation on a mesh.
Definition: qgsmesheditor.h:68
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
Class that contains topological differences between two states of a topological mesh,...