-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathreosmesh.h
254 lines (187 loc) · 9.02 KB
/
reosmesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/***************************************************************************
reosmesh.h - ReosMesh
---------------------
begin : 13.1.2022
copyright : (C) 2022 by Vincent Cloarec
email : vcloarec at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef REOSMESH_H
#define REOSMESH_H
#include <QPointF>
#include <QVector>
#include <QPointer>
#include <QSet>
#include "reoscore.h"
#include "reosgisengine.h"
#include "reosrenderedobject.h"
#include "reosencodedelement.h"
class ReosMeshGenerator;
class ReosMeshFrameData;
class ReosDigitalElevationModel;
class ReosTopographyCollection;
class ReosParameterDouble;
class ReosParameterInteger;
class ReosParameterSlope;
class ReosParameterArea;
class ReosHydraulicSimulationResults;
class ReosSpatialPosition;
class ReosMeshDatasetSource;
class ReosGisEngine;
class ReosMeshQualityChecker : public ReosProcess
{
public:
virtual ~ReosMeshQualityChecker() {}
struct QualityMeshResults
{
QString error;
int errorVertex = -1;
int errorFace = -1;
QList<QPolygonF> minimumAngle;
QList<QPolygonF> maximumAngle;;
QList<QPointF> connectionCount;
QList<QPointF> connectionCountBoundary;
QList<QLineF> maximumSlope;
QList<QPolygonF> minimumArea;
QList<QPolygonF> maximumArea;
QList<QPolygonF> maximumAreaChange;
};
virtual QualityMeshResults result() const = 0;
protected:
mutable QualityMeshResults mResult;
};
class REOSCORE_EXPORT ReosMesh: public ReosRenderedObject
{
Q_OBJECT
public:
struct QualityMeshParameters
{
ReosParameterDouble *minimumAngle = nullptr;
ReosParameterDouble *maximumAngle = nullptr;
ReosParameterInteger *connectionCount = nullptr;
ReosParameterInteger *connectionCountBoundary = nullptr;
ReosParameterSlope *maximumSlope = nullptr;
ReosParameterArea *minimumArea = nullptr;
ReosParameterArea *maximumArea = nullptr;
ReosParameterDouble *maximumAreaChange = nullptr;
ReosEncodedElement encode() const;
void decode( const ReosEncodedElement &element, QObject *parent );
};
enum QualityMeshCheck
{
MinimumAngle = 1 << 0,
MaximumAngle = 1 << 1,
ConnectionCount = 1 << 2,
ConnectionCountBoundary = 1 << 3,
MaximumSlope = 1 << 4,
MinimumArea = 1 << 5,
MaximumArea = 1 << 6,
MaximumAreaChange = 1 << 7
};
Q_ENUM( QualityMeshCheck )
Q_DECLARE_FLAGS( QualityMeshChecks, QualityMeshCheck )
Q_FLAG( QualityMeshChecks )
struct WireFrameSettings
{
bool enabled = false;
QColor color;
double width = 0.2;
};
//! Creates a new void mesh in memory
static ReosMesh *createMeshFrame( const QString &crs = QString(), QObject *parent = nullptr );
static ReosMesh *createMeshFrameFromFile( const QString &dataPath, const QString &destinationCrs );
//! Returns whether the mesh is valid
virtual bool isValid() const = 0;
//! Returns vertex count
virtual int vertexCount() const = 0;
//! Returns face count
virtual int faceCount() const = 0;
//! Returns whether the mesh frame is modified
virtual bool isFrameModified() const = 0;
//! Clears ans generates a new mesh with \a data
virtual void generateMesh( const ReosMeshFrameData &data ) = 0;
virtual QString crs() const = 0;
virtual QVector<int> face( int faceIndex ) const = 0 ;
virtual QPointF vertexPosition( int vertexIndex, const QString &destinationCrs = QString() ) const = 0;
virtual double vertexElevation( int vertexIndex ) const = 0 ;
virtual QObject *data() const = 0;
/**
* Activate vertices elevation as a dataset group with \a name, returns a unique id of this dataset group.
*/
virtual QString enableVertexElevationDataset( const QString &name ) = 0;
//! Returns the vertices elevation dataset id
virtual QString verticesElevationDatasetId() const = 0;
//! Returns all the dataset ids contained in the mesh
virtual QStringList datasetIds() const = 0;
//! Returns all the vector dataset ids contained in the mesh
virtual QStringList vectorDatasetIds() const = 0;
//! Returns the name of the dataset with \a id
virtual QString datasetName( const QString &id ) const = 0;
//! Activates the dataset with \a id
virtual bool activateDataset( const QString &id, bool update = true ) = 0;
//! Activates the vector dataset with \a id
virtual bool activateVectorDataset( const QString &id, bool update = true ) = 0;
//! Returns the current scalar dataset Id
virtual QString currentdScalarDatasetId() const = 0;
//! Returns the current vector dataset Id
virtual QString currentdVectorDatasetId() const = 0;
//! Returns whether the mesh has a dataset group with \a id
virtual bool hasDatasetGroupIndex( const QString &id ) const = 0;
//! Returns a process that apply the topography collection on the mesh, caller take ownership
virtual ReosProcess *applyTopographyOnVertices( ReosTopographyCollection *topographyCollection ) = 0;
//! Returns the value of dataset \a datasetId at position \a pos in map coordinates
virtual double datasetScalarValueAt( const QString &datasetId, const QPointF &pos ) const = 0;
//! Returns by reference the min max for the dataset group corresponding to \a id
virtual void datasetGroupMinimumMaximum( const QString &datasetId, double &min, double &max ) const = 0;
//! Save the mesh frame on UGRID file with path \a dataPath
virtual void save( const QString &dataPath ) = 0;
virtual void stopFrameEditing( bool commit, bool continueEditing = false ) = 0;
virtual ReosEncodedElement datasetScalarGroupSymbology( const QString &id ) const = 0;
virtual void setDatasetScalarGroupSymbology( const ReosEncodedElement &encodedElement, const QString &id ) = 0;
virtual ReosEncodedElement datasetVectorGroupSymbology( const QString &id ) const = 0;
virtual void setDatasetVectorGroupSymbology( const ReosEncodedElement &encodedElement, const QString &id ) = 0;
virtual void activateWireFrame( bool activate ) = 0;
virtual bool isWireFrameActive() const = 0;
//! Return the mesh frame symbology with encoded format
virtual ReosEncodedElement wireFrameSymbology() const = 0;
virtual WireFrameSettings wireFrameSettings() const = 0 ;
virtual void setWireFrameSettings( const WireFrameSettings &wireFrameSettings ) = 0;
virtual void update3DRenderer() = 0;
//! Returns a process that check the quality of the mesh, caller take ownership
virtual ReosMeshQualityChecker *getQualityChecker( QualityMeshChecks qualitiChecks, const QString &destinatonCrs ) const = 0;
virtual void setSimulationResults( ReosHydraulicSimulationResults *result ) = 0;
virtual double interpolateDatasetValueOnPoint( const ReosMeshDatasetSource *datasetSource, const ReosSpatialPosition &position, int sourceGroupindex, int datasetIndex ) const = 0;
QualityMeshParameters qualityMeshParameters() const;
void setQualityMeshParameter( const ReosEncodedElement &element );
void setBoundariesVertices( const QVector<QVector<int> > &vertices );
void setHolesVertices( const QVector<QVector<QVector<int> > > &vertices );
bool vertexIsOnBoundary( int vertexIndex ) const;
bool vertexIsOnHoleBorder( int vertexIndex ) const;
virtual QString verticalDataset3DId() const = 0;
virtual void setVerticalDataset3DId( const QString &verticalDataset3DId, bool update = true ) = 0;
double verticaleSCale() const;
void setVerticaleSCale( double verticaleSCale );
QMap<QString, QByteArray> datasetScalarSymbologies() const;
void setDatasetScalarSymbologies( const QMap<QString, QByteArray> &datasetScalarSymbologies );
QMap<QString, QByteArray> datasetVectorSymbologies() const;
void setDatasetVectorSymbologies( const QMap<QString, QByteArray> &datasetVectorSymbologies );
virtual QString exportAsMesh( const QString &fileName ) const = 0;
virtual bool exportSimulationResults( ReosHydraulicSimulationResults *result, const QString &fileName ) const = 0;
signals:
void datasetSymbologyChanged( const QString &datasetId );
protected:
ReosMesh( QObject *parent = nullptr );
QualityMeshParameters mQualityMeshParameters;
QSet<int> mBoundaryVerticesSet;
QSet<int> mHolesVerticesSet;
QMap<QString, QByteArray> mDatasetScalarSymbologies;
QMap<QString, QByteArray> mDatasetVectorSymbologies;
double mVerticaleSCale = 1;
};
#endif // REOSMESH_H