Commit 746fed1c authored by Ken Martin's avatar Ken Martin

ENH: some conversion to new pipeline

parent 6e910775
......@@ -24,7 +24,7 @@
#include "vtkPointData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkImageAlgorithm, "1.7");
vtkCxxRevisionMacro(vtkImageAlgorithm, "1.8");
//----------------------------------------------------------------------------
vtkImageAlgorithm::vtkImageAlgorithm()
......@@ -120,8 +120,8 @@ int vtkImageAlgorithm::ProcessRequest(vtkInformation* request,
{
output->Crop();
}
info->Set(vtkDataObject::ORIGIN(), output->GetOrigin(), 3);
info->Set(vtkDataObject::SPACING(), output->GetSpacing(), 3);
//info->Set(vtkDataObject::ORIGIN(), output->GetOrigin(), 3);
//info->Set(vtkDataObject::SPACING(), output->GetSpacing(), 3);
output->DataHasBeenGenerated();
}
}
......
......@@ -17,9 +17,12 @@
#include "vtkAbstractTransform.h"
#include "vtkIdentityTransform.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkTransformToGrid, "1.14");
vtkCxxRevisionMacro(vtkTransformToGrid, "1.15");
vtkStandardNewMacro(vtkTransformToGrid);
vtkCxxSetObjectMacro(vtkTransformToGrid,Input,vtkAbstractTransform);
......@@ -40,6 +43,7 @@ vtkTransformToGrid::vtkTransformToGrid()
this->DisplacementScale = 1.0;
this->DisplacementShift = 0.0;
this->SetNumberOfInputPorts(0);
}
//----------------------------------------------------------------------------
......@@ -89,21 +93,31 @@ void vtkTransformToGrid::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
// This method returns the largest data that can be generated.
void vtkTransformToGrid::ExecuteInformation()
void vtkTransformToGrid::ExecuteInformation (
vtkInformation * vtkNotUsed(request),
vtkInformationVector ** vtkNotUsed( inputVector ),
vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
if (this->GetInput() == NULL)
{
vtkErrorMacro("Missing input");
return;
}
// update the transform, maybe in the future make transforms part of the
// pipeline
this->Input->Update();
this->GetOutput()->SetWholeExtent(this->GridExtent);
this->GetOutput()->SetSpacing(this->GridSpacing);
this->GetOutput()->SetOrigin(this->GridOrigin);
this->GetOutput()->SetScalarType(this->GridScalarType);
this->GetOutput()->SetNumberOfScalarComponents(3);
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
this->GridExtent,6);
outInfo->Set(vtkDataObject::SPACING(),this->GridSpacing,3);
outInfo->Set(vtkDataObject::ORIGIN(),this->GridOrigin,3);
outInfo->Set(vtkDataObject::SCALAR_TYPE(),this->GridScalarType);
outInfo->Set(vtkDataObject::SCALAR_NUMBER_OF_COMPONENTS(),3);
}
//----------------------------------------------------------------------------
......@@ -337,9 +351,19 @@ void vtkTransformToGridExecute(vtkTransformToGrid *self,
}
//----------------------------------------------------------------------------
void vtkTransformToGrid::ExecuteData(vtkDataObject *output)
void vtkTransformToGrid::RequestData(
vtkInformation* vtkNotUsed( request ),
vtkInformationVector** vtkNotUsed( inputVector ),
vtkInformationVector* outputVector)
{
vtkImageData *grid = this->AllocateOutputData(output);
// get the data object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkImageData *grid = vtkImageData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
grid->SetExtent(
outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
grid->AllocateScalars();
int *extent = grid->GetExtent();
double *gridPtr = (double *)grid->GetScalarPointerForExtent(extent);
......@@ -382,7 +406,7 @@ void vtkTransformToGrid::ExecuteData(vtkDataObject *output)
//----------------------------------------------------------------------------
unsigned long vtkTransformToGrid::GetMTime()
{
unsigned long mtime = this->vtkImageSource::GetMTime();
unsigned long mtime = this->Superclass::GetMTime();
if (this->Input)
{
......
......@@ -24,15 +24,15 @@
#ifndef __vtkTransformToGrid_h
#define __vtkTransformToGrid_h
#include "vtkImageSource.h"
#include "vtkImageAlgorithm.h"
class vtkAbstractTransform;
class VTK_HYBRID_EXPORT vtkTransformToGrid : public vtkImageSource
class VTK_HYBRID_EXPORT vtkTransformToGrid : public vtkImageAlgorithm
{
public:
static vtkTransformToGrid *New();
vtkTypeRevisionMacro(vtkTransformToGrid,vtkImageSource);
vtkTypeRevisionMacro(vtkTransformToGrid,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -82,9 +82,11 @@ protected:
vtkTransformToGrid();
~vtkTransformToGrid();
void ExecuteInformation();
void ExecuteInformation (vtkInformation *,
vtkInformationVector **, vtkInformationVector *);
void ExecuteData(vtkDataObject *data);
void RequestData(vtkInformation *,
vtkInformationVector **, vtkInformationVector *);
// Description:
// Internal method to calculate the shift and scale values which
......
......@@ -14,9 +14,12 @@
=========================================================================*/
#include "vtkImageData.h"
#include "vtkDEMReader.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkDEMReader, "1.34");
vtkCxxRevisionMacro(vtkDEMReader, "1.35");
vtkStandardNewMacro(vtkDEMReader);
#define VTK_SW 0
......@@ -69,6 +72,8 @@ vtkDEMReader::vtkDEMReader()
{
this->SpatialResolution[i] = 0;
}
this->SetNumberOfInputPorts(0);
}
vtkDEMReader::~vtkDEMReader()
......@@ -80,8 +85,14 @@ vtkDEMReader::~vtkDEMReader()
}
//----------------------------------------------------------------------------
void vtkDEMReader::ExecuteInformation()
void vtkDEMReader::ExecuteInformation (
vtkInformation * vtkNotUsed(request),
vtkInformationVector ** vtkNotUsed( inputVector ),
vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
double spacing[3], origin[3];
int extent[6];
......@@ -98,24 +109,31 @@ void vtkDEMReader::ExecuteInformation()
this->ComputeExtentOriginAndSpacing (extent, origin, spacing);
// fill in the pertinent stuff from the header
this->GetOutput()->SetOrigin(origin);
this->GetOutput()->SetSpacing(spacing);
outInfo->Set(vtkDataObject::ORIGIN(),origin,3);
outInfo->Set(vtkDataObject::SPACING(),spacing,3);
this->GetOutput()->SetNumberOfScalarComponents(1);
this->GetOutput()->SetScalarType(VTK_FLOAT);
// whole dem must be read
this->GetOutput()->SetWholeExtent(extent);
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),extent,6);
}
//----------------------------------------------------------------------------
// Convert to Imaging API
void vtkDEMReader::ExecuteData(vtkDataObject *)
void vtkDEMReader::RequestData(
vtkInformation* vtkNotUsed( request ),
vtkInformationVector** vtkNotUsed( inputVector ),
vtkInformationVector* outputVector)
{
vtkImageData *output = this->GetOutput();
// get the data object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkImageData *output = vtkImageData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
output->SetExtent(output->GetWholeExtent());
output->SetExtent(
outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
output->AllocateScalars();
if (!this->FileName)
......
......@@ -25,13 +25,13 @@
#ifndef __vtkDEMReader_h
#define __vtkDEMReader_h
#include "vtkImageSource.h"
#include "vtkImageAlgorithm.h"
class VTK_IO_EXPORT vtkDEMReader : public vtkImageSource
class VTK_IO_EXPORT vtkDEMReader : public vtkImageAlgorithm
{
public:
static vtkDEMReader *New();
vtkTypeRevisionMacro(vtkDEMReader,vtkImageSource);
vtkTypeRevisionMacro(vtkDEMReader,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -106,7 +106,8 @@ public:
// Reads the DEM Type A record to compute the extent, origin and
// spacing of the image data. The number of scalar components is set
// to 1 and the output scalar type is VTK_FLOAT.
void ExecuteInformation();
void ExecuteInformation (vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
protected:
vtkDEMReader();
......@@ -138,7 +139,10 @@ protected:
double spacing[6]);
int ReadTypeARecord ();
int ReadProfiles (vtkImageData *data);
void ExecuteData(vtkDataObject *out);
void RequestData( vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
private:
vtkDEMReader(const vtkDEMReader&); // Not implemented.
void operator=(const vtkDEMReader&); // Not implemented.
......
......@@ -16,12 +16,15 @@
#include "vtkDoubleArray.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkPointData.h"
#include <math.h>
vtkCxxRevisionMacro(vtkGaussianSplatter, "1.55");
vtkCxxRevisionMacro(vtkGaussianSplatter, "1.56");
vtkStandardNewMacro(vtkGaussianSplatter);
// Construct object with dimensions=(50,50,50); automatic computation of
......@@ -56,21 +59,29 @@ vtkGaussianSplatter::vtkGaussianSplatter()
this->NullValue = 0.0;
}
void vtkGaussianSplatter::ExecuteInformation()
void vtkGaussianSplatter::ExecuteInformation (
vtkInformation * vtkNotUsed(request),
vtkInformationVector ** vtkNotUsed( inputVector ),
vtkInformationVector *outputVector)
{
vtkImageData *output = this->GetOutput();
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
// use model bounds if set
this->Origin[0] = 0;
this->Origin[1] = 0;
this->Origin[2] = 0;
if ( this->ModelBounds[0] < this->ModelBounds[1] &&
this->ModelBounds[2] < this->ModelBounds[3] &&
this->ModelBounds[4] < this->ModelBounds[5] )
{
output->SetOrigin(this->ModelBounds[0],this->ModelBounds[2],
this->ModelBounds[4]);
this->Origin[0] = this->ModelBounds[0];
this->Origin[1] = this->ModelBounds[2];
this->Origin[2] = this->ModelBounds[4];
}
// Set volume origin and data spacing
output->GetOrigin(this->Origin);
outInfo->Set(vtkDataObject::ORIGIN(), this->Origin, 3);
int i;
for (i=0; i<3; i++)
{
......@@ -81,17 +92,30 @@ void vtkGaussianSplatter::ExecuteInformation()
this->Spacing[i] = 1.0;
}
}
output->SetSpacing(this->Spacing);
outInfo->Set(vtkDataObject::SPACING(),this->Spacing,3);
output->SetWholeExtent(0, this->SampleDimensions[0] - 1,
0, this->SampleDimensions[1] - 1,
0, this->SampleDimensions[2] - 1);
output->SetScalarType(VTK_DOUBLE);
output->SetNumberOfScalarComponents(1);
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
0, this->SampleDimensions[0] - 1,
0, this->SampleDimensions[1] - 1,
0, this->SampleDimensions[2] - 1);
outInfo->Set(vtkDataObject::SCALAR_TYPE(),VTK_DOUBLE);
outInfo->Set(vtkDataObject::SCALAR_NUMBER_OF_COMPONENTS(),1);
}
void vtkGaussianSplatter::ExecuteData(vtkDataObject *outp)
void vtkGaussianSplatter::RequestData(
vtkInformation* vtkNotUsed( request ),
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// get the data object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkImageData *output = vtkImageData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
output->SetExtent(
outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
output->AllocateScalars();
vtkIdType numPts, numNewPts, ptId, idx, i;
int j, k;
int min[3], max[3];
......@@ -99,10 +123,12 @@ void vtkGaussianSplatter::ExecuteData(vtkDataObject *outp)
vtkDataArray *inNormals=NULL;
vtkDataArray *inScalars=NULL;
double loc[3], dist2, cx[3];
vtkImageData *output = this->AllocateOutputData(outp);
vtkDoubleArray *newScalars =
vtkDoubleArray::SafeDownCast(output->GetPointData()->GetScalars());
vtkDataSet *input= this->GetInput();
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkDataSet *input = vtkDataSet::SafeDownCast(
inInfo->Get(vtkDataObject::DATA_OBJECT()));
int sliceSize=this->SampleDimensions[0]*this->SampleDimensions[1];
vtkDebugMacro(<< "Splatting data");
......@@ -134,7 +160,7 @@ void vtkGaussianSplatter::ExecuteData(vtkDataObject *outp)
}
output->SetDimensions(this->GetSampleDimensions());
this->ComputeModelBounds();
this->ComputeModelBounds(input,output, outInfo);
// Set up function pointers to sample functions
//
......@@ -243,12 +269,12 @@ void vtkGaussianSplatter::ExecuteData(vtkDataObject *outp)
// Compute the size of the sample bounding box automatically from the
// input data.
void vtkGaussianSplatter::ComputeModelBounds()
void vtkGaussianSplatter::ComputeModelBounds(vtkDataSet *input,
vtkImageData *output,
vtkInformation *outInfo)
{
double *bounds, maxDist;
int i, adjustBounds=0;
vtkImageData *output = this->GetOutput();
vtkDataSet *input= this->GetInput();
// compute model bounds if not set previously
if ( this->ModelBounds[0] >= this->ModelBounds[1] ||
......@@ -284,9 +310,11 @@ void vtkGaussianSplatter::ComputeModelBounds()
}
// Set volume origin and data spacing
output->SetOrigin(this->ModelBounds[0],this->ModelBounds[2],
this->ModelBounds[4]);
output->GetOrigin(this->Origin);
outInfo->Set(vtkDataObject::ORIGIN(),
this->ModelBounds[0],this->ModelBounds[2],
this->ModelBounds[4]);
memcpy(this->Origin,outInfo->Get(vtkDataObject::ORIGIN()), sizeof(double)*6);
output->SetOrigin(this->Origin);
for (i=0; i<3; i++)
{
......@@ -297,6 +325,7 @@ void vtkGaussianSplatter::ComputeModelBounds()
this->Spacing[i] = 1.0;
}
}
outInfo->Set(vtkDataObject::SPACING(),this->Spacing,3);
output->SetSpacing(this->Spacing);
// Determine the splat propagation distance...used later
......@@ -546,3 +575,9 @@ void vtkGaussianSplatter::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "Null Value: " << this->NullValue << "\n";
}
int vtkGaussianSplatter::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
return 1;
}
......@@ -64,7 +64,7 @@
#ifndef __vtkGaussianSplatter_h
#define __vtkGaussianSplatter_h
#include "vtkDataSetToImageFilter.h"
#include "vtkImageAlgorithm.h"
#define VTK_ACCUMULATION_MODE_MIN 0
#define VTK_ACCUMULATION_MODE_MAX 1
......@@ -72,10 +72,10 @@
class vtkDoubleArray;
class VTK_IMAGING_EXPORT vtkGaussianSplatter : public vtkDataSetToImageFilter
class VTK_IMAGING_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
{
public:
vtkTypeRevisionMacro(vtkGaussianSplatter,vtkDataSetToImageFilter);
vtkTypeRevisionMacro(vtkGaussianSplatter,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -182,14 +182,20 @@ public:
// Description:
// Compute the size of the sample bounding box automatically from the
// input data. This is an internal helper function.
void ComputeModelBounds();
void ComputeModelBounds(vtkDataSet *input, vtkImageData *output,
vtkInformation *outInfo);
protected:
vtkGaussianSplatter();
~vtkGaussianSplatter() {};
virtual void ExecuteInformation();
virtual void ExecuteData(vtkDataObject *);
virtual int FillInputPortInformation(int port, vtkInformation* info);
virtual void ExecuteInformation (vtkInformation *,
vtkInformationVector **,
vtkInformationVector *);
virtual void RequestData(vtkInformation *,
vtkInformationVector **,
vtkInformationVector *);
void Cap(vtkDoubleArray *s);
int SampleDimensions[3]; // dimensions of volume to splat into
......
......@@ -30,6 +30,10 @@ ELSE ("${CXX_CONTENTS}" MATCHES ".*ThreadedExecute.*")
"vtkImageSource"
"vtkImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkDataSetToImageFilter"
"vtkImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
ENDIF ("${CXX_CONTENTS}" MATCHES ".*ThreadedExecute.*")
......
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