Commit 7b4b09cc authored by Ken Martin's avatar Ken Martin
Browse files

ENH: more cleanup and fixes

parent a9535e5f
......@@ -12,13 +12,15 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkDebugLeaks.h"
#include "vtkObjectFactory.h"
#include "vtkVersion.h"
#include "vtkVertex.h"
#include "vtkObjectFactoryCollection.h"
#include "vtkDebugLeaks.h"
#include "vtkOverrideInformationCollection.h"
#include "vtkOutputWindow.h"
#include "vtkOverrideInformation.h"
#include "vtkOverrideInformationCollection.h"
#include "vtkVersion.h"
#include "vtkVertex.h"
int failed = 0;
......@@ -38,7 +40,7 @@ private:
void operator=(const vtkTestVertex&);
};
vtkCxxRevisionMacro(vtkTestVertex, "1.19");
vtkCxxRevisionMacro(vtkTestVertex, "1.19.6.1");
class vtkTestVertex2 : public vtkVertex
{
......@@ -56,7 +58,7 @@ private:
void operator=(const vtkTestVertex2&);
};
vtkCxxRevisionMacro(vtkTestVertex2, "1.19");
vtkCxxRevisionMacro(vtkTestVertex2, "1.19.6.1");
VTK_CREATE_CREATE_FUNCTION(vtkTestVertex);
VTK_CREATE_CREATE_FUNCTION(vtkTestVertex2);
......@@ -105,6 +107,7 @@ void TestNewVertex(vtkVertex* v, const char* expectedClassName)
int ObjectFactory(int, char *[])
{
vtkDebugLeaks::PromptUserOff();
vtkOutputWindow::GetInstance()->PromptUserOff();
vtkGenericWarningMacro("Test Generic Warning");
TestFactory* factory = TestFactory::New();
vtkObjectFactory::RegisterFactory(factory);
......
......@@ -349,6 +349,11 @@ public:
// with only one piece (no streaming possible).
virtual int GetExtentType() { return VTK_PIECES_EXTENT; };
// Description:
// This method crops the data object (if necesary) so that the extent
// matches the update extent.
virtual void Crop();
//BTX
// Description:
// Possible values for the FIELD_ASSOCIATION information entry.
......@@ -420,10 +425,6 @@ protected:
// ImageToStructuredPoints.
int RequestExactExtent;
// This method crops the data object (if necesary) so that the extent
// matches the update extent.
virtual void Crop();
// When was this data last generated?
vtkTimeStamp UpdateTime;
......
......@@ -24,7 +24,7 @@
#include "vtkPointData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkImageAlgorithm, "1.1.2.9");
vtkCxxRevisionMacro(vtkImageAlgorithm, "1.1.2.10");
//----------------------------------------------------------------------------
vtkImageAlgorithm::vtkImageAlgorithm()
......@@ -116,13 +116,8 @@ int vtkImageAlgorithm::ProcessRequest(vtkInformation* request,
vtkImageData::SafeDownCast(info->Get(vtkDataObject::DATA_OBJECT()));
if (output)
{
// after executing set the origin and spacing from the
// WHOLE_BOUNDING_BOX
if (info->Has(vtkDataObject::ORIGIN()))
{
output->SetOrigin(info->Get(vtkDataObject::ORIGIN()));
output->SetSpacing(info->Get(vtkDataObject::SPACING()));
}
info->Set(vtkDataObject::ORIGIN(), output->GetOrigin(), 3);
info->Set(vtkDataObject::SPACING(), output->GetSpacing(), 3);
output->DataHasBeenGenerated();
}
}
......@@ -133,6 +128,20 @@ int vtkImageAlgorithm::ProcessRequest(vtkInformation* request,
if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
{
this->ExecuteInformation(request, inputVector, outputVector);
// after executing set the origin and spacing from the
// info
int i;
for (i = 0; i < this->GetNumberOfOutputPorts(); ++i)
{
vtkInformation* info = outputVector->GetInformationObject(i);
vtkImageData *output =
vtkImageData::SafeDownCast(info->Get(vtkDataObject::DATA_OBJECT()));
if (output && info->Has(vtkDataObject::ORIGIN()))
{
output->SetOrigin(info->Get(vtkDataObject::ORIGIN()));
output->SetSpacing(info->Get(vtkDataObject::SPACING()));
}
}
return 1;
}
......
......@@ -14,9 +14,9 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
# add tests that require data
SET(MyTests ${MyTests}
volProt.cxx
TestHierarchicalBox.cxx
TestHierarchicalBoxPipeline.cxx
TestMultiBlock.cxx
# TestHierarchicalBox.cxx
# TestHierarchicalBoxPipeline.cxx
# TestMultiBlock.cxx
)
ENDIF (VTK_DATA_ROOT)
CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx ${MyTests}
......
......@@ -16,10 +16,13 @@
#include "vtkCellData.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkPointData.h"
vtkCxxRevisionMacro(vtkExtractVOI, "1.37");
vtkCxxRevisionMacro(vtkExtractVOI, "1.37.6.1");
vtkStandardNewMacro(vtkExtractVOI);
//-----------------------------------------------------------------------------
......@@ -34,15 +37,19 @@ vtkExtractVOI::vtkExtractVOI()
//-----------------------------------------------------------------------------
// Get ALL of the input.
void vtkExtractVOI::ComputeInputUpdateExtent(int inExt[6],
int *)
void vtkExtractVOI::ComputeInputUpdateExtent (
vtkInformation * vtkNotUsed(request),
vtkInformationVector *inputVector,
vtkInformationVector *vtkNotUsed( outputVector ))
{
// request all of the VOI
int *wholeExtent;
// get the info objects
vtkInformation *inInfo =
this->GetInputConnectionInformation(inputVector,0,0);
// request all of the VOI, (note from Ken why are we not looking at the UE?)
int i;
wholeExtent = this->GetInput()->GetWholeExtent();
memcpy(inExt, wholeExtent, 6*sizeof(int));
int inExt[6];
inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),inExt);
// no need to go outside the VOI
for (i = 0; i < 3; ++i)
......@@ -56,23 +63,32 @@ void vtkExtractVOI::ComputeInputUpdateExtent(int inExt[6],
inExt[i*2+1] = this->VOI[i*2+1];
}
}
inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),inExt,6);
}
//-----------------------------------------------------------------------------
void
vtkExtractVOI::ExecuteInformation(vtkImageData *input, vtkImageData *output)
vtkExtractVOI::ExecuteInformation (
vtkInformation * vtkNotUsed(request),
vtkInformationVector *inputVector,
vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkInformation *inInfo =
this->GetInputConnectionInformation(inputVector,0,0);
int i, outDims[3], voi[6];
int rate[3];
int wholeExtent[6];
if (this->GetInput() == NULL)
{
vtkErrorMacro("Missing input");
return;
}
input->GetWholeExtent( wholeExtent );
int wholeExtent[6];
inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent );
double ar[3], outAR[3];
inInfo->Get(vtkDataObject::SPACING(), ar );
double origin[3], outOrigin[3];
inInfo->Get(vtkDataObject::ORIGIN(), origin );
for ( i=0; i < 6; i++ )
{
voi[i] = this->VOI[i];
......@@ -112,26 +128,36 @@ vtkExtractVOI::ExecuteInformation(vtkImageData *input, vtkImageData *output)
{
outDims[i] = 1;
}
outAR[i] = ar[i] * this->SampleRate[i];
wholeExtent[i*2] = voi[i*2];
wholeExtent[i*2+1] = voi[i*2] + outDims[i] - 1;
outOrigin[i] = origin[i] + voi[2*i]*ar[i] - wholeExtent[2*i]*outAR[i];
}
// This makes sense for sample rates of 1, 1, 1.
wholeExtent[0] = voi[0];
wholeExtent[1] = voi[0] + outDims[0] - 1;
wholeExtent[2] = voi[2];
wholeExtent[3] = voi[2] + outDims[1] - 1;
wholeExtent[4] = voi[4];
wholeExtent[5] = voi[4] + outDims[2] - 1;
output->SetWholeExtent( wholeExtent );
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent ,6);
outInfo->Set(vtkDataObject::SPACING(), outAR, 3);
outInfo->Set(vtkDataObject::ORIGIN(), outOrigin, 3);
}
//-----------------------------------------------------------------------------
void vtkExtractVOI::ExecuteData(vtkDataObject *)
void vtkExtractVOI::ExecuteData(
vtkInformation *request,
vtkInformationVector * inputVector,
vtkInformationVector * outputVector)
{
vtkImageData *input=this->GetInput();
// get the data objects
vtkInformation *outInfo =
outputVector->GetInformationObject(0);
vtkImageData *output = vtkImageData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkInformation *inInfo =
this->GetInputConnectionInformation(inputVector, 0, 0);
vtkImageData *input = vtkImageData::SafeDownCast(
inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkPointData *pd=input->GetPointData();
vtkCellData *cd=input->GetCellData();
vtkImageData *output = this->GetOutput();
output->SetExtent(output->GetWholeExtent());
vtkPointData *outPD=output->GetPointData();
vtkCellData *outCD=output->GetCellData();
......@@ -139,7 +165,8 @@ void vtkExtractVOI::ExecuteData(vtkDataObject *)
int newCellId;
double origin[3], ar[3], outOrigin[3], outAR[3];
int sliceSize, outSize, jOffset, kOffset, rate[3];
int *wholeExtent = input->GetWholeExtent();
int wholeExtent[6];
inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),wholeExtent);
int *inExt = input->GetExtent();
int *outExt = output->GetExtent();
......@@ -201,8 +228,6 @@ void vtkExtractVOI::ExecuteData(vtkDataObject *)
outSize *= outDims[i];
}
output->SetSpacing(outAR);
output->SetOrigin(outOrigin);
//
// If output same as input, just pass data through
//
......
......@@ -36,12 +36,12 @@
#ifndef __vtkExtractVOI_h
#define __vtkExtractVOI_h
#include "vtkImageToImageFilter.h"
#include "vtkImageAlgorithm.h"
class VTK_IMAGING_EXPORT vtkExtractVOI : public vtkImageToImageFilter
class VTK_IMAGING_EXPORT vtkExtractVOI : public vtkImageAlgorithm
{
public:
vtkTypeRevisionMacro(vtkExtractVOI,vtkImageToImageFilter);
vtkTypeRevisionMacro(vtkExtractVOI,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -67,10 +67,16 @@ protected:
vtkExtractVOI();
~vtkExtractVOI() {};
virtual void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
void ExecuteInformation(vtkImageData *input, vtkImageData *output);
void ExecuteInformation(){this->vtkImageToImageFilter::ExecuteInformation();};
virtual void ExecuteData(vtkDataObject *);
virtual void ComputeInputUpdateExtent (vtkInformation *,
vtkInformationVector *,
vtkInformationVector *);
void ExecuteInformation (vtkInformation *,
vtkInformationVector *,
vtkInformationVector *);
virtual void ExecuteData(vtkInformation *request,
vtkInformationVector *inputVector,
vtkInformationVector *outputVector);
int VOI[6];
int SampleRate[3];
......
......@@ -15,11 +15,14 @@
#include "vtkImageSinusoidSource.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include <math.h>
vtkCxxRevisionMacro(vtkImageSinusoidSource, "1.35");
vtkCxxRevisionMacro(vtkImageSinusoidSource, "1.35.10.1");
vtkStandardNewMacro(vtkImageSinusoidSource);
//----------------------------------------------------------------------------
......@@ -37,6 +40,7 @@ vtkImageSinusoidSource::vtkImageSinusoidSource()
this->WholeExtent[2] = 0; this->WholeExtent[3] = 255;
this->WholeExtent[4] = 0; this->WholeExtent[5] = 0;
this->SetNumberOfInputPorts(0);
}
void vtkImageSinusoidSource::SetDirection(double v[3])
......@@ -119,13 +123,18 @@ void vtkImageSinusoidSource::SetWholeExtent(int xMin, int xMax,
}
//----------------------------------------------------------------------------
void vtkImageSinusoidSource::ExecuteInformation()
void vtkImageSinusoidSource::ExecuteInformation (
vtkInformation * vtkNotUsed(request),
vtkInformationVector * vtkNotUsed( inputVector ),
vtkInformationVector *outputVector)
{
vtkImageData *output = this->GetOutput();
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
output->SetWholeExtent(this->WholeExtent);
output->SetScalarType(VTK_DOUBLE);
output->SetNumberOfScalarComponents(1);
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
this->WholeExtent,6);
outInfo->Set(vtkDataObject::SCALAR_TYPE(),VTK_DOUBLE);
outInfo->Set(vtkDataObject::SCALAR_NUMBER_OF_COMPONENTS(),1);
}
void vtkImageSinusoidSource::ExecuteData(vtkDataObject *output)
......
......@@ -21,13 +21,13 @@
#ifndef __vtkImageSinusoidSource_h
#define __vtkImageSinusoidSource_h
#include "vtkImageSource.h"
#include "vtkImageAlgorithm.h"
class VTK_IMAGING_EXPORT vtkImageSinusoidSource : public vtkImageSource
class VTK_IMAGING_EXPORT vtkImageSinusoidSource : public vtkImageAlgorithm
{
public:
static vtkImageSinusoidSource *New();
vtkTypeRevisionMacro(vtkImageSinusoidSource,vtkImageSource);
vtkTypeRevisionMacro(vtkImageSinusoidSource,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -67,7 +67,7 @@ protected:
double Phase;
double Amplitude;
virtual void ExecuteInformation();
virtual void ExecuteInformation (vtkInformation *, vtkInformationVector *, vtkInformationVector *);
virtual void ExecuteData(vtkDataObject *data);
private:
vtkImageSinusoidSource(const vtkImageSinusoidSource&); // Not implemented.
......
......@@ -16,11 +16,14 @@
#include "vtkImageData.h"
#include "vtkMath.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkPointData.h"
#include "vtkUnsignedCharArray.h"
vtkCxxRevisionMacro(vtkTriangularTexture, "1.25");
vtkCxxRevisionMacro(vtkTriangularTexture, "1.25.10.1");
vtkStandardNewMacro(vtkTriangularTexture);
// Instantiate object with XSize and YSize = 64; the texture pattern =1
......@@ -31,6 +34,7 @@ vtkTriangularTexture::vtkTriangularTexture()
this->XSize = this->YSize = 64;
this->TexturePattern = 1;
this->ScaleFactor = 1.0;
this->SetNumberOfInputPorts(0);
}
void vtkOpaqueAtElementCentroid (int XSize, int YSize, double ScaleFactor,
......@@ -137,13 +141,19 @@ void vtkOpaqueAtVertices (int XSize, int YSize, double ScaleFactor,
}
//----------------------------------------------------------------------------
void vtkTriangularTexture::ExecuteInformation()
void vtkTriangularTexture::ExecuteInformation (
vtkInformation * vtkNotUsed(request),
vtkInformationVector * vtkNotUsed( inputVector ),
vtkInformationVector *outputVector)
{
vtkImageData *output = this->GetOutput();
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
output->SetWholeExtent(0,this->XSize -1, 0, this->YSize - 1, 0,0);
output->SetScalarType(VTK_UNSIGNED_CHAR);
output->SetNumberOfScalarComponents(2);
int wExt[6] = {0,this->XSize -1, 0, this->YSize - 1, 0,0};
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),wExt,6);
outInfo->Set(vtkDataObject::SCALAR_TYPE(),VTK_UNSIGNED_CHAR);
outInfo->Set(vtkDataObject::SCALAR_NUMBER_OF_COMPONENTS(),2);
}
void vtkTriangularTexture::ExecuteData(vtkDataObject *outp)
......
......@@ -28,12 +28,12 @@
#ifndef __vtkTriangularTexture_h
#define __vtkTriangularTexture_h
#include "vtkImageSource.h"
#include "vtkImageAlgorithm.h"
class VTK_IMAGING_EXPORT vtkTriangularTexture : public vtkImageSource
class VTK_IMAGING_EXPORT vtkTriangularTexture : public vtkImageAlgorithm
{
public:
vtkTypeRevisionMacro(vtkTriangularTexture,vtkImageSource);
vtkTypeRevisionMacro(vtkTriangularTexture,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -68,7 +68,7 @@ protected:
vtkTriangularTexture();
~vtkTriangularTexture() {};
virtual void ExecuteInformation();
virtual void ExecuteInformation (vtkInformation *, vtkInformationVector *, vtkInformationVector *);
virtual void ExecuteData(vtkDataObject *data);
int XSize;
......
......@@ -31,7 +31,7 @@
#include "vtkUnstructuredGrid.h"
#include "vtkExtentTranslator.h"
vtkCxxRevisionMacro(vtkPDataSetReader, "1.30");
vtkCxxRevisionMacro(vtkPDataSetReader, "1.30.6.1");
vtkStandardNewMacro(vtkPDataSetReader);
//----------------------------------------------------------------------------
......@@ -1318,13 +1318,14 @@ void vtkPDataSetReader::StructuredGridExecute()
{
if (pieceMask[i])
{
tmp = vtkStructuredGrid::New();
reader->SetOutput(tmp);
reader->SetOutput(0);
reader->SetFileName(this->PieceFileNames[i]);
reader->Update();
tmp = reader->GetOutput();
if (tmp->GetNumberOfCells() > 0)
{
pieces[count] = tmp;
tmp->Register(this);
// Sanity check: extent is correct. Ignore electric slide.
tmp->GetExtent(ext);
if (ext[1] - ext[0] !=
......@@ -1344,10 +1345,6 @@ void vtkPDataSetReader::StructuredGridExecute()
}
++count;
}
else
{
tmp->Delete();
}
}
}
......
......@@ -22,7 +22,7 @@
#include "vtkRectilinearGrid.h"
#include "vtkErrorCode.h"
vtkCxxRevisionMacro(vtkPDataSetWriter, "1.12");
vtkCxxRevisionMacro(vtkPDataSetWriter, "1.12.10.1");
vtkStandardNewMacro(vtkPDataSetWriter);
//----------------------------------------------------------------------------
......@@ -254,8 +254,9 @@ void vtkPDataSetWriter::Write()
// I am putting this in here because shallow copy does not copy the
// UpdateExtentInitializedFlag, and I do not want to touch ShallowCopy
// in ParaViews release.
copy->SetUpdateExtent(0,1,0);
copy->SetUpdateExtent(input->GetUpdateExtent());
copy->SetRequestExactExtent(1);
copy->Crop();
writer->SetInput(vtkDataSet::SafeDownCast(copy));
writer->Write();
copy->Delete();
......
......@@ -15,15 +15,23 @@ FILE (GLOB CXX_FILE ${CLASS}.cxx)
FILE (READ ${H_FILE} H_CONTENTS)
# convert vtkImageToImageFilter subclasses to subclass off of
# vtkImageAlgorithm
STRING (REGEX REPLACE
"vtkImageToImageFilter"
"vtkThreadedImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkImageSource"
"vtkImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
# vtkImageAlgorithm, if it is threaded use threaded one
IF ("${CXX_CONTENTS}" MATCHES ".*ThreadedExecute.*")
STRING (REGEX REPLACE
"vtkImageToImageFilter"
"vtkThreadedImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
ELSE ("${CXX_CONTENTS}" MATCHES ".*ThreadedExecute.*")
STRING (REGEX REPLACE
"vtkImageToImageFilter"
"vtkImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkImageSource"
"vtkImageAlgorithm"
H_CONTENTS "${H_CONTENTS}")
ENDIF ("${CXX_CONTENTS}" MATCHES ".*ThreadedExecute.*")
# polyDataAlgorithm
STRING (REGEX REPLACE
......
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