Commit d2627496 authored by Berk Geveci's avatar Berk Geveci
Browse files

ENH: Removing vtkMultiBlockDataSet. Use vtkHierarchicalDataSet instead

parent e2176078
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMultiBlockDataIterator.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMultiBlockDataIterator.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkMultiBlockDataSetInternal.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkMultiBlockDataIterator, "1.1");
vtkStandardNewMacro(vtkMultiBlockDataIterator);
// Note that this class is dependent on the implementation
// of the data structure in vtkMultiBlockDataSet. Changes
// to vtkMultiBlockDataSet might require changes to this class.
class vtkMultiBlockDataIteratorInternal
{
public:
vtkstd::vector< vtkSmartPointer<vtkDataObject> >::iterator Iterator;
};
//----------------------------------------------------------------------------
vtkMultiBlockDataIterator::vtkMultiBlockDataIterator()
{
this->DataSet = 0;
this->Internal = new vtkMultiBlockDataIteratorInternal;
}
//----------------------------------------------------------------------------
vtkMultiBlockDataIterator::~vtkMultiBlockDataIterator()
{
this->SetDataSet(0);
delete this->Internal;
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataIterator::SetDataSet(vtkMultiBlockDataSet* dataset)
{
if (this->DataSet != dataset)
{
if (this->DataSet)
{
this->DataSet->UnRegister(this);
}
this->DataSet = dataset;
if (this->DataSet)
{
this->DataSet->Register(this);
this->GoToFirstItem();
}
this->Modified();
}
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataIterator::GoToFirstItem()
{
if (!this->DataSet)
{
vtkErrorMacro("No data object has been set.");
return;
}
// Simply use the STL iterator from the vector
this->Internal->Iterator = this->DataSet->Internal->DataSets.begin();
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataIterator::GoToNextItem()
{
if (!this->DataSet)
{
vtkErrorMacro("No data object has been set.");
return;
}
if (!this->IsDoneWithTraversal())
{
this->Internal->Iterator++;
}
}
//----------------------------------------------------------------------------
int vtkMultiBlockDataIterator::IsDoneWithTraversal()
{
if (!this->DataSet)
{
vtkErrorMacro("No data object has been set.");
return 1;
}
if ( this->Internal->Iterator == this->DataSet->Internal->DataSets.end() )
{
return 1;
}
else
{
return 0;
}
}
//----------------------------------------------------------------------------
vtkDataObject* vtkMultiBlockDataIterator::GetCurrentDataObject()
{
if (!this->DataSet)
{
vtkErrorMacro("No data object has been set.");
return 0;
}
return this->Internal->Iterator->GetPointer();
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataIterator::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "DataSet: ";
if (this->DataSet)
{
os << endl;
this->DataSet->PrintSelf(os, indent.GetNextIndent());
}
else
{
os << "(none)" << endl;
}
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMultiBlockDataIterator.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMultiBlockDataIterator - iterator to access datasets in a vtkMultiBlockDataSet
// .SECTION Description
// vtkMultiBlockDataIterator is a concrete implementation of
// vtkCompositeDataIterator for vtkMultiBlockDataSet.
#ifndef __vtkMultiBlockDataIterator_h
#define __vtkMultiBlockDataIterator_h
#include "vtkCompositeDataIterator.h"
class vtkMultiBlockDataSet;
class vtkMultiBlockDataIteratorInternal;
class VTK_FILTERING_EXPORT vtkMultiBlockDataIterator : public vtkCompositeDataIterator
{
public:
static vtkMultiBlockDataIterator *New();
vtkTypeRevisionMacro(vtkMultiBlockDataIterator,vtkCompositeDataIterator);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Move the iterator to the beginning of the collection.
virtual void GoToFirstItem();
// Description:
// Move the iterator to the next item in the collection.
virtual void GoToNextItem();
// Description:
// Test whether the iterator is currently pointing to a valid
// item. Returns 1 for yes, 0 for no.
virtual int IsDoneWithTraversal();
// Description:
// Get the current item. Valid only when IsDoneWithTraversal()
// returns 1.
virtual vtkDataObject* GetCurrentDataObject();
// Description:
// Set the data object to iterator over.
void SetDataSet(vtkMultiBlockDataSet* dataset);
vtkGetObjectMacro(DataSet, vtkMultiBlockDataSet);
protected:
vtkMultiBlockDataIterator();
virtual ~vtkMultiBlockDataIterator();
vtkMultiBlockDataSet* DataSet;
vtkMultiBlockDataIteratorInternal* Internal;
private:
vtkMultiBlockDataIterator(const vtkMultiBlockDataIterator&); // Not implemented.
void operator=(const vtkMultiBlockDataIterator&); // Not implemented.
};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMultiBlockDataSet.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
#include "vtkMultiBlockDataIterator.h"
#include "vtkMultiBlockDataSetInternal.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkMultiBlockDataSet, "1.4");
vtkStandardNewMacro(vtkMultiBlockDataSet);
//----------------------------------------------------------------------------
vtkMultiBlockDataSet::vtkMultiBlockDataSet()
{
this->Internal = new vtkMultiBlockDataSetInternal;
}
//----------------------------------------------------------------------------
vtkMultiBlockDataSet::~vtkMultiBlockDataSet()
{
delete this->Internal;
}
//----------------------------------------------------------------------------
unsigned int vtkMultiBlockDataSet::GetNumberOfDataSets()
{
return this->Internal->DataSets.size();
}
//----------------------------------------------------------------------------
vtkDataObject* vtkMultiBlockDataSet::GetDataSet(unsigned int idx)
{
if ( idx >= this->Internal->DataSets.size() )
{
return 0;
}
return this->Internal->DataSets[idx];
}
//----------------------------------------------------------------------------
vtkDataObject* vtkMultiBlockDataSet::GetDataSet(vtkInformation* index)
{
if (index->Has(INDEX()))
{
return this->GetDataSet(index->Get(INDEX()));
}
return 0;
}
//----------------------------------------------------------------------------
unsigned int vtkMultiBlockDataSet::AddDataSet(vtkDataObject* data)
{
if (data)
{
this->Internal->DataSets.push_back(data);
this->Modified();
}
return this->Internal->DataSets.size() - 1;
}
//----------------------------------------------------------------------------
vtkCompositeDataIterator* vtkMultiBlockDataSet::NewIterator()
{
vtkMultiBlockDataIterator* iter = vtkMultiBlockDataIterator::New();
iter->SetDataSet(this);
return iter;
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataSet::Initialize()
{
this->Superclass::Initialize();
this->Internal->DataSets.clear();
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataSet::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMultiBlockDataSet.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMultiBlockDataSet - collection of data objects
// .SECTION Description
// vtkMultiBlockDataSet represents a collection of data objects.
// The data objects can be primitive datasets as well as other
// composite datasets.
// No relation (spatial or hierarchical) between data objects is
// specified or enforced.
#ifndef __vtkMultiBlockDataSet_h
#define __vtkMultiBlockDataSet_h
#include "vtkCompositeDataSet.h"
class vtkDataSet;
class vtkMultiBlockDataIterator;
class vtkMultiBlockDataSetInternal;
class VTK_FILTERING_EXPORT vtkMultiBlockDataSet : public vtkCompositeDataSet
{
public:
static vtkMultiBlockDataSet *New();
vtkTypeRevisionMacro(vtkMultiBlockDataSet,vtkCompositeDataSet);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Return a new iterator (has to be deleted by user)
virtual vtkCompositeDataIterator* NewIterator();
// Description:
// Return class name of data type (see vtkSystemIncludes.h for
// definitions.
virtual int GetDataObjectType() {return VTK_MULTI_BLOCK_DATA_SET;}
// Description:
// Add a dataset to the collection. Returns the index of
// the added dataset.
unsigned int AddDataSet(vtkDataObject* data);
// Description:
// Calls AddDataSet(dobj)
virtual void AddDataSet(vtkInformation*, vtkDataObject* dobj)
{
this->AddDataSet(dobj);
}
// Description:
// Restore data object to initial state,
virtual void Initialize();
// Description:
// Returns the number of datasets
unsigned int GetNumberOfDataSets();
// Description:
// Returns dataset with given id
vtkDataObject* GetDataSet(unsigned int idx);
// Description:
// Passes the INDEX() key to GetDataSet(idx)
virtual vtkDataObject* GetDataSet(vtkInformation* index);
//BTX
// Note that vtkMultiBlockDataIterator is dependent on the implementation
// of the data structure in this class. Changes to the data structure
// might require changes to vtkMultiBlockDataIterator.
friend class vtkMultiBlockDataIterator;
//ETX
protected:
vtkMultiBlockDataSet();
~vtkMultiBlockDataSet();
vtkMultiBlockDataSetInternal* Internal;
private:
vtkMultiBlockDataSet(const vtkMultiBlockDataSet&); // Not implemented.
void operator=(const vtkMultiBlockDataSet&); // Not implemented.
};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMultiBlockDataSetAlgorithm.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMultiBlockDataSetAlgorithm.h"
#include "vtkCommand.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkDataSet.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkMultiBlockDataSetAlgorithm, "1.2");
vtkStandardNewMacro(vtkMultiBlockDataSetAlgorithm);
//----------------------------------------------------------------------------
// Instantiate object so that cell data is not passed to output.
vtkMultiBlockDataSetAlgorithm::vtkMultiBlockDataSetAlgorithm()
{
this->SetNumberOfInputPorts(1);
this->SetNumberOfOutputPorts(1);
}
//----------------------------------------------------------------------------
vtkMultiBlockDataSet* vtkMultiBlockDataSetAlgorithm::GetOutput()
{
return this->GetOutput(0);
}
//----------------------------------------------------------------------------
vtkMultiBlockDataSet* vtkMultiBlockDataSetAlgorithm::GetOutput(int port)
{
vtkDataObject* output =
vtkCompositeDataPipeline::SafeDownCast(this->GetExecutive())->
GetCompositeOutputData(port);
return vtkMultiBlockDataSet::SafeDownCast(output);
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataSetAlgorithm::SetInput(vtkDataObject* input)
{
this->SetInput(0, input);
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataSetAlgorithm::SetInput(int index, vtkDataObject* input)
{
if(input)
{
this->SetInputConnection(index, input->GetProducerPort());
}
else
{
// Setting a NULL input removes the connection.
this->SetInputConnection(index, 0);
}
}
//----------------------------------------------------------------------------
vtkDataObject* vtkMultiBlockDataSetAlgorithm::GetInput(int port)
{
if (this->GetNumberOfInputConnections(port) < 1)
{
return 0;
}
return this->GetExecutive()->GetInputData(port, 0);
}
//----------------------------------------------------------------------------
int vtkMultiBlockDataSetAlgorithm::ProcessRequest(
vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// generate the data
if(request->Has(vtkCompositeDataPipeline::REQUEST_COMPOSITE_DATA()))
{
int retVal = this->RequestCompositeData(request, inputVector, outputVector);
return retVal;
}
// execute information
if(request->Has(vtkCompositeDataPipeline::REQUEST_COMPOSITE_INFORMATION()))
{
return this->RequestCompositeInformation(request, inputVector, outputVector);
}
// set update extent
if(request->Has(
vtkCompositeDataPipeline::REQUEST_COMPOSITE_UPDATE_EXTENT()))
{
return this->ComputeCompositeInputUpdateExtent(
request, inputVector, outputVector);
}
return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}
//----------------------------------------------------------------------------
int vtkMultiBlockDataSetAlgorithm::FillOutputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
// now add our info
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkDataObject");
info->Set(vtkCompositeDataPipeline::COMPOSITE_DATA_TYPE_NAME(),
"vtkMultiBlockDataSet");
return 1;
}
//----------------------------------------------------------------------------
int vtkMultiBlockDataSetAlgorithm::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
// now add our info
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkMultiBlockDataSet");
return 1;
}
//----------------------------------------------------------------------------
vtkExecutive* vtkMultiBlockDataSetAlgorithm::CreateDefaultExecutive()
{
return vtkCompositeDataPipeline::New();
}
//----------------------------------------------------------------------------
void vtkMultiBlockDataSetAlgorithm::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMultiBlockDataSetAlgorithm.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMultiBlockDataSetAlgorithm -
// .SECTION Description
#ifndef __vtkMultiBlockDataSetAlgorithm_h
#define __vtkMultiBlockDataSetAlgorithm_h
#include "vtkAlgorithm.h"
class vtkMultiBlockDataSet;
class VTK_FILTERING_EXPORT vtkMultiBlockDataSetAlgorithm : public vtkAlgorithm
{
public:
static vtkMultiBlockDataSetAlgorithm *New();
vtkTypeRevisionMacro(vtkMultiBlockDataSetAlgorithm,vtkAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get the output data object for a port on this algorithm.
vtkMultiBlockDataSet* GetOutput();
vtkMultiBlockDataSet* GetOutput(int);
// Description:
// Set an input of this algorithm.
void SetInput(vtkDataObject*);
void SetInput(int, vtkDataObject*);
// Description:
// see vtkAlgorithm for details
virtual int ProcessRequest(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
protected:
vtkMultiBlockDataSetAlgorithm();
~vtkMultiBlockDataSetAlgorithm() {};
// This is called by the superclass.
// This is the method you should override.
virtual int RequestCompositeInformation(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*) {return 1;};
// This is called by the superclass.
// This is the method you should override.
virtual int RequestCompositeData(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*) {return 1;};
// This is called by the superclass.
// This is the method you should override.
virtual int ComputeCompositeInputUpdateExtent(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*)
{
return 1;
};