23 #include "qgsmeshmemorydataprovider.h"
30 const double D_TRUE = 1.0;
31 const double D_FALSE = 0.0;
32 const double D_NODATA = std::numeric_limits<double>::quiet_NaN();
34 std::shared_ptr<QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::createMemoryDatasetGroup(
const QString &datasetGroupName,
const QgsInterval &relativeTime,
const QgsInterval &startTime,
const QgsInterval &endTime )
const
36 std::shared_ptr<QgsMeshMemoryDatasetGroup> grp;
37 const QList<int> &indexes = mMeshLayer->datasetGroupsIndexes();
38 for (
const int groupIndex : indexes )
41 const QString name = meta.
name();
42 if ( name == datasetGroupName )
49 grp = std::make_shared<QgsMeshMemoryDatasetGroup>();
51 grp->setDataType( mOutputType );
53 grp->setName( meta.
name() );
57 for (
int index = 0; index < mMeshLayer->datasetCount( groupIndex ); ++index )
60 else if ( relativeTime.
isValid() )
62 const QgsMeshDatasetIndex datasetIndex = mMeshLayer->datasetIndexAtRelativeTime( relativeTime, groupIndex );
64 grp->addDataset( createMemoryDataset( datasetIndex ) );
68 QList<QgsMeshDatasetIndex> datasetIndexes = mMeshLayer->datasetIndexInRelativeTimeInterval( startTime, endTime, groupIndex );
70 if ( datasetIndexes.isEmpty() )
71 datasetIndexes.append( mMeshLayer->datasetIndexAtRelativeTime( startTime, groupIndex ) );
74 grp->addDataset( createMemoryDataset( index ) );
86 return createMemoryDataset( grp.
dataType() );
89 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::createMemoryDataset(
const QgsMeshDatasetIndex &datasetIndex )
const
92 const int groupIndex = datasetIndex.
group();
93 const auto meta = mMeshLayer->datasetGroupMetadata( groupIndex );
99 std::shared_ptr<QgsMeshMemoryDataset> ds = createMemoryDataset( mOutputType );
100 ds->maximum = dsMeta.
maximum();
101 ds->minimum = dsMeta.
minimum();
102 ds->time = dsMeta.
time();
106 const QgsMeshDataBlock block = QgsMeshLayerUtils::datasetValues( mMeshLayer, datasetIndex, 0, nativeCount );
109 Q_ASSERT( block.
count() == nativeCount );
116 QVector<double> data =
117 QgsMeshLayerUtils::interpolateFromFacesData(
124 Q_ASSERT( data.size() == resultCount );
125 for (
int valueIndex = 0; valueIndex < resultCount; ++valueIndex )
130 QVector<double> buf = block.
values();
131 QVector<double> x( nativeCount );
132 QVector<double> y( nativeCount );
133 for (
int value_i = 0; value_i < nativeCount; ++value_i )
135 x[value_i] = buf[2 * value_i];
136 y[value_i] = buf[2 * value_i + 1];
139 QVector<double> dataX =
140 QgsMeshLayerUtils::interpolateFromFacesData(
142 mMeshLayer->nativeMesh(),
143 mMeshLayer->triangularMesh(),
145 mMeshLayer->rendererSettings().scalarSettings( groupIndex ).dataResamplingMethod()
147 Q_ASSERT( dataX.size() == resultCount );
148 QVector<double> dataY =
149 QgsMeshLayerUtils::interpolateFromFacesData(
151 mMeshLayer->nativeMesh(),
152 mMeshLayer->triangularMesh(),
154 mMeshLayer->rendererSettings().scalarSettings( groupIndex ).dataResamplingMethod()
157 Q_ASSERT( dataY.size() == resultCount );
159 for (
int value_i = 0; value_i < resultCount; ++value_i )
167 for (
int value_i = 0; value_i < resultCount; ++value_i )
168 ds->values[value_i] = block.
value( value_i );
175 for (
int value_i = 0; value_i < dp->
faceCount(); ++value_i )
176 ds->active[value_i] = active.
active( value_i );
186 std::shared_ptr<QgsMeshMemoryDataset> ds = std::make_shared<QgsMeshMemoryDataset>();
189 ds->values.resize( mMeshLayer->dataProvider()->vertexCount() );
190 ds->active.resize( mMeshLayer->dataProvider()->faceCount() );
191 memset( ds->active.data(), 1,
static_cast<size_t>( ds->active.size() ) *
sizeof(
int ) );
195 ds->values.resize( mMeshLayer->dataProvider()->faceCount() );
201 QgsMeshCalcUtils:: QgsMeshCalcUtils(
QgsMeshLayer *layer,
202 const QStringList &usedGroupNames,
205 : mMeshLayer( layer )
209 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
213 mOutputType = determineResultDataType( layer, usedGroupNames );
220 if ( mMeshLayer->dataProvider()->contains( QgsMesh::ElementType::Edge ) )
225 for (
const QString &groupName : usedGroupNames )
227 const std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = createMemoryDatasetGroup( groupName );
231 mDatasetGroupMap.insert( groupName, ds );
236 bool timesPopulated =
false;
237 const QList<std::shared_ptr<QgsMeshMemoryDatasetGroup>> vals = mDatasetGroupMap.values();
238 for (
const std::shared_ptr<QgsMeshMemoryDatasetGroup> &ds : vals )
240 if ( ds->datasetCount() == 0 )
246 if ( ds->datasetCount() > 1 )
248 if ( timesPopulated )
250 if ( ds->datasetCount() != mTimes.size() )
257 for (
int datasetIndex = 0; datasetIndex < ds->datasetCount(); ++datasetIndex )
259 const std::shared_ptr<const QgsMeshMemoryDataset> o = ds->constDataset( datasetIndex );
260 if ( timesPopulated )
270 mTimes.append( o->time );
274 timesPopulated =
true;
279 if ( mTimes.isEmpty() )
281 mTimes.push_back( 0.0 );
286 for ( QVector<double>::iterator it = mTimes.begin(); it != mTimes.end(); )
290 ( ( *it >= startTime ) && ( *it <= endTime ) ) )
293 it = mTimes.erase( it );
298 for (
const std::shared_ptr<QgsMeshMemoryDatasetGroup> &ds : vals )
300 if ( ds->dataType() != mOutputType )
308 QgsMeshCalcUtils::QgsMeshCalcUtils(
QgsMeshLayer *layer,
const QStringList &usedGroupNames,
const QgsInterval &relativeTime )
309 : mMeshLayer( layer )
313 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
317 mOutputType = determineResultDataType( layer, usedGroupNames );
324 if ( mMeshLayer->dataProvider()->contains( QgsMesh::ElementType::Edge ) )
331 for (
const QString &groupName : usedGroupNames )
333 const std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = createMemoryDatasetGroup( groupName, relativeTime );
334 if ( !ds || ds->memoryDatasets.isEmpty() )
337 mDatasetGroupMap.insert( groupName, ds );
340 mTimes.push_back( usedInterval.
hours() );
345 QgsMeshCalcUtils::QgsMeshCalcUtils(
QgsMeshLayer *layer,
346 const QStringList &usedGroupNames,
347 const QStringList &usedGroupNamesForAggregate,
351 : mMeshLayer( layer )
355 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
360 mOutputType = determineResultDataType( layer, usedGroupNames + usedGroupNamesForAggregate );
367 if ( mMeshLayer->dataProvider()->contains( QgsMesh::ElementType::Edge ) )
370 for (
const QString &groupName : usedGroupNamesForAggregate )
372 const std::shared_ptr<QgsMeshMemoryDatasetGroup> dsg = createMemoryDatasetGroup( groupName,
QgsInterval(), startTime, endTime );
376 mDatasetGroupMapForAggregate.insert( groupName, dsg );
379 for (
const QString &groupName : usedGroupNames )
381 const std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = createMemoryDatasetGroup( groupName, relativeTime );
382 if ( ( !ds || ds->memoryDatasets.isEmpty() ) )
384 if ( mDatasetGroupMapForAggregate.contains( groupName ) )
389 mDatasetGroupMap.insert( groupName, ds );
395 mTimes.append( usedInterval.
hours() );
401 bool QgsMeshCalcUtils::isValid()
const
411 std::shared_ptr<const QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::group(
const QString &datasetName,
bool isAggregate )
const
414 return mDatasetGroupMapForAggregate.value( datasetName );
416 return mDatasetGroupMap.value( datasetName );
419 std::shared_ptr<const QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::group(
const QString &datasetName )
const
421 return mDatasetGroupMap[datasetName];
430 const std::shared_ptr<QgsMeshMemoryDataset> output = createMemoryDataset( filter );
431 output->time = mTimes[0];
433 const QList<int> faceIndexesForRectangle = triangularMesh()->faceIndexesForRectangle( extent );
434 const QVector<int> trianglesToNativeFaces = triangularMesh()->trianglesToNativeFaces();
438 for (
const int faceIndex : faceIndexesForRectangle )
440 const int nativeIndex = trianglesToNativeFaces[faceIndex];
441 const QgsMeshFace face = nativeMesh()->face( nativeIndex );
442 for (
const int vertexIndex : face )
444 output->values[vertexIndex].set( D_TRUE );
450 for (
const int faceIndex : faceIndexesForRectangle )
452 const int nativeIndex = trianglesToNativeFaces[faceIndex];
453 output->values[nativeIndex].set( D_TRUE );
465 const std::shared_ptr<QgsMeshMemoryDataset> output = createMemoryDataset( filter );
466 output->time = mTimes[0];
468 const QVector<QgsMeshVertex> &vertices = triangularMesh()->vertices();
472 const int nativeVertexCount = mMeshLayer->dataProvider()->vertexCount();
474 for (
int i = 0; i < nativeVertexCount; ++i )
479 output->values[i].set( D_TRUE );
483 output->values[i].set( D_FALSE );
489 const QVector<QgsMeshFace> &triangles = triangularMesh()->triangles();
490 for (
int i = 0; i < triangles.size(); ++i )
497 output->values[i].
set( D_TRUE );
501 output->values[i].set( D_FALSE );
508 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::number(
double val,
double time )
const
510 Q_ASSERT( isValid() );
512 std::shared_ptr<QgsMeshMemoryDataset> output = createMemoryDataset( mOutputType );
516 if ( std::isnan( val ) )
519 memset( output->active.data(), 0,
static_cast<size_t>( output->active.size() ) *
sizeof(
int ) );
523 for (
int i = 0; i < output->values.size(); ++i )
525 output->values[i].set( val );
534 Q_ASSERT( isValid() );
537 const std::shared_ptr<QgsMeshMemoryDataset> output = number( val, mTimes[0] );
544 Q_ASSERT( isValid() );
545 number( group1, 1.0 );
550 Q_ASSERT( isValid() );
551 number( group1, D_NODATA );
555 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::copy(
556 std::shared_ptr<const QgsMeshMemoryDataset> dataset0
559 Q_ASSERT( isValid() );
560 Q_ASSERT( dataset0 );
562 std::shared_ptr<QgsMeshMemoryDataset> output = std::make_shared<QgsMeshMemoryDataset>();
563 output->values = dataset0->values;
564 output->active = dataset0->active;
565 output->time = dataset0->time;
566 output->valid = dataset0->valid;
572 Q_ASSERT( isValid() );
574 const std::shared_ptr<const QgsMeshMemoryDatasetGroup> group2 = group( groupName, isAggregate );
577 if ( group2->datasetCount() == 1 )
580 const std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( 0 );
581 const std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
586 for (
int output_index = 0; output_index < group2->datasetCount(); ++output_index )
588 const std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( output_index );
592 ( ( o0->time >= mTimes.first() ) && ( o0->time <= mTimes.last() ) )
595 const std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
604 Q_ASSERT( isValid() );
609 const std::shared_ptr<QgsMeshMemoryDataset> o = group2.
memoryDatasets[i];
618 Q_ASSERT( isValid() );
624 const std::shared_ptr<QgsMeshMemoryDataset> o0 = group1.
memoryDatasets[0];
628 const std::shared_ptr<QgsMeshMemoryDataset> o = copy( o0 );
642 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::canditateDataset(
644 int datasetIndex )
const
646 Q_ASSERT( isValid() );
660 std::shared_ptr<const QgsMeshMemoryDataset> QgsMeshCalcUtils::constCandidateDataset(
662 int datasetIndex )
const
664 Q_ASSERT( isValid() );
678 int QgsMeshCalcUtils::datasetCount(
682 Q_ASSERT( isValid() );
689 return mTimes.size();
698 std::function<
double(
double )> func )
const
700 Q_ASSERT( isValid() );
702 for (
int time_index = 0; time_index < group.
datasetCount(); ++time_index )
704 const std::shared_ptr<QgsMeshMemoryDataset> output = canditateDataset( group, time_index );
706 for (
int n = 0; n < output->values.size(); ++n )
708 const double val1 = output->values[n].scalar();
709 double res_val = D_NODATA;
710 if ( !std::isnan( val1 ) )
711 res_val = func( val1 );
712 output->values[n] = res_val;
723 std::function<
double(
double,
double )> func )
const
725 Q_ASSERT( isValid() );
728 expand( group1, group2 );
730 for (
int time_index = 0; time_index < datasetCount( group1, group2 ); ++time_index )
732 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, time_index );
733 const std::shared_ptr<const QgsMeshMemoryDataset> o2 = constCandidateDataset( group2, time_index );
735 for (
int n = 0; n < o2->values.size(); ++n )
737 const double val1 = o1->values[n].scalar();
738 const double val2 = o2->values[n].scalar();
739 double res_val = D_NODATA;
740 if ( !std::isnan( val1 ) && !std::isnan( val2 ) )
741 res_val = func( val1, val2 );
742 o1->values[n] = res_val;
753 void QgsMeshCalcUtils::funcAggr(
755 std::function<
double( QVector<double>& )> func
758 Q_ASSERT( isValid() );
763 output->time = mTimes[0];
764 for (
int n = 0; n < mMeshLayer->dataProvider()->vertexCount(); ++n )
766 QVector < double > vals;
767 for (
int datasetIndex = 0; datasetIndex < group1.
datasetCount(); ++datasetIndex )
769 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
771 const double val1 = o1->values[n].scalar();
775 if ( !std::isnan( val1 ) )
777 vals.push_back( val1 );
781 double res_val = D_NODATA;
782 if ( !vals.isEmpty() )
784 res_val = func( vals );
787 output->values[n] = res_val;
800 output->time = mTimes[0];
802 const int facesCount = mMeshLayer->dataProvider()->faceCount();
803 output->values.resize( facesCount );
805 for (
int n = 0; n < mMeshLayer->dataProvider()->faceCount(); ++n )
807 QVector < double > vals;
808 for (
int datasetIndex = 0; datasetIndex < group1.
datasetCount(); ++datasetIndex )
810 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
811 const double val1 = o1->values[n].scalar();
812 if ( !std::isnan( val1 ) )
814 vals.push_back( val1 );
818 double res_val = D_NODATA;
819 if ( !vals.isEmpty() )
821 res_val = func( vals );
824 output->values[n] = res_val;
835 Q_ASSERT( mMeshLayer->triangularMesh() );
836 return mMeshLayer->triangularMesh();
839 const QgsMesh *QgsMeshCalcUtils::nativeMesh()
const
842 Q_ASSERT( mMeshLayer->nativeMesh() );
843 return mMeshLayer->nativeMesh();
846 void QgsMeshCalcUtils::updateMesh()
const
848 if ( ! mMeshLayer->nativeMesh() )
851 mMeshLayer->updateTriangularMesh();
864 Q_ASSERT( isValid() );
867 expand( trueGroup, condition );
868 expand( trueGroup, falseGroup );
873 for (
int time_index = 0; time_index < trueGroup.
datasetCount(); ++time_index )
875 const std::shared_ptr<QgsMeshMemoryDataset> true_o = canditateDataset( trueGroup, time_index );
876 const std::shared_ptr<const QgsMeshMemoryDataset> false_o = constCandidateDataset( falseGroup, time_index );
877 const std::shared_ptr<const QgsMeshMemoryDataset> condition_o = constCandidateDataset( condition, time_index );
878 for (
int n = 0; n < true_o->values.size(); ++n )
880 const double conditionValue = condition_o->values[n].scalar();
881 double resultValue = D_NODATA;
882 if ( !std::isnan( conditionValue ) )
885 resultValue = true_o->values[n].scalar();
887 resultValue = false_o->values[n].scalar();
889 true_o->values[n] = resultValue;
896 activate( true_o, condition_o );
904 Q_ASSERT( isValid() );
908 for (
int datasetIndex = 0; datasetIndex < group.
datasetCount(); ++datasetIndex )
910 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group, datasetIndex );
918 void QgsMeshCalcUtils::activate(
919 std::shared_ptr<QgsMeshMemoryDataset> dataset,
920 std::shared_ptr<const QgsMeshMemoryDataset> refDataset
924 Q_ASSERT( isValid() );
928 for (
int idx = 0; idx < mMeshLayer->dataProvider()->faceCount(); ++idx )
930 if ( refDataset && !refDataset->active.isEmpty() && ( !refDataset->active[idx] ) )
932 dataset->active[idx] =
false;
936 if ( !dataset->active[idx] )
943 bool isActive =
true;
944 for (
int j = 0; j < face.size(); ++j )
946 if ( std::isnan( dataset->values[face[j]].scalar() ) )
952 dataset->active[idx] = isActive;
956 double QgsMeshCalcUtils::ffilter(
double val1,
double filter )
const
958 Q_ASSERT( !std::isnan( val1 ) );
966 double QgsMeshCalcUtils::fadd(
double val1,
double val2 )
const
968 Q_ASSERT( !std::isnan( val1 ) );
969 Q_ASSERT( !std::isnan( val2 ) );
974 double QgsMeshCalcUtils::fsubtract(
double val1,
double val2 )
const
976 Q_ASSERT( !std::isnan( val1 ) );
977 Q_ASSERT( !std::isnan( val2 ) );
982 double QgsMeshCalcUtils::fmultiply(
double val1,
double val2 )
const
984 Q_ASSERT( !std::isnan( val1 ) );
985 Q_ASSERT( !std::isnan( val2 ) );
990 double QgsMeshCalcUtils::fdivide(
double val1,
double val2 )
const
992 Q_ASSERT( !std::isnan( val1 ) );
993 Q_ASSERT( !std::isnan( val2 ) );
1001 double QgsMeshCalcUtils::fpower(
double val1,
double val2 )
const
1003 Q_ASSERT( !std::isnan( val1 ) );
1004 Q_ASSERT( !std::isnan( val2 ) );
1005 return pow( val1, val2 );
1009 double QgsMeshCalcUtils::fequal(
double val1,
double val2 )
const
1011 Q_ASSERT( !std::isnan( val1 ) );
1012 Q_ASSERT( !std::isnan( val2 ) );
1024 double QgsMeshCalcUtils::fnotEqual(
double val1,
double val2 )
const
1026 Q_ASSERT( !std::isnan( val1 ) );
1027 Q_ASSERT( !std::isnan( val2 ) );
1039 double QgsMeshCalcUtils::fgreaterThan(
double val1,
double val2 )
const
1041 Q_ASSERT( !std::isnan( val1 ) );
1042 Q_ASSERT( !std::isnan( val2 ) );
1054 double QgsMeshCalcUtils::flesserThan(
double val1,
double val2 )
const
1056 Q_ASSERT( !std::isnan( val1 ) );
1057 Q_ASSERT( !std::isnan( val2 ) );
1069 double QgsMeshCalcUtils::flesserEqual(
double val1,
double val2 )
const
1071 Q_ASSERT( !std::isnan( val1 ) );
1072 Q_ASSERT( !std::isnan( val2 ) );
1084 double QgsMeshCalcUtils::fgreaterEqual(
double val1,
double val2 )
const
1086 Q_ASSERT( !std::isnan( val1 ) );
1087 Q_ASSERT( !std::isnan( val2 ) );
1100 double QgsMeshCalcUtils::flogicalAnd(
double val1,
double val2 )
const
1102 Q_ASSERT( !std::isnan( val1 ) );
1103 Q_ASSERT( !std::isnan( val2 ) );
1106 if ( bval1 && bval2 )
1113 double QgsMeshCalcUtils::flogicalOr(
double val1,
double val2 )
const
1115 Q_ASSERT( !std::isnan( val1 ) );
1116 Q_ASSERT( !std::isnan( val2 ) );
1119 if ( bval1 || bval2 )
1126 double QgsMeshCalcUtils::flogicalNot(
double val1 )
const
1128 Q_ASSERT( !std::isnan( val1 ) );
1137 double QgsMeshCalcUtils::fchangeSign(
double val1 )
const
1139 Q_ASSERT( !std::isnan( val1 ) );
1143 double QgsMeshCalcUtils::fmin(
double val1,
double val2 )
const
1145 Q_ASSERT( !std::isnan( val1 ) );
1157 double QgsMeshCalcUtils::fmax(
double val1,
double val2 )
const
1159 Q_ASSERT( !std::isnan( val1 ) );
1160 Q_ASSERT( !std::isnan( val2 ) );
1172 double QgsMeshCalcUtils::fabs(
double val1 )
const
1174 Q_ASSERT( !std::isnan( val1 ) );
1186 double QgsMeshCalcUtils::fsumAggregated( QVector<double> &vals )
const
1188 Q_ASSERT( !vals.contains( D_NODATA ) );
1189 Q_ASSERT( !vals.isEmpty() );
1190 return std::accumulate( vals.begin(), vals.end(), 0.0 );
1193 double QgsMeshCalcUtils::fminimumAggregated( QVector<double> &vals )
const
1195 Q_ASSERT( !vals.contains( D_NODATA ) );
1196 Q_ASSERT( !vals.isEmpty() );
1197 return *std::min_element( vals.begin(), vals.end() );
1200 double QgsMeshCalcUtils::fmaximumAggregated( QVector<double> &vals )
const
1202 Q_ASSERT( !vals.contains( D_NODATA ) );
1203 Q_ASSERT( !vals.isEmpty() );
1204 return *std::max_element( vals.begin(), vals.end() );
1207 double QgsMeshCalcUtils::faverageAggregated( QVector<double> &vals )
const
1209 Q_ASSERT( !vals.contains( D_NODATA ) );
1210 Q_ASSERT( !vals.isEmpty() );
1211 return fsumAggregated( vals ) / vals.size();
1216 return func1( group1, std::bind( & QgsMeshCalcUtils::flogicalNot,
this, std::placeholders::_1 ) );
1221 return func1( group1, std::bind( & QgsMeshCalcUtils::fchangeSign,
this, std::placeholders::_1 ) );
1226 return func1( group1, std::bind( & QgsMeshCalcUtils::fabs,
this, std::placeholders::_1 ) );
1231 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fadd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1236 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fsubtract,
this, std::placeholders::_1, std::placeholders::_2 ) );
1241 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmultiply,
this, std::placeholders::_1, std::placeholders::_2 ) );
1246 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fdivide,
this, std::placeholders::_1, std::placeholders::_2 ) );
1251 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fpower,
this, std::placeholders::_1, std::placeholders::_2 ) );
1256 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fequal,
this, std::placeholders::_1, std::placeholders::_2 ) );
1261 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fnotEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1266 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fgreaterThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1271 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flesserThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1276 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flesserEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1281 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fgreaterEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1286 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flogicalAnd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1291 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flogicalOr,
this, std::placeholders::_1, std::placeholders::_2 ) );
1296 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmin,
this, std::placeholders::_1, std::placeholders::_2 ) );
1301 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmax,
this, std::placeholders::_1, std::placeholders::_2 ) );
1306 QHash<QString, int> names;
1308 for (
const int groupId : groupIndexes )
1311 const QString name = meta.
name();
1312 names[ name ] = groupId;
1314 for (
const QString &datasetGroupName : usedGroupNames )
1316 if ( names.contains( datasetGroupName ) )
1318 const int groupId = names.value( datasetGroupName );
1336 populateSpatialFilter( filter, extent );
1337 return func2( group1, filter, std::bind( & QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1343 populateMaskFilter( filter, mask );
1344 return func2( group1, filter, std::bind( & QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1349 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fsumAggregated,
this, std::placeholders::_1 ) );
1354 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fminimumAggregated,
this, std::placeholders::_1 ) );
1359 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fmaximumAggregated,
this, std::placeholders::_1 ) );
1364 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::faverageAggregated,
this, std::placeholders::_1 ) );
A geometry is the spatial representation of a feature.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
A representation of the interval between two datetime values.
bool isValid() const
Returns true if the interval is valid.
double hours() const
Returns the interval duration in hours.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
QVector< double > values() const
Returns buffer to the array with values For vector it is pairs (x1, y1, x2, y2, .....
bool isValid() const
Whether the block is valid.
bool active(int index) const
Returns a value for active flag by the index For scalar and vector 2d the behavior is undefined.
int count() const
Number of items stored in the block.
Base class for providing data for QgsMeshLayer.
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
virtual int faceCount() const =0
Returns number of faces in the native mesh.
QgsMeshDatasetGroupMetadata::DataType dataType() const
Returns the data type of the dataset group.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
bool isValid() const
Returns whether index is valid, ie at least groups is set.
int group() const
Returns a group index.
QgsMeshDatasetValue represents single dataset value.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QList< int > datasetGroupsIndexes() const
Returns the list of indexes of dataset groups handled by the layer.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
Class that represents a dataset group stored in memory.
void addDataset(std::shared_ptr< QgsMeshMemoryDataset > dataset)
Adds a memory dataset to the group.
void clearDatasets()
Removes all the datasets from the group.
std::shared_ptr< const QgsMeshMemoryDataset > constDataset(int index) const
Returns the dataset with index.
QVector< std::shared_ptr< QgsMeshMemoryDataset > > memoryDatasets
Contains all the memory datasets.
int datasetCount() const override
Returns the count of datasets in the group.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
A class to represent a 2D point.
A rectangle specified with double values.
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
CORE_EXPORT QgsGeometry toGeometry(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns face as polygon geometry.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QVector< int > QgsMeshFace
List of vertex indexes.
Mesh - vertices, edges and faces.