Skip to content
Snippets Groups Projects
Commit 66f861fa authored by Lucas Givord's avatar Lucas Givord
Browse files

vtkMergeArrays: fix missing temporal information

(cherry picked from commit 768d2ef0)
parent 8f9bd113
No related branches found
No related tags found
No related merge requests found
# Fix MergeArrays filter for temporal datas
MergeArrays now ensure to forward time informations from the input to the output.
......@@ -14,6 +14,10 @@
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkSmartPointer.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include <set>
#include <vector>
VTK_ABI_NAMESPACE_BEGIN
vtkStandardNewMacro(vtkMergeArrays);
......@@ -111,6 +115,62 @@ int vtkMergeArrays::FillInputPortInformation(int vtkNotUsed(port), vtkInformatio
return 1;
}
//------------------------------------------------------------------------------
int vtkMergeArrays::RequestInformation(vtkInformation* vtkNotUsed(request),
vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
int numberOfInputs = inputVector[0]->GetNumberOfInformationObjects();
if (numberOfInputs < 2)
{
vtkErrorMacro(<< "This filter needs at least 2 inputs.");
return 0;
}
vtkInformation* outInfo = outputVector->GetInformationObject(0);
// Aggregates time values
std::set<double> allTimeSteps;
for (int idx = 0; idx < numberOfInputs; ++idx)
{
vtkInformation* inInfo = inputVector[0]->GetInformationObject(idx);
if (!inInfo)
{
continue;
}
if (!inInfo->Has(vtkStreamingDemandDrivenPipeline::TIME_STEPS()))
{
continue;
}
int numberOfTimeSteps = inInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
double* values = inInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
for (int step = 0; step < numberOfTimeSteps; step++)
{
allTimeSteps.insert(values[step]);
}
}
if (allTimeSteps.empty())
{
// Not having any timesteps is fine, just return.
return 1;
}
// Forward these timesteps to the output
std::vector<double> allTimeStepsVec(allTimeSteps.begin(), allTimeSteps.end());
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), allTimeStepsVec.data(),
static_cast<int>(allTimeStepsVec.size()));
double timeRange[2];
timeRange[0] = allTimeStepsVec.front();
timeRange[1] = allTimeStepsVec.back();
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2);
return 1;
}
//------------------------------------------------------------------------------
int vtkMergeArrays::RequestData(vtkInformation* vtkNotUsed(request),
vtkInformationVector** inputVector, vtkInformationVector* outputVector)
......
......@@ -66,9 +66,17 @@ protected:
virtual int MergeDataObjectFields(vtkDataObject* input, int inputIndex, vtkDataObject* output);
///@}
// see algorithm for more info
/**
* Make sure that this filter can take a dynamic number of input.
*/
int FillInputPortInformation(int port, vtkInformation* info) override;
/**
* Gets the metadata from input informations and aggregates time information to the output.
*/
int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment