25 #include "qgsmeshmemorydataprovider.h"
30 const QString &outputFile,
35 : mFormulaString( formulaString )
36 , mOutputDriver( QStringLiteral(
"DAT" ) )
37 , mOutputFile( outputFile )
38 , mOutputExtent( outputExtent )
40 , mStartTime( startTime )
44 if ( !mOutputFile.isEmpty() )
45 mOutputGroupName = QFileInfo( mOutputFile ).baseName();
49 const QString &outputFile,
54 : mFormulaString( formulaString )
55 , mOutputDriver( QStringLiteral(
"DAT" ) )
56 , mOutputFile( outputFile )
57 , mOutputMask( outputMask )
59 , mStartTime( startTime )
63 if ( !mOutputFile.isEmpty() )
64 mOutputGroupName = QFileInfo( mOutputFile ).baseName();
69 const QString &outputDriver,
70 const QString &outputGroupName,
71 const QString &outputFile,
76 : mFormulaString( formulaString )
77 , mOutputDriver( outputDriver )
78 , mOutputGroupName( outputGroupName )
79 , mOutputFile( outputFile )
80 , mOutputExtent( outputExtent )
83 , mStartTime( startTime )
90 const QString &outputDriver,
91 const QString &outputGroupName,
92 const QString &outputFile,
97 : mFormulaString( formulaString )
98 , mOutputDriver( outputDriver )
99 , mOutputGroupName( outputGroupName )
100 , mOutputFile( outputFile )
101 , mOutputMask( outputMask )
104 , mStartTime( startTime )
105 , mEndTime( endTime )
106 , mMeshLayer( layer )
111 const QString &outputGroupName,
117 : mFormulaString( formulaString )
118 , mOutputGroupName( outputGroupName )
119 , mOutputExtent( outputExtent )
121 , mDestination( destination )
122 , mStartTime( startTime )
123 , mEndTime( endTime )
124 , mMeshLayer( layer )
129 const QString &outputGroupName,
135 : mFormulaString( formulaString )
136 , mOutputGroupName( outputGroupName )
137 , mOutputMask( outputMask )
139 , mDestination( destination )
140 , mStartTime( startTime )
141 , mEndTime( endTime )
142 , mMeshLayer( layer )
147 const QString &formulaString,
155 const QString &formulaString,
160 std::unique_ptr< QgsMeshCalcNode > calcNode( QgsMeshCalcNode::parseMeshCalcString( formulaString, errorString ) );
170 QgsMeshDriverMetadata::MeshDriverCapability::CanWriteVertexDatasets;
193 std::unique_ptr< QgsMeshCalcNode > calcNode( QgsMeshCalcNode::parseMeshCalcString( mFormulaString, errorString ) );
203 std::unique_ptr<QgsMeshDatasetGroup> virtualDatasetGroup =
204 qgis::make_unique<QgsMeshVirtualDatasetGroup> ( mOutputGroupName, mFormulaString, mMeshLayer, mStartTime * 3600 * 1000, mEndTime * 3600 * 1000 );
205 virtualDatasetGroup->initialize();
207 err = !mMeshLayer->
addDatasets( virtualDatasetGroup.release() );
221 QgsMeshCalcUtils dsu( mMeshLayer, calcNode->usedDatasetGroupNames(), mStartTime, mEndTime );
222 if ( !dsu.isValid() )
227 std::unique_ptr<QgsMeshMemoryDatasetGroup> outputGroup = qgis::make_unique<QgsMeshMemoryDatasetGroup> ( mOutputGroupName, dsu.outputType() );
230 bool ok = calcNode->calculate( dsu, *outputGroup );
248 dsu.filter( *outputGroup, mOutputMask );
252 dsu.filter( *outputGroup, mOutputExtent );
254 outputGroup->setIsScalar(
true );
267 QVector<QgsMeshDataBlock> datasetValues;
268 QVector<QgsMeshDataBlock> datasetActive;
269 QVector<double> times;
271 const auto datasize = outputGroup->datasetCount();
272 datasetValues.reserve( datasize );
273 times.reserve( datasize );
275 for (
int i = 0; i < datasize; ++i )
277 const std::shared_ptr<QgsMeshMemoryDataset> dataset = outputGroup->memoryDatasets.at( i );
279 times.push_back( dataset->time );
280 datasetValues.push_back(
281 dataset->datasetValues( outputGroup->isScalar(),
283 dataset->values.size() )
285 if ( !dataset->active.isEmpty() )
287 datasetActive.push_back(
288 dataset->areFacesActive(
290 dataset->active.size() )
296 outputGroup->initialize();
303 err = !mMeshLayer->
addDatasets( outputGroup.release() );