Skip to content
Snippets Groups Projects
Commit 5932419e authored by Mathieu Westphal (Kitware)'s avatar Mathieu Westphal (Kitware) :zap:
Browse files

Allow the use of any kind of dataset as an input to periodicFilter

parent f7e845a7
No related branches found
No related tags found
No related merge requests found
......@@ -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 *);
......
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