29 const QgsRectangle &outputExtent,
double startTime,
double endTime,
31 : mFormulaString( formulaString )
32 , mOutputFile( outputFile )
33 , mOutputExtent( outputExtent )
35 , mStartTime( startTime )
42 const QString &outputFile,
47 : mFormulaString( formulaString )
48 , mOutputFile( outputFile )
49 , mOutputMask( outputMask )
51 , mStartTime( startTime )
61 std::unique_ptr< QgsMeshCalcNode > calcNode( QgsMeshCalcNode::parseMeshCalcString( formulaString, errorString ) );
67 double startTime = -std::numeric_limits<double>::max();
68 double endTime = std::numeric_limits<double>::max();
69 QgsMeshCalcUtils dsu( layer, calcNode->usedDatasetGroupNames(), startTime, endTime );
83 if ( mOutputFile.isEmpty() )
98 std::unique_ptr< QgsMeshCalcNode > calcNode( QgsMeshCalcNode::parseMeshCalcString( mFormulaString, errorString ) );
104 QgsMeshCalcUtils dsu( mMeshLayer, calcNode->usedDatasetGroupNames(), mStartTime, mEndTime );
105 if ( !dsu.isValid() )
111 std::unique_ptr<QgsMeshMemoryDatasetGroup> outputGroup = qgis::make_unique<QgsMeshMemoryDatasetGroup> ( mOutputFile );
114 bool ok = calcNode->calculate( dsu, *outputGroup );
132 dsu.filter( *outputGroup, mOutputMask );
136 dsu.filter( *outputGroup, mOutputExtent );
138 outputGroup->isScalar =
true;
139 outputGroup->name = QFileInfo( mOutputFile ).baseName();
152 QVector<QgsMeshDataBlock> datasetValues;
153 QVector<QgsMeshDataBlock> datasetActive;
154 QVector<double> times;
156 const auto datasize = outputGroup->datasets.size();
157 datasetValues.reserve( datasize );
158 times.reserve( datasize );
160 for (
int i = 0; i < datasize; ++i )
162 const std::shared_ptr<QgsMeshMemoryDataset> dataset = outputGroup->datasets.at( i );
164 times.push_back( dataset->time );
165 datasetValues.push_back(
166 dataset->datasetValues( outputGroup->isScalar,
168 dataset->values.size() )
170 if ( !dataset->active.isEmpty() )
172 datasetActive.push_back(
173 dataset->areFacesActive(
175 dataset->active.size() )
Result
Result of the calculation.
A rectangle specified with double values.
Result processCalculation(QgsFeedback *feedback=nullptr)
Starts the calculation, writes new dataset group to file and adds it to the mesh layer.
virtual bool persistDatasetGroup(const QString &path, const QgsMeshDatasetGroupMetadata &meta, const QVector< QgsMeshDataBlock > &datasetValues, const QVector< QgsMeshDataBlock > &datasetActive, const QVector< double > ×)=0
Creates a new dataset group from a data and persists it into a destination path.
void setProgress(double progress)
Sets the current progress for the feedback object.
A geometry is the spatial representation of a feature.
QgsMeshCalculator(const QString &formulaString, const QString &outputFile, const QgsRectangle &outputExtent, double startTime, double endTime, QgsMeshLayer *layer)
Creates calculator with bounding box (rectangular) mask.
static Result expression_valid(const QString &formulaString, QgsMeshLayer *layer)
Returns whether formula is valid for particular mesh layer.
virtual QString name() const =0
Returns a provider name.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Datasets with different time outputs or not part of the mesh.
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
bool isCanceled() const
Tells whether the operation has been canceled already.
Error creating output data file.
Represents a mesh layer supporting display of data on structured or unstructured meshes.