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 );
64 const QgsMeshDataBlock active = dp->areFacesActive( index, 0, dp->faceCount() );
65 Q_ASSERT( active.
count() == dp->faceCount() );
66 for (
int value_i = 0; value_i < dp->faceCount(); ++value_i )
69 grp->addDataset( ds );
78 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::create(
const QgsMeshMemoryDatasetGroup &grp )
const 80 return create( grp.type );
85 std::shared_ptr<QgsMeshMemoryDataset> ds = std::make_shared<QgsMeshMemoryDataset>();
89 ds->values.resize( mMeshLayer->dataProvider()->vertexCount() );
90 ds->active.resize( mMeshLayer->dataProvider()->faceCount() );
91 memset( ds->active.data(), 1,
static_cast<size_t>( ds->active.size() ) *
sizeof(
int ) );
95 ds->values.resize( mMeshLayer->dataProvider()->faceCount() );
101 QgsMeshCalcUtils:: QgsMeshCalcUtils(
QgsMeshLayer *layer,
102 const QStringList &usedGroupNames,
105 : mMeshLayer( layer )
111 for (
const QString &groupName : usedGroupNames )
113 std::shared_ptr<QgsMeshMemoryDatasetGroup> ds = create( groupName );
117 mDatasetGroupMap.insert( groupName, ds );
122 bool timesPopulated =
false;
123 const auto vals = mDatasetGroupMap.values();
124 for (
const auto &ds : vals )
126 if ( ds->datasetCount() == 0 )
132 if ( ds->datasetCount() > 1 )
134 if ( timesPopulated )
136 if ( ds->datasetCount() != mTimes.size() )
143 for (
int datasetIndex = 0; datasetIndex < ds->datasetCount(); ++datasetIndex )
145 std::shared_ptr<const QgsMeshMemoryDataset> o = ds->constDataset( datasetIndex );
146 if ( timesPopulated )
156 mTimes.append( o->time );
160 timesPopulated =
true;
165 if ( mTimes.isEmpty() )
167 mTimes.push_back( 0.0 );
172 for ( QVector<double>::iterator it = mTimes.begin(); it != mTimes.end(); )
176 ( ( *it >= startTime ) && ( *it <= endTime ) ) )
179 it = mTimes.erase( it );
184 for (
const auto &ds : vals )
186 if ( ds->type != mOutputType )
194 bool QgsMeshCalcUtils::isValid()
const 204 std::shared_ptr<const QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::group(
const QString &datasetName )
const 206 return mDatasetGroupMap[datasetName];
209 void QgsMeshCalcUtils::populateSpatialFilter( QgsMeshMemoryDatasetGroup &filter,
const QgsRectangle &extent )
const 211 filter.clearDatasets();
213 std::shared_ptr<QgsMeshMemoryDataset> output = create( filter );
214 output->time = mTimes[0];
216 const QList<int> faceIndexesForRectangle = triangularMesh()->faceIndexesForRectangle( extent );
217 const QVector<int> trianglesToNativeFaces = triangularMesh()->trianglesToNativeFaces();
221 for (
const int faceIndex : faceIndexesForRectangle )
223 const int nativeIndex = trianglesToNativeFaces[faceIndex];
224 const QgsMeshFace face = nativeMesh()->face( nativeIndex );
225 for (
const int vertexIndex : face )
227 output->values[vertexIndex].set( D_TRUE );
233 for (
const int faceIndex : faceIndexesForRectangle )
235 const int nativeIndex = trianglesToNativeFaces[faceIndex];
236 output->values[nativeIndex].set( D_TRUE );
239 filter.addDataset( output );
243 void QgsMeshCalcUtils::populateMaskFilter( QgsMeshMemoryDatasetGroup &filter,
const QgsGeometry &mask )
const 245 filter.clearDatasets();
246 std::shared_ptr<QgsMeshMemoryDataset> output = create( filter );
247 output->time = mTimes[0];
249 const QVector<int> trianglesToNativeFaces = triangularMesh()->trianglesToNativeFaces();
250 const QVector<QgsMeshVertex> &vertices = triangularMesh()->vertices();
256 for (
int i = 0; i < nativeVertexCount; ++i )
261 output->values[i].set( D_TRUE );
265 output->values[i].set( D_FALSE );
271 const QVector<QgsMeshFace> &triangles = triangularMesh()->triangles();
272 for (
int i = 0; i < triangles.size(); ++i )
279 output->values[i].
set( D_TRUE );
283 output->values[i].set( D_FALSE );
287 filter.addDataset( output );
290 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::number(
double val,
double time )
const 292 Q_ASSERT( isValid() );
294 std::shared_ptr<QgsMeshMemoryDataset> output = create( mOutputType );
298 if ( std::isnan( val ) )
301 memset( output->active.data(), 0,
static_cast<size_t>( output->active.size() ) *
sizeof(
int ) );
305 for (
int i = 0; i < output->values.size(); ++i )
307 output->values[i].set( val );
314 void QgsMeshCalcUtils::number( QgsMeshMemoryDatasetGroup &group1,
double val )
const 316 Q_ASSERT( isValid() );
318 group1.datasets.clear();
319 std::shared_ptr<QgsMeshMemoryDataset> output = number( val, mTimes[0] );
320 group1.datasets.push_back( output );
324 void QgsMeshCalcUtils::ones( QgsMeshMemoryDatasetGroup &group1 )
const 326 Q_ASSERT( isValid() );
327 number( group1, 1.0 );
330 void QgsMeshCalcUtils::nodata( QgsMeshMemoryDatasetGroup &group1 )
const 332 Q_ASSERT( isValid() );
333 number( group1, D_NODATA );
337 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::copy(
338 std::shared_ptr<const QgsMeshMemoryDataset> dataset0
341 Q_ASSERT( isValid() );
342 Q_ASSERT( dataset0 );
344 std::shared_ptr<QgsMeshMemoryDataset> output = std::make_shared<QgsMeshMemoryDataset>();
345 output->values = dataset0->values;
346 output->active = dataset0->active;
347 output->time = dataset0->time;
348 output->valid = dataset0->valid;
352 void QgsMeshCalcUtils::copy( QgsMeshMemoryDatasetGroup &group1,
const QString &groupName )
const 354 Q_ASSERT( isValid() );
356 std::shared_ptr<const QgsMeshMemoryDatasetGroup> group2 = group( groupName );
359 if ( group2->datasetCount() == 1 )
362 std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( 0 );
363 std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
364 group1.addDataset( output );
368 for (
int output_index = 0; output_index < group2->datasetCount(); ++output_index )
370 std::shared_ptr<const QgsMeshMemoryDataset> o0 = group2->constDataset( output_index );
373 ( ( o0->time >= mTimes.first() ) && ( o0->time <= mTimes.last() ) )
376 std::shared_ptr<QgsMeshMemoryDataset> output = copy( o0 );
377 group1.addDataset( output );
383 void QgsMeshCalcUtils::transferDatasets( QgsMeshMemoryDatasetGroup &group1, QgsMeshMemoryDatasetGroup &group2 )
const 385 Q_ASSERT( isValid() );
387 group1.clearDatasets();
388 for (
int i = 0; i < group2.datasetCount(); ++i )
390 std::shared_ptr<QgsMeshMemoryDataset> o = group2.datasets[i];
392 group1.addDataset( o );
394 group2.clearDatasets();
397 void QgsMeshCalcUtils::expand( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 399 Q_ASSERT( isValid() );
401 if ( group2.datasetCount() > 1 )
403 if ( group1.datasetCount() == 1 )
405 const std::shared_ptr<QgsMeshMemoryDataset> o0 = group1.datasets[0];
407 for (
int i = 1; i < group2.datasetCount(); ++i )
409 std::shared_ptr<QgsMeshMemoryDataset> o = copy( o0 );
411 group1.addDataset( o );
418 std::shared_ptr<QgsMeshMemoryDataset> QgsMeshCalcUtils::canditateDataset(
419 QgsMeshMemoryDatasetGroup &group,
420 int datasetIndex )
const 422 Q_ASSERT( isValid() );
424 if ( group.datasetCount() > 1 )
426 Q_ASSERT( group.datasetCount() > datasetIndex );
427 return group.datasets[datasetIndex];
431 Q_ASSERT( group.datasetCount() == 1 );
432 return group.datasets[0];
436 std::shared_ptr<const QgsMeshMemoryDataset> QgsMeshCalcUtils::constCandidateDataset(
437 const QgsMeshMemoryDatasetGroup &group,
438 int datasetIndex )
const 440 Q_ASSERT( isValid() );
442 if ( group.datasetCount() > 1 )
444 Q_ASSERT( group.datasetCount() > datasetIndex );
445 return group.constDataset( datasetIndex );
449 Q_ASSERT( group.datasetCount() == 1 );
450 return group.constDataset( 0 );
454 int QgsMeshCalcUtils::datasetCount(
455 const QgsMeshMemoryDatasetGroup &group1,
456 const QgsMeshMemoryDatasetGroup &group2 )
const 458 Q_ASSERT( isValid() );
460 if ( ( group1.datasetCount() > 1 ) || ( group2.datasetCount() > 1 ) )
462 return mTimes.size();
470 void QgsMeshCalcUtils::func1( QgsMeshMemoryDatasetGroup &group,
471 std::function<
double(
double )> func )
const 473 Q_ASSERT( isValid() );
475 for (
int time_index = 0; time_index < group.datasetCount(); ++time_index )
477 std::shared_ptr<QgsMeshMemoryDataset> output = canditateDataset( group, time_index );
479 for (
int n = 0; n < output->values.size(); ++n )
481 double val1 = output->values[n].scalar();
482 double res_val = D_NODATA;
483 if ( !std::isnan( val1 ) )
484 res_val = func( val1 );
485 output->values[n] = res_val;
494 void QgsMeshCalcUtils::func2( QgsMeshMemoryDatasetGroup &group1,
495 const QgsMeshMemoryDatasetGroup &group2,
496 std::function<
double(
double,
double )> func )
const 498 Q_ASSERT( isValid() );
499 Q_ASSERT( group1.type == group2.type );
501 expand( group1, group2 );
503 for (
int time_index = 0; time_index < datasetCount( group1, group2 ); ++time_index )
505 std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, time_index );
506 std::shared_ptr<const QgsMeshMemoryDataset> o2 = constCandidateDataset( group2, time_index );
508 for (
int n = 0; n < o2->values.size(); ++n )
510 double val1 = o1->values[n].scalar();
511 double val2 = o2->values[n].scalar();
512 double res_val = D_NODATA;
513 if ( !std::isnan( val1 ) && !std::isnan( val2 ) )
514 res_val = func( val1, val2 );
515 o1->values[n] = res_val;
526 void QgsMeshCalcUtils::funcAggr(
527 QgsMeshMemoryDatasetGroup &group1,
528 std::function<
double( QVector<double>& )> func
531 Q_ASSERT( isValid() );
536 output->time = mTimes[0];
539 QVector < double > vals;
540 for (
int datasetIndex = 0; datasetIndex < group1.datasetCount(); ++datasetIndex )
542 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
544 double val1 = o1->values[n].scalar();
548 if ( !std::isnan( val1 ) )
550 vals.push_back( val1 );
554 double res_val = D_NODATA;
555 if ( !vals.isEmpty() )
557 res_val = func( vals );
560 output->values[n] = res_val;
566 group1.datasets.clear();
567 group1.datasets.push_back( output );
573 output->time = mTimes[0];
576 output->values.resize( facesCount );
580 QVector < double > vals;
581 for (
int datasetIndex = 0; datasetIndex < group1.datasetCount(); ++datasetIndex )
583 const std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group1, datasetIndex );
584 double val1 = o1->values[n].scalar();
585 if ( !std::isnan( val1 ) )
587 vals.push_back( val1 );
591 double res_val = D_NODATA;
592 if ( !vals.isEmpty() )
594 res_val = func( vals );
597 output->values[n] = res_val;
600 group1.datasets.clear();
601 group1.datasets.push_back( output );
612 const QgsMesh *QgsMeshCalcUtils::nativeMesh()
const 619 void QgsMeshCalcUtils::updateMesh()
const 636 void QgsMeshCalcUtils::addIf( QgsMeshMemoryDatasetGroup &trueGroup,
637 const QgsMeshMemoryDatasetGroup &falseGroup,
638 const QgsMeshMemoryDatasetGroup &condition )
const 640 Q_ASSERT( isValid() );
643 expand( trueGroup, condition );
644 expand( trueGroup, falseGroup );
646 Q_ASSERT( trueGroup.type == falseGroup.type );
647 Q_ASSERT( trueGroup.type == condition.type );
649 for (
int time_index = 0; time_index < trueGroup.datasetCount(); ++time_index )
651 std::shared_ptr<QgsMeshMemoryDataset> true_o = canditateDataset( trueGroup, time_index );
652 std::shared_ptr<const QgsMeshMemoryDataset> false_o = constCandidateDataset( falseGroup, time_index );
653 std::shared_ptr<const QgsMeshMemoryDataset> condition_o = constCandidateDataset( condition, time_index );
654 for (
int n = 0; n < true_o->values.size(); ++n )
656 double conditionValue = condition_o->values[n].scalar();
657 double resultValue = D_NODATA;
658 if ( !std::isnan( conditionValue ) )
661 resultValue = true_o->values[n].scalar();
663 resultValue = false_o->values[n].scalar();
665 true_o->values[n] = resultValue;
672 activate( true_o, condition_o );
678 void QgsMeshCalcUtils::activate( QgsMeshMemoryDatasetGroup &group )
const 680 Q_ASSERT( isValid() );
684 for (
int datasetIndex = 0; datasetIndex < group.datasetCount(); ++datasetIndex )
686 std::shared_ptr<QgsMeshMemoryDataset> o1 = canditateDataset( group, datasetIndex );
694 void QgsMeshCalcUtils::activate(
695 std::shared_ptr<QgsMeshMemoryDataset> dataset,
696 std::shared_ptr<const QgsMeshMemoryDataset> refDataset
700 Q_ASSERT( isValid() );
706 if ( refDataset && !refDataset->active.isEmpty() && ( !refDataset->active[idx] ) )
708 dataset->active[idx] =
false;
712 if ( !dataset->active[idx] )
719 bool isActive =
true;
720 for (
int j = 0; j < face.size(); ++j )
722 if ( std::isnan( dataset->values[face[j]].scalar() ) )
728 dataset->active[idx] = isActive;
732 double QgsMeshCalcUtils::ffilter(
double val1,
double filter )
const 734 Q_ASSERT( !std::isnan( val1 ) );
742 double QgsMeshCalcUtils::fadd(
double val1,
double val2 )
const 744 Q_ASSERT( !std::isnan( val1 ) );
745 Q_ASSERT( !std::isnan( val2 ) );
750 double QgsMeshCalcUtils::fsubtract(
double val1,
double val2 )
const 752 Q_ASSERT( !std::isnan( val1 ) );
753 Q_ASSERT( !std::isnan( val2 ) );
758 double QgsMeshCalcUtils::fmultiply(
double val1,
double val2 )
const 760 Q_ASSERT( !std::isnan( val1 ) );
761 Q_ASSERT( !std::isnan( val2 ) );
766 double QgsMeshCalcUtils::fdivide(
double val1,
double val2 )
const 768 Q_ASSERT( !std::isnan( val1 ) );
769 Q_ASSERT( !std::isnan( val2 ) );
777 double QgsMeshCalcUtils::fpower(
double val1,
double val2 )
const 779 Q_ASSERT( !std::isnan( val1 ) );
780 Q_ASSERT( !std::isnan( val2 ) );
781 return pow( val1, val2 );
785 double QgsMeshCalcUtils::fequal(
double val1,
double val2 )
const 787 Q_ASSERT( !std::isnan( val1 ) );
788 Q_ASSERT( !std::isnan( val2 ) );
800 double QgsMeshCalcUtils::fnotEqual(
double val1,
double val2 )
const 802 Q_ASSERT( !std::isnan( val1 ) );
803 Q_ASSERT( !std::isnan( val2 ) );
815 double QgsMeshCalcUtils::fgreaterThan(
double val1,
double val2 )
const 817 Q_ASSERT( !std::isnan( val1 ) );
818 Q_ASSERT( !std::isnan( val2 ) );
830 double QgsMeshCalcUtils::flesserThan(
double val1,
double val2 )
const 832 Q_ASSERT( !std::isnan( val1 ) );
833 Q_ASSERT( !std::isnan( val2 ) );
845 double QgsMeshCalcUtils::flesserEqual(
double val1,
double val2 )
const 847 Q_ASSERT( !std::isnan( val1 ) );
848 Q_ASSERT( !std::isnan( val2 ) );
860 double QgsMeshCalcUtils::fgreaterEqual(
double val1,
double val2 )
const 862 Q_ASSERT( !std::isnan( val1 ) );
863 Q_ASSERT( !std::isnan( val2 ) );
876 double QgsMeshCalcUtils::flogicalAnd(
double val1,
double val2 )
const 878 Q_ASSERT( !std::isnan( val1 ) );
879 Q_ASSERT( !std::isnan( val2 ) );
882 if ( bval1 && bval2 )
889 double QgsMeshCalcUtils::flogicalOr(
double val1,
double val2 )
const 891 Q_ASSERT( !std::isnan( val1 ) );
892 Q_ASSERT( !std::isnan( val2 ) );
895 if ( bval1 || bval2 )
902 double QgsMeshCalcUtils::flogicalNot(
double val1 )
const 904 Q_ASSERT( !std::isnan( val1 ) );
913 double QgsMeshCalcUtils::fchangeSign(
double val1 )
const 915 Q_ASSERT( !std::isnan( val1 ) );
919 double QgsMeshCalcUtils::fmin(
double val1,
double val2 )
const 921 Q_ASSERT( !std::isnan( val1 ) );
933 double QgsMeshCalcUtils::fmax(
double val1,
double val2 )
const 935 Q_ASSERT( !std::isnan( val1 ) );
936 Q_ASSERT( !std::isnan( val2 ) );
948 double QgsMeshCalcUtils::fabs(
double val1 )
const 950 Q_ASSERT( !std::isnan( val1 ) );
962 double QgsMeshCalcUtils::fsumAggregated( QVector<double> &vals )
const 964 Q_ASSERT( !vals.contains( D_NODATA ) );
965 Q_ASSERT( !vals.isEmpty() );
966 return std::accumulate( vals.begin(), vals.end(), 0.0 );
969 double QgsMeshCalcUtils::fminimumAggregated( QVector<double> &vals )
const 971 Q_ASSERT( !vals.contains( D_NODATA ) );
972 Q_ASSERT( !vals.isEmpty() );
973 return *std::min_element( vals.begin(), vals.end() );
976 double QgsMeshCalcUtils::fmaximumAggregated( QVector<double> &vals )
const 978 Q_ASSERT( !vals.contains( D_NODATA ) );
979 Q_ASSERT( !vals.isEmpty() );
980 return *std::max_element( vals.begin(), vals.end() );
983 double QgsMeshCalcUtils::faverageAggregated( QVector<double> &vals )
const 985 Q_ASSERT( !vals.contains( D_NODATA ) );
986 Q_ASSERT( !vals.isEmpty() );
987 return fsumAggregated( vals ) / vals.size();
990 void QgsMeshCalcUtils::logicalNot( QgsMeshMemoryDatasetGroup &group1 )
const 992 return func1( group1, std::bind( & QgsMeshCalcUtils::flogicalNot,
this, std::placeholders::_1 ) );
995 void QgsMeshCalcUtils::changeSign( QgsMeshMemoryDatasetGroup &group1 )
const 997 return func1( group1, std::bind( & QgsMeshCalcUtils::fchangeSign,
this, std::placeholders::_1 ) );
1000 void QgsMeshCalcUtils::abs( QgsMeshMemoryDatasetGroup &group1 )
const 1002 return func1( group1, std::bind( & QgsMeshCalcUtils::fabs,
this, std::placeholders::_1 ) );
1005 void QgsMeshCalcUtils::add( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1007 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fadd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1010 void QgsMeshCalcUtils::subtract( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1012 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fsubtract,
this, std::placeholders::_1, std::placeholders::_2 ) );
1015 void QgsMeshCalcUtils::multiply( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1017 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmultiply,
this, std::placeholders::_1, std::placeholders::_2 ) );
1020 void QgsMeshCalcUtils::divide( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1022 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fdivide,
this, std::placeholders::_1, std::placeholders::_2 ) );
1025 void QgsMeshCalcUtils::power( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1027 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fpower,
this, std::placeholders::_1, std::placeholders::_2 ) );
1030 void QgsMeshCalcUtils::equal( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1032 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fequal,
this, std::placeholders::_1, std::placeholders::_2 ) );
1035 void QgsMeshCalcUtils::notEqual( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1037 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fnotEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1040 void QgsMeshCalcUtils::greaterThan( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1042 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fgreaterThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1045 void QgsMeshCalcUtils::lesserThan( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1047 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flesserThan,
this, std::placeholders::_1, std::placeholders::_2 ) );
1050 void QgsMeshCalcUtils::lesserEqual( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1052 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flesserEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1055 void QgsMeshCalcUtils::greaterEqual( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1057 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fgreaterEqual,
this, std::placeholders::_1, std::placeholders::_2 ) );
1060 void QgsMeshCalcUtils::logicalAnd( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1062 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flogicalAnd,
this, std::placeholders::_1, std::placeholders::_2 ) );
1065 void QgsMeshCalcUtils::logicalOr( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1067 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::flogicalOr,
this, std::placeholders::_1, std::placeholders::_2 ) );
1070 void QgsMeshCalcUtils::minimum( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1072 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmin,
this, std::placeholders::_1, std::placeholders::_2 ) );
1075 void QgsMeshCalcUtils::maximum( QgsMeshMemoryDatasetGroup &group1,
const QgsMeshMemoryDatasetGroup &group2 )
const 1077 return func2( group1, group2, std::bind( & QgsMeshCalcUtils::fmax,
this, std::placeholders::_1, std::placeholders::_2 ) );
1080 void QgsMeshCalcUtils::filter( QgsMeshMemoryDatasetGroup &group1,
const QgsRectangle &extent )
const 1082 QgsMeshMemoryDatasetGroup filter(
"filter" );
1083 populateSpatialFilter( filter, extent );
1084 return func2( group1, filter, std::bind( & QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1087 void QgsMeshCalcUtils::filter( QgsMeshMemoryDatasetGroup &group1,
const QgsGeometry &mask )
const 1089 QgsMeshMemoryDatasetGroup filter(
"filter" );
1090 populateMaskFilter( filter, mask );
1091 return func2( group1, filter, std::bind( & QgsMeshCalcUtils::ffilter,
this, std::placeholders::_1, std::placeholders::_2 ) );
1094 void QgsMeshCalcUtils::sumAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1096 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fsumAggregated,
this, std::placeholders::_1 ) );
1099 void QgsMeshCalcUtils::minimumAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1101 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fminimumAggregated,
this, std::placeholders::_1 ) );
1104 void QgsMeshCalcUtils::maximumAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1106 return funcAggr( group1, std::bind( & QgsMeshCalcUtils::fmaximumAggregated,
this, std::placeholders::_1 ) );
1109 void QgsMeshCalcUtils::averageAggregated( QgsMeshMemoryDatasetGroup &group1 )
const 1111 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 null.
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