27 #include "qgsmeshmemorydataprovider.h"
32 const QString &outputFile,
37 : mFormulaString( formulaString )
38 , mOutputDriver( QStringLiteral(
"DAT" ) )
39 , mOutputFile( outputFile )
40 , mOutputExtent( outputExtent )
42 , mStartTime( startTime )
46 if ( !mOutputFile.isEmpty() )
47 mOutputGroupName = QFileInfo( mOutputFile ).baseName();
51 const QString &outputFile,
56 : mFormulaString( formulaString )
57 , mOutputDriver( QStringLiteral(
"DAT" ) )
58 , mOutputFile( outputFile )
59 , mOutputMask( outputMask )
61 , mStartTime( startTime )
65 if ( !mOutputFile.isEmpty() )
66 mOutputGroupName = QFileInfo( mOutputFile ).baseName();
71 const QString &outputDriver,
72 const QString &outputGroupName,
73 const QString &outputFile,
78 : mFormulaString( formulaString )
79 , mOutputDriver( outputDriver )
80 , mOutputGroupName( outputGroupName )
81 , mOutputFile( outputFile )
82 , mOutputExtent( outputExtent )
85 , mStartTime( startTime )
92 const QString &outputDriver,
93 const QString &outputGroupName,
94 const QString &outputFile,
99 : mFormulaString( formulaString )
100 , mOutputDriver( outputDriver )
101 , mOutputGroupName( outputGroupName )
102 , mOutputFile( outputFile )
103 , mOutputMask( outputMask )
106 , mStartTime( startTime )
107 , mEndTime( endTime )
108 , mMeshLayer( layer )
113 const QString &outputGroupName,
119 : mFormulaString( formulaString )
120 , mOutputGroupName( outputGroupName )
121 , mOutputExtent( outputExtent )
123 , mDestination( destination )
124 , mStartTime( startTime )
125 , mEndTime( endTime )
126 , mMeshLayer( layer )
131 const QString &outputGroupName,
137 : mFormulaString( formulaString )
138 , mOutputGroupName( outputGroupName )
139 , mOutputMask( outputMask )
141 , mDestination( destination )
142 , mStartTime( startTime )
143 , mEndTime( endTime )
144 , mMeshLayer( layer )
149 const QString &formulaString,
157 const QString &formulaString,
162 std::unique_ptr< QgsMeshCalcNode > calcNode( QgsMeshCalcNode::parseMeshCalcString( formulaString, errorString ) );
172 QgsMeshDriverMetadata::MeshDriverCapability::CanWriteVertexDatasets;
195 std::unique_ptr< QgsMeshCalcNode > calcNode( QgsMeshCalcNode::parseMeshCalcString( mFormulaString, errorString ) );
205 std::unique_ptr<QgsMeshDatasetGroup> virtualDatasetGroup =
206 std::make_unique<QgsMeshVirtualDatasetGroup> ( mOutputGroupName, mFormulaString, mMeshLayer, mStartTime * 3600 * 1000, mEndTime * 3600 * 1000 );
207 virtualDatasetGroup->initialize();
209 err = !mMeshLayer->
addDatasets( virtualDatasetGroup.release() );
223 const QgsMeshCalcUtils dsu( mMeshLayer, calcNode->usedDatasetGroupNames(), mStartTime, mEndTime );
224 if ( !dsu.isValid() )
229 std::unique_ptr<QgsMeshMemoryDatasetGroup> outputGroup = std::make_unique<QgsMeshMemoryDatasetGroup> ( mOutputGroupName, dsu.outputType() );
232 const bool ok = calcNode->calculate( dsu, *outputGroup );
250 dsu.filter( *outputGroup, mOutputMask );
254 dsu.filter( *outputGroup, mOutputExtent );
256 outputGroup->setIsScalar(
true );
269 QVector<QgsMeshDataBlock> datasetValues;
270 QVector<QgsMeshDataBlock> datasetActive;
271 QVector<double> times;
273 const auto datasize = outputGroup->datasetCount();
274 datasetValues.reserve( datasize );
275 times.reserve( datasize );
277 for (
int i = 0; i < datasize; ++i )
279 const std::shared_ptr<QgsMeshMemoryDataset> dataset = outputGroup->memoryDatasets.at( i );
281 times.push_back( dataset->time );
282 datasetValues.push_back(
283 dataset->datasetValues( outputGroup->isScalar(),
285 dataset->values.size() )
287 if ( !dataset->active.isEmpty() )
289 datasetActive.push_back(
290 dataset->areFacesActive(
292 dataset->active.size() )
298 outputGroup->initialize();
305 err = !mMeshLayer->
addDatasets( outputGroup.release() );