Commit f0f36ed1 authored by Dave Demarle's avatar Dave Demarle
Browse files

ENH: Allow fetch to use different reduction algorithms for each composite data...

ENH: Allow fetch to use different reduction algorithms for each composite data type. This way multiblock data appears as multiblock data on the client.
parent 8a5c0060
......@@ -16,14 +16,13 @@
#include "vtkCellData.h"
#include "vtkDataObject.h"
#include "vtkMultiGroupDataSet.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkMultiBlockMergeFilter, "1.3");
vtkCxxRevisionMacro(vtkMultiBlockMergeFilter, "1.4");
vtkStandardNewMacro(vtkMultiBlockMergeFilter);
vtkMultiBlockMergeFilter::vtkMultiBlockMergeFilter()
......@@ -40,36 +39,16 @@ int vtkMultiBlockMergeFilter::RequestData(
vtkInformationVector *outputVector)
{
vtkInformation* info = outputVector->GetInformationObject(0);
vtkMultiGroupDataSet *output = vtkMultiGroupDataSet::SafeDownCast(
vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
info->Get(vtkDataObject::DATA_OBJECT()));
if (!output) {return 0;}
int numInputs = inputVector[0]->GetNumberOfInformationObjects();
//determine if we have a parallel partitioned mb data set to merge
int allMBs = 1;
for (int idx = 0; idx < numInputs; ++idx)
{
vtkDataObject* input = 0;
vtkInformation* inInfo = inputVector[0]->GetInformationObject(idx);
if (inInfo)
{
input = inInfo->Get(vtkDataObject::DATA_OBJECT());
}
if (input && !input->IsA("vtkMultiBlockDataSet"))
{
allMBs = 0;
break;
}
}
if (!allMBs)
{
//we do not, let the superclass append all of the inputs
//cerr << "reverting to superclass" << endl;
return this->Superclass::RequestData(request,inputVector,outputVector);
}
unsigned int updatePiece = static_cast<unsigned int>(
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()));
unsigned int updateNumPieces = static_cast<unsigned int>(
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()));
int numInputs = inputVector[0]->GetNumberOfInformationObjects();
if (numInputs<0)
{
vtkErrorMacro("Too many inputs to algorithm.")
......@@ -93,7 +72,7 @@ int vtkMultiBlockMergeFilter::RequestData(
{
//shallow copy first input to output to start off with
//cerr << "Copy first input" << endl;
output->ShallowCopy(vtkMultiGroupDataSet::SafeDownCast(input));
output->ShallowCopy(vtkMultiBlockDataSet::SafeDownCast(input));
first = 0;
}
else
......@@ -126,6 +105,28 @@ int vtkMultiBlockMergeFilter::RequestData(
return !first;
}
void vtkMultiBlockMergeFilter::AddInput(vtkDataObject* input)
{
this->AddInput(0, input);
}
void vtkMultiBlockMergeFilter::AddInput(int index, vtkDataObject* input)
{
if(input)
{
this->AddInputConnection(index, input->GetProducerPort());
}
}
int vtkMultiBlockMergeFilter::FillInputPortInformation(
int, vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkMultiBlockDataSet");
info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1);
info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1);
return 1;
}
void vtkMultiBlockMergeFilter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
......
......@@ -12,19 +12,25 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMultiBlockMergeFilter - merges multiple inputs into one multi-group dataset with special treatment for multiblock inputs.
// .NAME vtkMultiBlockMergeFilter - merges multiblock inputs into a single multiblock output
// .SECTION Description
// vtkMultiBlockMergeFilter is an M to 1 filter similar to vtkMultiGroupDataGroupFilters. However where as the parent class creates N groups in the output for N inputs, this creates (when all N inputs are multiblock datasets) 1 group in the output with N datasets inside it. In actuality if the inputs have M groups, this will produce M groups, each of which has N datasets.
// vtkMultiBlockMergeFilter is an M to 1 filter similar to
// vtkMultiGroupDataGroupFilters. However where as that class creates N groups
// in the output for N inputs, this creates 1 group in the output with N
// datasets inside it. In actuality if the inputs have M groups, this will
// produce M groups, each of which has N datasets. Inside the merged group,
// the i'th data set comes from the i'th data set in the i'th input.
#ifndef __vtkMultiBlockMergeFilter_h
#define __vtkMultiBlockMergeFilter_h
#include "vtkMultiGroupDataGroupFilter.h"
#include "vtkMultiBlockDataSetAlgorithm.h"
class VTK_GRAPHICS_EXPORT vtkMultiBlockMergeFilter : public vtkMultiGroupDataGroupFilter
class VTK_GRAPHICS_EXPORT vtkMultiBlockMergeFilter
: public vtkMultiBlockDataSetAlgorithm
{
public:
vtkTypeRevisionMacro(vtkMultiBlockMergeFilter,vtkMultiGroupDataGroupFilter);
vtkTypeRevisionMacro(vtkMultiBlockMergeFilter,vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -32,6 +38,14 @@ public:
// as scalars.
static vtkMultiBlockMergeFilter *New();
// Description:
// Add an input of this algorithm. Note that these methods support
// old-style pipeline connections. When writing new code you should
// use the more general vtkAlgorithm::AddInputConnection(). See
// SetInput() for details.
void AddInput(vtkDataObject *);
void AddInput(int, vtkDataObject*);
protected:
vtkMultiBlockMergeFilter();
~vtkMultiBlockMergeFilter();
......@@ -40,6 +54,9 @@ protected:
vtkInformationVector **,
vtkInformationVector *);
virtual int FillInputPortInformation(int port, vtkInformation *info);
private:
vtkMultiBlockMergeFilter(const vtkMultiBlockMergeFilter&); // Not implemented.
void operator=(const vtkMultiBlockMergeFilter&); // Not implemented.
......
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