QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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 "qgsabstractgeometry.h"
23#include "qgstopologicalmesh.h"
24#include "qgstriangularmesh.h"
25
40{
41 public:
43
45 void setInputLine( const QgsPoint &pt1, const QgsPoint &pt2, double tolerance, bool newVertexOnIntersection );
46
48 void setTolerance( double tolerance );
49
51 void setAddVertexOnIntersection( bool addVertex );
52
54 void setDefaultZValue( double defaultZValue );
55
61 void setInterpolateZValueOnMesh( bool interpolateZValueOnMesh );
62
63 private:
64 QgsPoint mPoint1;
65 QgsPoint mPoint2;
66 bool mNewVertexOnIntersection = false;
67 double mTolerance = 1e-8;
68 double mDefaultZValue = 0;
69 bool mInterpolateZValueOnMesh = false;
70
71 QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
72
73 virtual void finish();
74
75 //members and method used for the calculation
76 QgsMeshEditor *mEditor = nullptr;
77 QList<int> mRemovedFaces;
78 QList<int> mHoleOnLeft; // contains the border vertices of hole to fill on the right of the line (line go up)
79 QList<int> mNeighborOnLeft; //contains the neighbor face on the right of the line (line go up)
80 QList<int> mHoleOnRight; // contains the border vertices of hole to fill on the right of the line (line go up)
81 QList<int> mNeighborOnRight; // contains the neighbor face on the right of the line (line go up)
82 QList<int> mNewVerticesIndexesOnLine; //the new vertices intersecting edges except
83 bool mEndOnPoint2 = false;
84 int mPoint2VertexIndex = -1;
85 int mCurrentSnappedVertex = -1; // Last snapped point
86 QgsPoint mCurrentPointPosition;
87
88 bool mFirstPointChecked = false;
89 bool mSecondPointChecked = false;
90
91 void interpolateZValueOnMesh( QgsPoint &point ) const;
92 void interpolateZValueOnMesh( int faceIndex, QgsPoint &point ) const;
93 void interpolateZValue( QgsMeshVertex &point, const QgsPoint &otherPoint1, const QgsPoint &otherPoint2 );
94
95
96 bool buildForcedElements();
97
98 bool edgeIntersection( int vertex1, int vertex2, int &closestSnappedVertex, QgsPoint &intersectionPoint, bool outAllowed );
99
100 bool searchIntersectionEdgeFromSnappedVertex(
101 int &intersectionFaceIndex, int &previousSnappedVertex, int &currentSnappedVertexIndex, QgsPoint &intersectionPoint, int &edgePosition, QSet<int> &treatedFaces
102 );
103
104 // Insert a new vertex and returns its local index (0 is first index in th
105 int insertNewVertex( const QgsMeshVertex &vertex );
106
107 bool triangulateHoles( const QList<int> &holeOnLeft, const QList<int> &neighborOnLeft, bool isLeftHole, QList<std::array<int, 2> > &newFacesOnLine, std::array<int, 2> &extremeFaces );
108
109 bool finishForcingLine();
110
111 friend class TestQgsMeshEditor;
113};
114
115
130{
131 public:
133
134 QString text() const override;
135 bool isFinished() const override;
136
143 void addLineFromGeometry( const QgsGeometry &geom );
144
151 void addLinesFromGeometries( const QList<QgsGeometry> geometries );
152
153 private:
154 QList<QgsPointSequence> mPolylines;
155 int mCurrentPolyline = 0;
156 int mCurrentSegment = 0;
157
158 void incrementSegment();
159
161 QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
162};
163
164#endif // QGSMESHFORCEBYPOLYLINES_H
A geometry is the spatial representation of a feature.
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 ...
QgsMeshEditForceByLine()=default
void setAddVertexOnIntersection(bool addVertex)
Sets whether vertices will be added when the lines will intersect internal edges of faces,...
void setInputLine(const QgsPoint &pt1, const QgsPoint &pt2, double tolerance, bool newVertexOnIntersection)
Sets the input forcing line in rendering coordinates.
void setDefaultZValue(double defaultZValue)
Sets the default value of Z coordinate to use for new vertices, this value will be used if the Z valu...
void setTolerance(double tolerance)
Sets the tolerance in redering coordinate system unit.
void setInterpolateZValueOnMesh(bool interpolateZValueOnMesh)
Sets whether the new created vertices will have their value interpolated from the existing mesh.
void addLinesFromGeometries(const QList< QgsGeometry > geometries)
Adds a list of input forcing lines geometry in rendering coordinates.
void addLineFromGeometry(const QgsGeometry &geom)
Adds a input forcing line geometry in rendering coordinates.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
Contains topological differences between two states of a topological mesh, only accessible from the Q...
QgsPoint QgsMeshVertex
xyz coords of vertex