Commit 92220d4a authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Kitware Robot

Merge topic 'periodicFilterInputAnyDataSetFix'

5932419e Allow the use of any kind of dataset as an input to periodicFilter
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Mathieu Westphal's avatarMathieu Westphal <mathieu.westphal@kitware.com>
Merge-request: !535
parents f2fd417a 5932419e
......@@ -16,7 +16,9 @@
#include "vtkPeriodicFilter.h"
#include "vtkDataObjectTreeIterator.h"
#include "vtkDataSet.h"
#include "vtkInformationVector.h"
#include "vtkInformation.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkMultiProcessController.h"
......@@ -69,15 +71,37 @@ void vtkPeriodicFilter::RemoveAllIndices()
this->Modified();
}
//----------------------------------------------------------------------------
int vtkPeriodicFilter::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
// now add our info
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject");
return 1;
}
//----------------------------------------------------------------------------
int vtkPeriodicFilter::RequestData(vtkInformation *vtkNotUsed(request),
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
vtkMultiBlockDataSet *input = vtkMultiBlockDataSet::GetData(inputVector[0], 0);
// Recover casted dataset
vtkDataObject* inputObject = vtkDataObject::GetData(inputVector[0], 0);
vtkDataObjectTree *input = vtkDataObjectTree::SafeDownCast(inputObject);
vtkDataSet* dsInput = vtkDataSet::SafeDownCast(inputObject);
vtkMultiBlockDataSet* mb = NULL;
vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::GetData(outputVector, 0);
if (this->Indices.empty())
if (dsInput)
{
mb = vtkMultiBlockDataSet::New();
mb->SetNumberOfBlocks(1);
mb->SetBlock(0, dsInput);
this->AddIndex(1);
input = mb;
}
else if (this->Indices.empty())
{
// Trivial case
output->ShallowCopy(input);
......@@ -144,5 +168,10 @@ int vtkPeriodicFilter::RequestData(vtkInformation *vtkNotUsed(request),
delete [] reducedPeriodNumbers;
}
iter->Delete();
if (mb != NULL)
{
mb->Delete();
}
return 1;
}
......@@ -92,6 +92,9 @@ protected:
vtkPeriodicFilter();
~vtkPeriodicFilter();
// see algorithm for more info
virtual int FillInputPortInformation(int port, vtkInformation* info);
virtual int RequestData(vtkInformation *,
vtkInformationVector **,
vtkInformationVector *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment