25#include "qgsmeshmemorydataprovider.h"
31const double D_TRUE = 1.0;
32const double D_FALSE = 0.0;
33const double D_NODATA = std::numeric_limits<double>::quiet_NaN();
35std::shared_ptr<QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::createMemoryDatasetGroup(
39 std::shared_ptr<QgsMeshMemoryDatasetGroup> grp;
40 const QList<int> &indexes = mMeshLayer->datasetGroupsIndexes();
41 for (
const int groupIndex : indexes )
44 const QString name = meta.
name();
45 if ( name == datasetGroupName )
52 grp = std::make_shared<QgsMeshMemoryDatasetGroup>();
54 grp->setDataType( mOutputType );
56 grp->setName( meta.
name() );
60 for (
int index = 0; index < mMeshLayer->datasetCount( groupIndex ); ++index )
63 else if ( relativeTime.
isValid() )
65 const QgsMeshDatasetIndex datasetIndex = mMeshLayer->datasetIndexAtRelativeTime( relativeTime, groupIndex );
67 grp->addDataset( createMemoryDataset( datasetIndex ) );
71 QList<QgsMeshDatasetIndex> datasetIndexes = mMeshLayer->datasetIndexInRelativeTimeInterval( startTime, endTime, groupIndex );
73 if ( datasetIndexes.isEmpty() )
74 datasetIndexes.append( mMeshLayer->datasetIndexAtRelativeTime( startTime, groupIndex ) );
77 grp->addDataset( createMemoryDataset( index ) );
89 return createMemoryDataset( grp.
dataType() );
92std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::createMemoryDataset(
const QgsMeshDatasetIndex &datasetIndex )
const
95 const int groupIndex = datasetIndex.
group();
96 const auto meta = mMeshLayer->datasetGroupMetadata( groupIndex );
102 std::shared_ptr<QgsMeshMemoryDataset> ds = createMemoryDataset( mOutputType );
103 ds->maximum = dsMeta.
maximum();
104 ds->minimum = dsMeta.
minimum();
105 ds->time = dsMeta.
time();
109 const QgsMeshDataBlock block = QgsMeshLayerUtils::datasetValues( mMeshLayer, datasetIndex, 0, nativeCount );
112 Q_ASSERT( block.
count() == nativeCount );
120 Q_ASSERT( data.size() == resultCount );
121 for (
int valueIndex = 0; valueIndex < resultCount; ++valueIndex )
126 QVector<double> buf = block.
values();
127 QVector<double> x( nativeCount );
128 QVector<double> y( nativeCount );
129 for (
int value_i = 0; value_i < nativeCount; ++value_i )
131 x[value_i] = buf[2 * value_i];
132 y[value_i] = buf[2 * value_i + 1];
135 QVector<double> dataX
136 = QgsMeshLayerUtils::interpolateFromFacesData( x, mMeshLayer->nativeMesh(), mMeshLayer->triangularMesh(),
nullptr, mMeshLayer->rendererSettings().scalarSettings( groupIndex ).dataResamplingMethod() );
137 Q_ASSERT( dataX.size() == resultCount );
138 QVector<double> dataY
139 = QgsMeshLayerUtils::interpolateFromFacesData( y, mMeshLayer->nativeMesh(), mMeshLayer->triangularMesh(),
nullptr, mMeshLayer->rendererSettings().scalarSettings( groupIndex ).dataResamplingMethod() );
141 Q_ASSERT( dataY.size() == resultCount );
143 for (
int value_i = 0; value_i < resultCount; ++value_i )
151 for (
int value_i = 0; value_i < resultCount; ++value_i )
152 ds->values[value_i] = block.
value( value_i );
159 for (
int value_i = 0; value_i < dp->
faceCount(); ++value_i )
160 ds->active[value_i] = active.
active( value_i );
170 auto ds = std::make_shared<QgsMeshMemoryDataset>();
173 ds->values.resize( mMeshLayer->dataProvider()->vertexCount() );
174 ds->active.resize( mMeshLayer->dataProvider()->faceCount() );
175 memset( ds->active.data(), 1,
static_cast<size_t>( ds->active.size() ) *
sizeof(
int ) );
179 ds->values.resize( mMeshLayer->dataProvider()->faceCount() );
185QgsMeshCalcUtils::QgsMeshCalcUtils(
QgsMeshLayer *layer,
const QStringList &usedGroupNames,
double startTime,
double endTime )
186 : mMeshLayer( layer )
190 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
194 mOutputType = determineResultDataType( layer, usedGroupNames );
206 for (
const QString &groupName : usedGroupNames )
208 const std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = createMemoryDatasetGroup( groupName );
212 mDatasetGroupMap.insert( groupName, ds );
216 mDatasetGroupMapForAggregate = mDatasetGroupMap;
220 bool timesPopulated =
false;
221 const QList<std::shared_ptr<QgsMeshMemoryDatasetGroup>> vals = mDatasetGroupMap.values();
222 for (
const std::shared_ptr<QgsMeshMemoryDatasetGroup> &ds : vals )
224 if ( ds->datasetCount() == 0 )
230 if ( ds->datasetCount() > 1 )
232 if ( timesPopulated )
234 if ( ds->datasetCount() != mTimes.size() )
241 for (
int datasetIndex = 0; datasetIndex < ds->datasetCount(); ++datasetIndex )
243 const std::shared_ptr<const QgsMeshMemoryDataset> o = ds->constDataset( datasetIndex );
244 if ( timesPopulated )
254 mTimes.append( o->time );
258 timesPopulated =
true;
263 if ( mTimes.isEmpty() )
265 mTimes.push_back( 0.0 );
270 for ( QVector<double>::iterator it = mTimes.begin(); it != mTimes.end(); )
272 if ( qgsDoubleNear( *it, startTime ) || qgsDoubleNear( *it, endTime ) || ( ( *it >= startTime ) && ( *it <= endTime ) ) )
275 it = mTimes.erase( it );
280 for (
const std::shared_ptr<QgsMeshMemoryDatasetGroup> &ds : vals )
282 if ( ds->dataType() != mOutputType )
290QgsMeshCalcUtils::QgsMeshCalcUtils(
QgsMeshLayer *layer,
const QStringList &usedGroupNames,
const QgsInterval &relativeTime )
291 : mMeshLayer( layer )
295 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
299 mOutputType = determineResultDataType( layer, usedGroupNames );
310 if ( !usedInterval.isValid() )
313 for (
const QString &groupName : usedGroupNames )
315 const std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = createMemoryDatasetGroup( groupName, relativeTime );
316 if ( !ds || ds->memoryDatasets.isEmpty() )
319 mDatasetGroupMap.insert( groupName, ds );
322 mTimes.push_back( usedInterval.hours() );
327QgsMeshCalcUtils::QgsMeshCalcUtils(
330 : mMeshLayer( layer )
334 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
339 mOutputType = determineResultDataType( layer, usedGroupNames + usedGroupNamesForAggregate );
349 for (
const QString &groupName : usedGroupNamesForAggregate )
351 const std::shared_ptr<QgsMeshMemoryDatasetGroup> dsg = createMemoryDatasetGroup( groupName,
QgsInterval(), startTime, endTime );
355 mDatasetGroupMapForAggregate.insert( groupName, dsg );
358 for (
const QString &groupName : usedGroupNames )
360 const std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = createMemoryDatasetGroup( groupName, relativeTime );
361 if ( ( !ds || ds->memoryDatasets.isEmpty() ) )
363 if ( mDatasetGroupMapForAggregate.contains( groupName ) )
368 mDatasetGroupMap.insert( groupName, ds );
374 mTimes.append( usedInterval.
hours() );
380bool QgsMeshCalcUtils::isValid()
const
390std::shared_ptr<const QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::group(
const QString &datasetName,
bool isAggregate )
const
393 return mDatasetGroupMapForAggregate.value( datasetName );
395 return mDatasetGroupMap.value( datasetName );
398std::shared_ptr<const QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::group(
const QString &datasetName )
const
400 return mDatasetGroupMap[datasetName];
409 const std::shared_ptr<QgsMeshMemoryDataset> output = createMemoryDataset( filter );
410 output->time = mTimes[0];
412 const QList<int> faceIndexesForRectangle = triangularMesh()->faceIndexesForRectangle( extent );
413 const QVector<int> trianglesToNativeFaces = triangularMesh()->trianglesToNativeFaces();
417 for (
const int faceIndex : faceIndexesForRectangle )
419 const int nativeIndex = trianglesToNativeFaces[faceIndex];
420 const QgsMeshFace face = nativeMesh()->face( nativeIndex );
421 for (
const int vertexIndex : face )
423 output->values[vertexIndex].set( D_TRUE );
429 for (
const int faceIndex : faceIndexesForRectangle )
431 const int nativeIndex = trianglesToNativeFaces[faceIndex];
432 output->values[nativeIndex].set( D_TRUE );
444 const std::shared_ptr<QgsMeshMemoryDataset> output = createMemoryDataset( filter );
445 output->time = mTimes[0];
447 const QVector<QgsMeshVertex> &vertices = triangularMesh()->vertices();
451 const int nativeVertexCount = mMeshLayer->dataProvider()->vertexCount();
453 for (
int i = 0; i < nativeVertexCount; ++i )
458 output->values[i].set( D_TRUE );
462 output->values[i].set( D_FALSE );
468 const QVector<QgsMeshFace> &triangles = triangularMesh()->triangles();
469 for (
int i = 0; i < triangles.size(); ++i )
476 output->values[i].set( D_TRUE );
480 output->values[i].set( D_FALSE );
487std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::number(
double val,
double time )
const
489 Q_ASSERT( isValid() );
491 std::shared_ptr<QgsMeshMemoryDataset> output = createMemoryDataset( mOutputType );
495 if ( std::isnan( val ) )
498 memset( output->active.data(), 0,
static_cast<size_t>( output->active.size() ) *
sizeof(
int ) );
502 for (
int i = 0; i < output->values.size(); ++i )
504 output->values[i].set( val );
513 Q_ASSERT( isValid() );
516 const std::shared_ptr<QgsMeshMemoryDataset> output = number( val, mTimes[0] );
523 Q_ASSERT( isValid() );
524 number( group1, 1.0 );
529 Q_ASSERT( isValid() );
530 number( group1, D_NODATA );
534std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::copy( std::shared_ptr<const QgsMeshMemoryDataset> dataset0 )
const
536 Q_ASSERT( isValid() );
537 Q_ASSERT( dataset0 );
539 auto output = std::make_shared<QgsMeshMemoryDataset>();
540 output->values = dataset0->values;
541 output->active = dataset0->active;
542 output->time = dataset0->time;
543 output->valid = dataset0->valid;
549 Q_ASSERT( isValid() );
551 const std::shared_ptr<const QgsMeshMemoryDatasetGroup> group2 = group( groupName, isAggregate );
554 if ( group2->datasetCount() == 1 )
557 const std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( 0 );
558 const std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
563 for (
int output_index = 0; output_index < group2->datasetCount(); ++output_index )
565 const std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( output_index );
566 if ( mIgnoreTime ||
qgsDoubleNear( o0->time, mTimes.first() ) ||
qgsDoubleNear( o0->time, mTimes.last() ) || ( ( o0->time >= mTimes.first() ) && ( o0->time <= mTimes.last() ) ) )
568 const std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
577 Q_ASSERT( isValid() );
582 const std::shared_ptr<QgsMeshMemoryDataset> o = group2.
memoryDatasets[i];
591 Q_ASSERT( isValid() );
597 const std::shared_ptr<QgsMeshMemoryDataset> o0 = group1.
memoryDatasets[0];
601 const std::shared_ptr<QgsMeshMemoryDataset> o = copy( o0 );
615std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::canditateDataset(
QgsMeshMemoryDatasetGroup &group,
int datasetIndex )
const
617 Q_ASSERT( isValid() );
631std::shared_ptr<const QgsMeshMemoryDataset> QgsMeshCalcUtils::constCandidateDataset(
const QgsMeshMemoryDatasetGroup &group,
int datasetIndex )
const
633 Q_ASSERT( isValid() );
649 Q_ASSERT( isValid() );
656 return mTimes.size();
666 Q_ASSERT( isValid() );
668 for (
int time_index = 0; time_index < group.
datasetCount(); ++time_index )
670 const std::shared_ptr<QgsMeshMemoryDataset> output = canditateDataset( group, time_index );
672 for (
int n = 0; n < output->values.size(); ++n )
674 const double val1 = output->values[n].scalar();
675 double res_val = D_NODATA;
676 if ( !std::isnan( val1 ) )
677 res_val = func( val1 );
678 output->values[n] = res_val;
689 Q_ASSERT( isValid() );
692 expand( group1, group2 );
694 for (
int time_index = 0; time_index < datasetCount( group1, group2 ); ++time_index )
696 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, time_index );
697 const std::shared_ptr<const QgsMeshMemoryDataset> o2 = constCandidateDataset( group2, time_index );
699 for (
int n = 0; n < o2->values.size(); ++n )
701 const double val1 = o1->values[n].scalar();
702 const double val2 = o2->values[n].scalar();
703 double res_val = D_NODATA;
704 if ( !std::isnan( val1 ) && !std::isnan( val2 ) )
705 res_val = func( val1, val2 );
706 o1->values[n] = res_val;
716void QgsMeshCalcUtils::funcAggr(
QgsMeshMemoryDatasetGroup &group1, std::function<
double( QVector<double> & )> func )
const
718 Q_ASSERT( isValid() );
723 output->time = mTimes[0];
724 for (
int n = 0; n < mMeshLayer->dataProvider()->vertexCount(); ++n )
726 QVector< double > vals;
727 for (
int datasetIndex = 0; datasetIndex < group1.
datasetCount(); ++datasetIndex )
729 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
731 const double val1 = o1->values[n].scalar();
735 if ( !std::isnan( val1 ) )
737 vals.push_back( val1 );
741 double res_val = D_NODATA;
742 if ( !vals.isEmpty() )
744 res_val = func( vals );
747 output->values[n] = res_val;
759 output->time = mTimes[0];
761 const int facesCount = mMeshLayer->dataProvider()->faceCount();
762 output->values.resize( facesCount );
764 for (
int n = 0; n < mMeshLayer->dataProvider()->faceCount(); ++n )
766 QVector< double > vals;
767 for (
int datasetIndex = 0; datasetIndex < group1.
datasetCount(); ++datasetIndex )
769 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
770 const double val1 = o1->values[n].scalar();
771 if ( !std::isnan( val1 ) )
773 vals.push_back( val1 );
777 double res_val = D_NODATA;
778 if ( !vals.isEmpty() )
780 res_val = func( vals );
783 output->values[n] = res_val;
794 Q_ASSERT( mMeshLayer->triangularMesh() );
795 return mMeshLayer->triangularMesh();
798const QgsMesh *QgsMeshCalcUtils::nativeMesh()
const
801 const QgsMesh *res = mMeshLayer->nativeMesh();
806void QgsMeshCalcUtils::updateMesh()
const
808 if ( !mMeshLayer->nativeMesh() )
811 mMeshLayer->updateTriangularMesh();
822 Q_ASSERT( isValid() );
825 expand( trueGroup, condition );
826 expand( trueGroup, falseGroup );
831 for (
int time_index = 0; time_index < trueGroup.
datasetCount(); ++time_index )
833 const std::shared_ptr<QgsMeshMemoryDataset> true_o = canditateDataset( trueGroup, time_index );
834 const std::shared_ptr<const QgsMeshMemoryDataset> false_o = constCandidateDataset( falseGroup, time_index );
835 const std::shared_ptr<const QgsMeshMemoryDataset> condition_o = constCandidateDataset( condition, time_index );
836 for (
int n = 0; n < true_o->values.size(); ++n )
838 const double conditionValue = condition_o->values[n].scalar();
839 double resultValue = D_NODATA;
840 if ( !std::isnan( conditionValue ) )
843 resultValue = true_o->values[n].scalar();
845 resultValue = false_o->values[n].scalar();
847 true_o->values[n] = resultValue;
854 activate( true_o, condition_o );
862 Q_ASSERT( isValid() );
866 for (
int datasetIndex = 0; datasetIndex < group.
datasetCount(); ++datasetIndex )
868 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group, datasetIndex );
876void QgsMeshCalcUtils::activate(
877 std::shared_ptr<QgsMeshMemoryDataset> dataset, std::shared_ptr<const QgsMeshMemoryDataset> refDataset
880 Q_ASSERT( isValid() );
884 for (
int idx = 0; idx < mMeshLayer->dataProvider()->faceCount(); ++idx )
886 if ( refDataset && !refDataset->active.isEmpty() && ( !refDataset->active[idx] ) )
888 dataset->active[idx] =
false;
892 if ( !dataset->active[idx] )
899 bool isActive =
true;
900 for (
int j = 0; j < face.size(); ++j )
902 if ( std::isnan( dataset->values[face[j]].scalar() ) )
908 dataset->active[idx] = isActive;
912double QgsMeshCalcUtils::ffilter(
double val1,
double filter )
const
914 Q_ASSERT( !std::isnan( val1 ) );
922double QgsMeshCalcUtils::fadd(
double val1,
double val2 )
const
924 Q_ASSERT( !std::isnan( val1 ) );
925 Q_ASSERT( !std::isnan( val2 ) );
929double QgsMeshCalcUtils::fsubtract(
double val1,
double val2 )
const
931 Q_ASSERT( !std::isnan( val1 ) );
932 Q_ASSERT( !std::isnan( val2 ) );
936double QgsMeshCalcUtils::fmultiply(
double val1,
double val2 )
const
938 Q_ASSERT( !std::isnan( val1 ) );
939 Q_ASSERT( !std::isnan( val2 ) );
943double QgsMeshCalcUtils::fdivide(
double val1,
double val2 )
const
945 Q_ASSERT( !std::isnan( val1 ) );
946 Q_ASSERT( !std::isnan( val2 ) );
953double QgsMeshCalcUtils::fpower(
double val1,
double val2 )
const
955 Q_ASSERT( !std::isnan( val1 ) );
956 Q_ASSERT( !std::isnan( val2 ) );
957 return pow( val1, val2 );
960double QgsMeshCalcUtils::fequal(
double val1,
double val2 )
const
962 Q_ASSERT( !std::isnan( val1 ) );
963 Q_ASSERT( !std::isnan( val2 ) );
974double QgsMeshCalcUtils::fnotEqual(
double val1,
double val2 )
const
976 Q_ASSERT( !std::isnan( val1 ) );
977 Q_ASSERT( !std::isnan( val2 ) );
988double QgsMeshCalcUtils::fgreaterThan(
double val1,
double val2 )
const
990 Q_ASSERT( !std::isnan( val1 ) );
991 Q_ASSERT( !std::isnan( val2 ) );
1002double QgsMeshCalcUtils::flesserThan(
double val1,
double val2 )
const
1004 Q_ASSERT( !std::isnan( val1 ) );
1005 Q_ASSERT( !std::isnan( val2 ) );
1016double QgsMeshCalcUtils::flesserEqual(
double val1,
double val2 )
const
1018 Q_ASSERT( !std::isnan( val1 ) );
1019 Q_ASSERT( !std::isnan( val2 ) );
1030double QgsMeshCalcUtils::fgreaterEqual(
double val1,
double val2 )
const
1032 Q_ASSERT( !std::isnan( val1 ) );
1033 Q_ASSERT( !std::isnan( val2 ) );
1045double QgsMeshCalcUtils::flogicalAnd(
double val1,
double val2 )
const
1047 Q_ASSERT( !std::isnan( val1 ) );
1048 Q_ASSERT( !std::isnan( val2 ) );
1051 if ( bval1 && bval2 )
1057double QgsMeshCalcUtils::flogicalOr(
double val1,
double val2 )
const
1059 Q_ASSERT( !std::isnan( val1 ) );
1060 Q_ASSERT( !std::isnan( val2 ) );
1063 if ( bval1 || bval2 )
1069double QgsMeshCalcUtils::flogicalNot(
double val1 )
const
1071 Q_ASSERT( !std::isnan( val1 ) );
1079double QgsMeshCalcUtils::fchangeSign(
double val1 )
const
1081 Q_ASSERT( !std::isnan( val1 ) );
1085double QgsMeshCalcUtils::fmin(
double val1,
double val2 )
const
1087 Q_ASSERT( !std::isnan( val1 ) );
1099double QgsMeshCalcUtils::fmax(
double val1,
double val2 )
const
1101 Q_ASSERT( !std::isnan( val1 ) );
1102 Q_ASSERT( !std::isnan( val2 ) );
1113double QgsMeshCalcUtils::fabs(
double val1 )
const
1115 Q_ASSERT( !std::isnan( val1 ) );
1126double QgsMeshCalcUtils::fsumAggregated( QVector<double> &vals )
const
1128 Q_ASSERT( !vals.contains( D_NODATA ) );
1129 Q_ASSERT( !vals.isEmpty() );
1130 return std::accumulate( vals.begin(), vals.end(), 0.0 );
1133double QgsMeshCalcUtils::fminimumAggregated( QVector<double> &vals )
const
1135 Q_ASSERT( !vals.contains( D_NODATA ) );
1136 Q_ASSERT( !vals.isEmpty() );
1137 return *std::min_element( vals.begin(), vals.end() );
1140double QgsMeshCalcUtils::fmaximumAggregated( QVector<double> &vals )
const
1142 Q_ASSERT( !vals.contains( D_NODATA ) );
1143 Q_ASSERT( !vals.isEmpty() );
1144 return *std::max_element( vals.begin(), vals.end() );
1147double QgsMeshCalcUtils::faverageAggregated( QVector<double> &vals )
const
1149 Q_ASSERT( !vals.contains( D_NODATA ) );
1150 Q_ASSERT( !vals.isEmpty() );
1151 return fsumAggregated( vals ) / vals.size();
1156 return func1( group1, std::bind( &QgsMeshCalcUtils::flogicalNot,
this, std::placeholders::_1 ) );
1161 return func1( group1, std::bind( &QgsMeshCalcUtils::fchangeSign,
this, std::placeholders::_1 ) );
1166 return func1( group1, std::bind( &QgsMeshCalcUtils::fabs,
this, std::placeholders::_1 ) );
1171 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fadd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1176 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fsubtract,
this, std::placeholders::_1, std::placeholders::_2 ) );
1181 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fmultiply,
this, std::placeholders::_1, std::placeholders::_2 ) );
1186 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fdivide,
this, std::placeholders::_1, std::placeholders::_2 ) );
1191 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fpower,
this, std::placeholders::_1, std::placeholders::_2 ) );
1196 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fequal,
this, std::placeholders::_1, std::placeholders::_2 ) );
1201 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fnotEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1206 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fgreaterThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1211 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::flesserThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1216 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::flesserEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1221 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fgreaterEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1226 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::flogicalAnd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1231 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::flogicalOr,
this, std::placeholders::_1, std::placeholders::_2 ) );
1236 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fmin,
this, std::placeholders::_1, std::placeholders::_2 ) );
1241 return func2( group1, group2, std::bind( &QgsMeshCalcUtils::fmax,
this, std::placeholders::_1, std::placeholders::_2 ) );
1246 QHash<QString, int> names;
1248 for (
const int groupId : groupIndexes )
1251 const QString name = meta.
name();
1252 names[name] = groupId;
1254 for (
const QString &datasetGroupName : usedGroupNames )
1256 if ( names.contains( datasetGroupName ) )
1258 const int groupId = names.value( datasetGroupName );
1276 populateSpatialFilter( filter, extent );
1277 return func2( group1, filter, std::bind( &QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1283 populateMaskFilter( filter, mask );
1284 return func2( group1, filter, std::bind( &QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1289 return funcAggr( group1, std::bind( &QgsMeshCalcUtils::fsumAggregated,
this, std::placeholders::_1 ) );
1294 return funcAggr( group1, std::bind( &QgsMeshCalcUtils::fminimumAggregated,
this, std::placeholders::_1 ) );
1299 return funcAggr( group1, std::bind( &QgsMeshCalcUtils::fmaximumAggregated,
this, std::placeholders::_1 ) );
1304 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.
A block of integers/doubles from a mesh dataset.
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.
An 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.
Represents a single mesh 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.
Represents a mesh 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.
static QgsGeometry toGeometry(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns face as polygon geometry.
A rectangle specified with double values.
A triangular/derived mesh with vertices in map coordinates.
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.