QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
44
46 void setInputLine( const QgsPoint &pt1, const QgsPoint &pt2, double tolerance, bool newVertexOnIntersection );
47
49 void setTolerance( double tolerance );
50
52 void setAddVertexOnIntersection( bool addVertex );
53
55 void setDefaultZValue( double defaultZValue );
56
62 void setInterpolateZValueOnMesh( bool interpolateZValueOnMesh );
63
64 private:
65 QgsPoint mPoint1;
66 QgsPoint mPoint2;
67 bool mNewVertexOnIntersection = false;
68 double mTolerance = 1e-8;
69 double mDefaultZValue = 0;
70 bool mInterpolateZValueOnMesh = false;
71
72 QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
73
74 virtual void finish();
75
76 //members and method used for the calculation
77 QgsMeshEditor *mEditor = nullptr;
78 QList<int> mRemovedFaces;
79 QList<int> mHoleOnLeft; // contains the border vertices of hole to fill on the right of the line (line go up)
80 QList<int> mNeighborOnLeft; //contains the neighbor face on the right of the line (line go up)
81 QList<int> mHoleOnRight; // contains the border vertices of hole to fill on the right of the line (line go up)
82 QList<int> mNeighborOnRight; // contains the neighbor face on the right of the line (line go up)
83 QList<int> mNewVerticesIndexesOnLine; //the new vertices intersecting edges except
84 bool mEndOnPoint2 = false;
85 int mPoint2VertexIndex = -1;
86 int mCurrentSnappedVertex = -1; // Last snapped point
87 QgsPoint mCurrentPointPosition;
88
89 bool mFirstPointChecked = false;
90 bool mSecondPointChecked = false;
91
92 void interpolateZValueOnMesh( QgsPoint &point ) const;
93 void interpolateZValueOnMesh( int faceIndex, QgsPoint &point ) const;
94 void interpolateZValue( QgsMeshVertex &point, const QgsPoint &otherPoint1, const QgsPoint &otherPoint2 );
95
96
97 bool buildForcedElements();
98
99 bool edgeIntersection( int vertex1,
100 int vertex2,
101 int &closestSnappedVertex,
102 QgsPoint &intersectionPoint,
103 bool outAllowed );
104
105 bool searchIntersectionEdgeFromSnappedVertex(
106 int &intersectionFaceIndex,
107 int &previousSnappedVertex,
108 int &currentSnappedVertexIndex,
109 QgsPoint &intersectionPoint,
110 int &edgePosition,
111 QSet<int> &treatedFaces );
112
113 // Insert a new vertex and returns its local index (0 is first index in th
114 int insertNewVertex( const QgsMeshVertex &vertex );
115
116 bool triangulateHoles( const QList<int> &holeOnLeft,
117 const QList<int> &neighborOnLeft,
118 bool isLeftHole,
119 QList<std::array<int, 2> > &newFacesOnLine,
120 std::array<int, 2> &extremeFaces );
121
122 bool finishForcingLine();
123
124 friend class TestQgsMeshEditor;
126};
127
128
129
144{
145 public:
146
148
149 QString text() const override;
150 bool isFinished() const override;
151
158 void addLineFromGeometry( const QgsGeometry &geom );
159
166 void addLinesFromGeometries( const QList<QgsGeometry> geometries );
167
168 private:
169 QList<QgsPointSequence> mPolylines;
170 int mCurrentPolyline = 0;
171 int mCurrentSegment = 0;
172
173 void incrementSegment();
174
176 QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
177
178};
179
180#endif // QGSMESHFORCEBYPOLYLINES_H
A geometry is the spatial representation of a feature.
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
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.
Class that makes edit operation on a mesh.
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,...