27 const double D_TRUE = 1.0;
28 const double D_FALSE = 0.0;
29 const double D_NODATA = std::numeric_limits<double>::quiet_NaN();
31 std::shared_ptr<QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::create(
const QString &datasetGroupName )
const 33 const auto dp = mMeshLayer->dataProvider();
34 std::shared_ptr<QgsMeshMemoryDatasetGroup> grp;
35 for (
int group_i = 0; group_i < dp->datasetGroupCount(); ++group_i )
37 const auto meta = dp->datasetGroupMetadata( group_i );
38 const QString name = meta.name();
39 if ( name == datasetGroupName )
41 grp = std::make_shared<QgsMeshMemoryDatasetGroup>();
42 grp->isScalar = meta.isScalar();
43 grp->type = meta.dataType();
44 grp->maximum = meta.maximum();
45 grp->minimum = meta.minimum();
46 grp->name = meta.name();
49 for (
int dataset_i = 0; dataset_i < dp->datasetCount( group_i ); ++dataset_i )
52 const auto dsMeta = dp->datasetMetadata( index );
53 std::shared_ptr<QgsMeshMemoryDataset> ds = create( grp->type );
54 ds->maximum = dsMeta.maximum();
55 ds->minimum = dsMeta.minimum();
56 ds->time = dsMeta.time();
57 ds->valid = dsMeta.isValid();
60 Q_ASSERT( block.
count() == count );
61 for (
int value_i = 0; value_i < count; ++value_i )
62 ds->values[value_i] = block.
value( value_i );
66 const QgsMeshDataBlock active = dp->areFacesActive( index, 0, dp->faceCount() );
67 Q_ASSERT( active.
count() == dp->faceCount() );
68 for (
int value_i = 0; value_i < dp->faceCount(); ++value_i )
71 grp->addDataset( ds );
80 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::create(
const QgsMeshMemoryDatasetGroup &grp )
const 82 return create( grp.type );
87 std::shared_ptr<QgsMeshMemoryDataset> ds = std::make_shared<QgsMeshMemoryDataset>();
91 ds->values.resize( mMeshLayer->dataProvider()->vertexCount() );
92 ds->active.resize( mMeshLayer->dataProvider()->faceCount() );
93 memset( ds->active.data(), 1,
static_cast<size_t>( ds->active.size() ) *
sizeof(
int ) );
97 ds->values.resize( mMeshLayer->dataProvider()->faceCount() );
103 QgsMeshCalcUtils:: QgsMeshCalcUtils(
QgsMeshLayer *layer,
104 const QStringList &usedGroupNames,
107 : mMeshLayer( layer )
113 for (
const QString &groupName : usedGroupNames )
115 std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = create( groupName );
119 mDatasetGroupMap.insert( groupName, ds );
124 bool timesPopulated =
false;
125 const auto vals = mDatasetGroupMap.values();
126 for (
const auto &ds : vals )
128 if ( ds->datasetCount() == 0 )
134 if ( ds->datasetCount() > 1 )
136 if ( timesPopulated )
138 if ( ds->datasetCount() != mTimes.size() )
145 for (
int datasetIndex = 0; datasetIndex < ds->datasetCount(); ++datasetIndex )
147 std::shared_ptr<const QgsMeshMemoryDataset> o = ds->constDataset( datasetIndex );
148 if ( timesPopulated )
158 mTimes.append( o->time );
162 timesPopulated =
true;
167 if ( mTimes.isEmpty() )
169 mTimes.push_back( 0.0 );
174 for ( QVector<double>::iterator it = mTimes.begin(); it != mTimes.end(); )
178 ( ( *it >= startTime ) && ( *it <= endTime ) ) )
181 it = mTimes.erase( it );
186 for (
const auto &ds : vals )
188 if ( ds->type != mOutputType )
196 bool QgsMeshCalcUtils::isValid()
const 206 std::shared_ptr<const QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::group(
const QString &datasetName )
const 208 return mDatasetGroupMap[datasetName];
211 void QgsMeshCalcUtils::populateSpatialFilter( QgsMeshMemoryDatasetGroup &filter,
const QgsRectangle &extent )
const 213 filter.clearDatasets();
215 std::shared_ptr<QgsMeshMemoryDataset> output = create( filter );
216 output->time = mTimes[0];
218 const QList<int> faceIndexesForRectangle = triangularMesh()->faceIndexesForRectangle( extent );
219 const QVector<int> trianglesToNativeFaces = triangularMesh()->trianglesToNativeFaces();
223 for (
const int faceIndex : faceIndexesForRectangle )
225 const int nativeIndex = trianglesToNativeFaces[faceIndex];
226 const QgsMeshFace face = nativeMesh()->face( nativeIndex );
227 for (
const int vertexIndex : face )
229 output->values[vertexIndex].set( D_TRUE );
235 for (
const int faceIndex : faceIndexesForRectangle )
237 const int nativeIndex = trianglesToNativeFaces[faceIndex];
238 output->values[nativeIndex].set( D_TRUE );
241 filter.addDataset( output );
245 void QgsMeshCalcUtils::populateMaskFilter( QgsMeshMemoryDatasetGroup &filter,
const QgsGeometry &mask )
const 247 filter.clearDatasets();
248 std::shared_ptr<QgsMeshMemoryDataset> output = create( filter );
249 output->time = mTimes[0];
251 const QVector<QgsMeshVertex> &vertices = triangularMesh()->vertices();
257 for (
int i = 0; i < nativeVertexCount; ++i )
262 output->values[i].set( D_TRUE );
266 output->values[i].set( D_FALSE );
272 const QVector<QgsMeshFace> &triangles = triangularMesh()->triangles();
273 for (
int i = 0; i < triangles.size(); ++i )
280 output->values[i].
set( D_TRUE );
284 output->values[i].set( D_FALSE );
288 filter.addDataset( output );
291 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::number(
double val,
double time )
const 293 Q_ASSERT( isValid() );
295 std::shared_ptr<QgsMeshMemoryDataset> output = create( mOutputType );
299 if ( std::isnan( val ) )
302 memset( output->active.data(), 0,
static_cast<size_t>( output->active.size() ) *
sizeof(
int ) );
306 for (
int i = 0; i < output->values.size(); ++i )
308 output->values[i].set( val );
315 void QgsMeshCalcUtils::number( QgsMeshMemoryDatasetGroup &group1,
double val )
const 317 Q_ASSERT( isValid() );
319 group1.datasets.clear();
320 std::shared_ptr<QgsMeshMemoryDataset> output = number( val, mTimes[0] );
321 group1.datasets.push_back( output );
325 void QgsMeshCalcUtils::ones( QgsMeshMemoryDatasetGroup &group1 )
const 327 Q_ASSERT( isValid() );
328 number( group1, 1.0 );
331 void QgsMeshCalcUtils::nodata( QgsMeshMemoryDatasetGroup &group1 )
const 333 Q_ASSERT( isValid() );
334 number( group1, D_NODATA );
338 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::copy(
339 std::shared_ptr<const QgsMeshMemoryDataset> dataset0
342 Q_ASSERT( isValid() );
343 Q_ASSERT( dataset0 );
345 std::shared_ptr<QgsMeshMemoryDataset> output = std::make_shared<QgsMeshMemoryDataset>();
346 output->values = dataset0->values;
347 output->active = dataset0->active;
348 output->time = dataset0->time;
349 output->valid = dataset0->valid;
353 void QgsMeshCalcUtils::copy( QgsMeshMemoryDatasetGroup &group1,
const QString &groupName )
const 355 Q_ASSERT( isValid() );
357 std::shared_ptr<const QgsMeshMemoryDatasetGroup> group2 = group( groupName );
360 if ( group2->datasetCount() == 1 )
363 std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( 0 );
364 std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
365 group1.addDataset( output );
369 for (
int output_index = 0; output_index < group2->datasetCount(); ++output_index )
371 std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( output_index );
374 ( ( o0->time >= mTimes.first() ) && ( o0->time <= mTimes.last() ) )
377 std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
378 group1.addDataset( output );
384 void QgsMeshCalcUtils::transferDatasets( QgsMeshMemoryDatasetGroup &group1, QgsMeshMemoryDatasetGroup &group2 )
const 386 Q_ASSERT( isValid() );
388 group1.clearDatasets();
389 for (
int i = 0; i < group2.datasetCount(); ++i )
391 std::shared_ptr<QgsMeshMemoryDataset> o = group2.datasets[i];
393 group1.addDataset( o );
395 group2.clearDatasets();
398 void QgsMeshCalcUtils::expand( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 400 Q_ASSERT( isValid() );
402 if ( group2.datasetCount() > 1 )
404 if ( group1.datasetCount() == 1 )
406 const std::shared_ptr<QgsMeshMemoryDataset> o0 = group1.datasets[0];
408 for (
int i = 1; i < group2.datasetCount(); ++i )
410 std::shared_ptr<QgsMeshMemoryDataset> o = copy( o0 );
412 group1.addDataset( o );
419 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::canditateDataset(
420 QgsMeshMemoryDatasetGroup &group,
421 int datasetIndex )
const 423 Q_ASSERT( isValid() );
425 if ( group.datasetCount() > 1 )
427 Q_ASSERT( group.datasetCount() > datasetIndex );
428 return group.datasets[datasetIndex];
432 Q_ASSERT( group.datasetCount() == 1 );
433 return group.datasets[0];
437 std::shared_ptr<const QgsMeshMemoryDataset> QgsMeshCalcUtils::constCandidateDataset(
438 const QgsMeshMemoryDatasetGroup &group,
439 int datasetIndex )
const 441 Q_ASSERT( isValid() );
443 if ( group.datasetCount() > 1 )
445 Q_ASSERT( group.datasetCount() > datasetIndex );
446 return group.constDataset( datasetIndex );
450 Q_ASSERT( group.datasetCount() == 1 );
451 return group.constDataset( 0 );
455 int QgsMeshCalcUtils::datasetCount(
456 const QgsMeshMemoryDatasetGroup &group1,
457 const QgsMeshMemoryDatasetGroup &group2 )
const 459 Q_ASSERT( isValid() );
461 if ( ( group1.datasetCount() > 1 ) || ( group2.datasetCount() > 1 ) )
463 return mTimes.size();
471 void QgsMeshCalcUtils::func1( QgsMeshMemoryDatasetGroup &group,
472 std::function<
double(
double )> func )
const 474 Q_ASSERT( isValid() );
476 for (
int time_index = 0; time_index < group.datasetCount(); ++time_index )
478 std::shared_ptr<QgsMeshMemoryDataset> output = canditateDataset( group, time_index );
480 for (
int n = 0; n < output->values.size(); ++n )
482 double val1 = output->values[n].scalar();
483 double res_val = D_NODATA;
484 if ( !std::isnan( val1 ) )
485 res_val = func( val1 );
486 output->values[n] = res_val;
495 void QgsMeshCalcUtils::func2( QgsMeshMemoryDatasetGroup &group1,
496 const QgsMeshMemoryDatasetGroup &group2,
497 std::function<
double(
double,
double )> func )
const 499 Q_ASSERT( isValid() );
500 Q_ASSERT( group1.type == group2.type );
502 expand( group1, group2 );
504 for (
int time_index = 0; time_index < datasetCount( group1, group2 ); ++time_index )
506 std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, time_index );
507 std::shared_ptr<const QgsMeshMemoryDataset> o2 = constCandidateDataset( group2, time_index );
509 for (
int n = 0; n < o2->values.size(); ++n )
511 double val1 = o1->values[n].scalar();
512 double val2 = o2->values[n].scalar();
513 double res_val = D_NODATA;
514 if ( !std::isnan( val1 ) && !std::isnan( val2 ) )
515 res_val = func( val1, val2 );
516 o1->values[n] = res_val;
527 void QgsMeshCalcUtils::funcAggr(
528 QgsMeshMemoryDatasetGroup &group1,
529 std::function<
double( QVector<double>& )> func
532 Q_ASSERT( isValid() );
537 output->time = mTimes[0];
540 QVector < double > vals;
541 for (
int datasetIndex = 0; datasetIndex < group1.datasetCount(); ++datasetIndex )
543 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
545 double val1 = o1->values[n].scalar();
549 if ( !std::isnan( val1 ) )
551 vals.push_back( val1 );
555 double res_val = D_NODATA;
556 if ( !vals.isEmpty() )
558 res_val = func( vals );
561 output->values[n] = res_val;
567 group1.datasets.clear();
568 group1.datasets.push_back( output );
574 output->time = mTimes[0];
577 output->values.resize( facesCount );
581 QVector < double > vals;
582 for (
int datasetIndex = 0; datasetIndex < group1.datasetCount(); ++datasetIndex )
584 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
585 double val1 = o1->values[n].scalar();
586 if ( !std::isnan( val1 ) )
588 vals.push_back( val1 );
592 double res_val = D_NODATA;
593 if ( !vals.isEmpty() )
595 res_val = func( vals );
598 output->values[n] = res_val;
601 group1.datasets.clear();
602 group1.datasets.push_back( output );
613 const QgsMesh *QgsMeshCalcUtils::nativeMesh()
const 620 void QgsMeshCalcUtils::updateMesh()
const 637 void QgsMeshCalcUtils::addIf( QgsMeshMemoryDatasetGroup &trueGroup,
638 const QgsMeshMemoryDatasetGroup &falseGroup,
639 const QgsMeshMemoryDatasetGroup &condition )
const 641 Q_ASSERT( isValid() );
644 expand( trueGroup, condition );
645 expand( trueGroup, falseGroup );
647 Q_ASSERT( trueGroup.type == falseGroup.type );
648 Q_ASSERT( trueGroup.type == condition.type );
650 for (
int time_index = 0; time_index < trueGroup.datasetCount(); ++time_index )
652 std::shared_ptr<QgsMeshMemoryDataset> true_o = canditateDataset( trueGroup, time_index );
653 std::shared_ptr<const QgsMeshMemoryDataset> false_o = constCandidateDataset( falseGroup, time_index );
654 std::shared_ptr<const QgsMeshMemoryDataset> condition_o = constCandidateDataset( condition, time_index );
655 for (
int n = 0; n < true_o->values.size(); ++n )
657 double conditionValue = condition_o->values[n].scalar();
658 double resultValue = D_NODATA;
659 if ( !std::isnan( conditionValue ) )
662 resultValue = true_o->values[n].scalar();
664 resultValue = false_o->values[n].scalar();
666 true_o->values[n] = resultValue;
673 activate( true_o, condition_o );
679 void QgsMeshCalcUtils::activate( QgsMeshMemoryDatasetGroup &group )
const 681 Q_ASSERT( isValid() );
685 for (
int datasetIndex = 0; datasetIndex < group.datasetCount(); ++datasetIndex )
687 std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group, datasetIndex );
695 void QgsMeshCalcUtils::activate(
696 std::shared_ptr<QgsMeshMemoryDataset> dataset,
697 std::shared_ptr<const QgsMeshMemoryDataset> refDataset
701 Q_ASSERT( isValid() );
707 if ( refDataset && !refDataset->active.isEmpty() && ( !refDataset->active[idx] ) )
709 dataset->active[idx] =
false;
713 if ( !dataset->active[idx] )
720 bool isActive =
true;
721 for (
int j = 0; j < face.size(); ++j )
723 if ( std::isnan( dataset->values[face[j]].scalar() ) )
729 dataset->active[idx] = isActive;
733 double QgsMeshCalcUtils::ffilter(
double val1,
double filter )
const 735 Q_ASSERT( !std::isnan( val1 ) );
743 double QgsMeshCalcUtils::fadd(
double val1,
double val2 )
const 745 Q_ASSERT( !std::isnan( val1 ) );
746 Q_ASSERT( !std::isnan( val2 ) );
751 double QgsMeshCalcUtils::fsubtract(
double val1,
double val2 )
const 753 Q_ASSERT( !std::isnan( val1 ) );
754 Q_ASSERT( !std::isnan( val2 ) );
759 double QgsMeshCalcUtils::fmultiply(
double val1,
double val2 )
const 761 Q_ASSERT( !std::isnan( val1 ) );
762 Q_ASSERT( !std::isnan( val2 ) );
767 double QgsMeshCalcUtils::fdivide(
double val1,
double val2 )
const 769 Q_ASSERT( !std::isnan( val1 ) );
770 Q_ASSERT( !std::isnan( val2 ) );
778 double QgsMeshCalcUtils::fpower(
double val1,
double val2 )
const 780 Q_ASSERT( !std::isnan( val1 ) );
781 Q_ASSERT( !std::isnan( val2 ) );
782 return pow( val1, val2 );
786 double QgsMeshCalcUtils::fequal(
double val1,
double val2 )
const 788 Q_ASSERT( !std::isnan( val1 ) );
789 Q_ASSERT( !std::isnan( val2 ) );
801 double QgsMeshCalcUtils::fnotEqual(
double val1,
double val2 )
const 803 Q_ASSERT( !std::isnan( val1 ) );
804 Q_ASSERT( !std::isnan( val2 ) );
816 double QgsMeshCalcUtils::fgreaterThan(
double val1,
double val2 )
const 818 Q_ASSERT( !std::isnan( val1 ) );
819 Q_ASSERT( !std::isnan( val2 ) );
831 double QgsMeshCalcUtils::flesserThan(
double val1,
double val2 )
const 833 Q_ASSERT( !std::isnan( val1 ) );
834 Q_ASSERT( !std::isnan( val2 ) );
846 double QgsMeshCalcUtils::flesserEqual(
double val1,
double val2 )
const 848 Q_ASSERT( !std::isnan( val1 ) );
849 Q_ASSERT( !std::isnan( val2 ) );
861 double QgsMeshCalcUtils::fgreaterEqual(
double val1,
double val2 )
const 863 Q_ASSERT( !std::isnan( val1 ) );
864 Q_ASSERT( !std::isnan( val2 ) );
877 double QgsMeshCalcUtils::flogicalAnd(
double val1,
double val2 )
const 879 Q_ASSERT( !std::isnan( val1 ) );
880 Q_ASSERT( !std::isnan( val2 ) );
883 if ( bval1 && bval2 )
890 double QgsMeshCalcUtils::flogicalOr(
double val1,
double val2 )
const 892 Q_ASSERT( !std::isnan( val1 ) );
893 Q_ASSERT( !std::isnan( val2 ) );
896 if ( bval1 || bval2 )
903 double QgsMeshCalcUtils::flogicalNot(
double val1 )
const 905 Q_ASSERT( !std::isnan( val1 ) );
914 double QgsMeshCalcUtils::fchangeSign(
double val1 )
const 916 Q_ASSERT( !std::isnan( val1 ) );
920 double QgsMeshCalcUtils::fmin(
double val1,
double val2 )
const 922 Q_ASSERT( !std::isnan( val1 ) );
934 double QgsMeshCalcUtils::fmax(
double val1,
double val2 )
const 936 Q_ASSERT( !std::isnan( val1 ) );
937 Q_ASSERT( !std::isnan( val2 ) );
949 double QgsMeshCalcUtils::fabs(
double val1 )
const 951 Q_ASSERT( !std::isnan( val1 ) );
963 double QgsMeshCalcUtils::fsumAggregated( QVector<double> &vals )
const 965 Q_ASSERT( !vals.contains( D_NODATA ) );
966 Q_ASSERT( !vals.isEmpty() );
967 return std::accumulate( vals.begin(), vals.end(), 0.0 );
970 double QgsMeshCalcUtils::fminimumAggregated( QVector<double> &vals )
const 972 Q_ASSERT( !vals.contains( D_NODATA ) );
973 Q_ASSERT( !vals.isEmpty() );
974 return *std::min_element( vals.begin(), vals.end() );
977 double QgsMeshCalcUtils::fmaximumAggregated( QVector<double> &vals )
const 979 Q_ASSERT( !vals.contains( D_NODATA ) );
980 Q_ASSERT( !vals.isEmpty() );
981 return *std::max_element( vals.begin(), vals.end() );
984 double QgsMeshCalcUtils::faverageAggregated( QVector<double> &vals )
const 986 Q_ASSERT( !vals.contains( D_NODATA ) );
987 Q_ASSERT( !vals.isEmpty() );
988 return fsumAggregated( vals ) / vals.size();
991 void QgsMeshCalcUtils::logicalNot( QgsMeshMemoryDatasetGroup &group1 )
const 993 return func1( group1, std::bind( & QgsMeshCalcUtils::flogicalNot,
this, std::placeholders::_1 ) );
996 void QgsMeshCalcUtils::changeSign( QgsMeshMemoryDatasetGroup &group1 )
const 998 return func1( group1, std::bind( & QgsMeshCalcUtils::fchangeSign,
this, std::placeholders::_1 ) );
1001 void QgsMeshCalcUtils::abs( QgsMeshMemoryDatasetGroup &group1 )
const 1003 return func1( group1, std::bind( & QgsMeshCalcUtils::fabs,
this, std::placeholders::_1 ) );
1006 void QgsMeshCalcUtils::add( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1008 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fadd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1011 void QgsMeshCalcUtils::subtract( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1013 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fsubtract,
this, std::placeholders::_1, std::placeholders::_2 ) );
1016 void QgsMeshCalcUtils::multiply( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1018 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmultiply,
this, std::placeholders::_1, std::placeholders::_2 ) );
1021 void QgsMeshCalcUtils::divide( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1023 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fdivide,
this, std::placeholders::_1, std::placeholders::_2 ) );
1026 void QgsMeshCalcUtils::power( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1028 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fpower,
this, std::placeholders::_1, std::placeholders::_2 ) );
1031 void QgsMeshCalcUtils::equal( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1033 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fequal,
this, std::placeholders::_1, std::placeholders::_2 ) );
1036 void QgsMeshCalcUtils::notEqual( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1038 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fnotEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1041 void QgsMeshCalcUtils::greaterThan( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1043 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fgreaterThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1046 void QgsMeshCalcUtils::lesserThan( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1048 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flesserThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1051 void QgsMeshCalcUtils::lesserEqual( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1053 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flesserEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1056 void QgsMeshCalcUtils::greaterEqual( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1058 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fgreaterEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1061 void QgsMeshCalcUtils::logicalAnd( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1063 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flogicalAnd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1066 void QgsMeshCalcUtils::logicalOr( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1068 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flogicalOr,
this, std::placeholders::_1, std::placeholders::_2 ) );
1071 void QgsMeshCalcUtils::minimum( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1073 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmin,
this, std::placeholders::_1, std::placeholders::_2 ) );
1076 void QgsMeshCalcUtils::maximum( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1078 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmax,
this, std::placeholders::_1, std::placeholders::_2 ) );
1081 void QgsMeshCalcUtils::filter( QgsMeshMemoryDatasetGroup &group1,
const QgsRectangle &extent )
const 1083 QgsMeshMemoryDatasetGroup filter(
"filter" );
1084 populateSpatialFilter( filter, extent );
1085 return func2( group1, filter, std::bind( & QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1088 void QgsMeshCalcUtils::filter( QgsMeshMemoryDatasetGroup &group1,
const QgsGeometry &mask )
const 1090 QgsMeshMemoryDatasetGroup filter(
"filter" );
1091 populateMaskFilter( filter, mask );
1092 return func2( group1, filter, std::bind( & QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1095 void QgsMeshCalcUtils::sumAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1097 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fsumAggregated,
this, std::placeholders::_1 ) );
1100 void QgsMeshCalcUtils::minimumAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1102 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fminimumAggregated,
this, std::placeholders::_1 ) );
1105 void QgsMeshCalcUtils::maximumAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1107 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fmaximumAggregated,
this, std::placeholders::_1 ) );
1110 void QgsMeshCalcUtils::averageAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1112 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::faverageAggregated,
this, std::placeholders::_1 ) );
CORE_EXPORT QgsGeometry toGeometry(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns face as polygon geometry.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
virtual int faceCount() const =0
Returns number of faces in the native mesh.
A class to represent a 2D point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
int count() const
Number of items stored in the block.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels.
A geometry is the spatial representation of a feature.
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering)
The QgsMapSettings class contains configuration for rendering of the map.
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
bool active(int index) const
Returns a value for active flag by the index For scalar and vector 2d the behavior is undefined...
QgsRectangle extent() const override
Returns the extent of the layer.
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
Contains information about the context of a rendering operation.
Mesh - vertices and faces.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
QVector< int > QgsMeshFace
List of vertex indexes.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
bool contains(const QgsPointXY *p) const
Tests for containment of a point (uses GEOS)
QgsTriangularMesh * triangularMesh()
Returns triangular mesh (nullptr before rendering)
void set(const QgsPointXY &p1, const QgsPointXY &p2)
Sets the rectangle from two QgsPoints.
QgsCoordinateReferenceSystem crs