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

More progress. Everything compiles now

parent 56788e10
...@@ -38,9 +38,7 @@ int TestHistogram2D(int, char * []) ...@@ -38,9 +38,7 @@ int TestHistogram2D(int, char * [])
vtkNew<vtkImageData> data; vtkNew<vtkImageData> data;
data->SetExtent(0, size-1, 0, size-1, 0, 0); data->SetExtent(0, size-1, 0, size-1, 0, 0);
data->SetNumberOfScalarComponents(1); data->AllocateScalars(VTK_DOUBLE, 1);
data->SetScalarTypeToDouble();
data->AllocateScalars();
data->SetOrigin(100.0, 0.0, 0.0); data->SetOrigin(100.0, 0.0, 0.0);
data->SetSpacing(2.0, 1.0, 1.0); data->SetSpacing(2.0, 1.0, 1.0);
......
...@@ -170,9 +170,7 @@ void vtkColorLegend::ComputeTexture() ...@@ -170,9 +170,7 @@ void vtkColorLegend::ComputeTexture()
this->ImageData->SetExtent(0, 0, this->ImageData->SetExtent(0, 0,
0, dimension-1, 0, dimension-1,
0, 0); 0, 0);
this->ImageData->SetNumberOfScalarComponents(3); this->ImageData->AllocateScalars(VTK_UNSIGNED_CHAR, 3);
this->ImageData->SetScalarTypeToUnsignedChar();
this->ImageData->AllocateScalars();
for (int i = 0; i < dimension; ++i) for (int i = 0; i < dimension; ++i)
{ {
......
...@@ -106,9 +106,7 @@ void vtkColorTransferFunctionItem::ComputeTexture() ...@@ -106,9 +106,7 @@ void vtkColorTransferFunctionItem::ComputeTexture()
this->Texture->SetExtent(0, dimension-1, this->Texture->SetExtent(0, dimension-1,
0, 0, 0, 0,
0, 0); 0, 0);
this->Texture->SetNumberOfScalarComponents(4); this->Texture->AllocateScalars(VTK_UNSIGNED_CHAR, 4);
this->Texture->SetScalarTypeToUnsignedChar();
this->Texture->AllocateScalars();
for (int i = 0; i < dimension; ++i) for (int i = 0; i < dimension; ++i)
{ {
......
...@@ -96,9 +96,7 @@ void vtkLookupTableItem::ComputeTexture() ...@@ -96,9 +96,7 @@ void vtkLookupTableItem::ComputeTexture()
this->Texture->SetExtent(0, dimension - 1, this->Texture->SetExtent(0, dimension - 1,
0,0, 0,0,
0,0); 0,0);
this->Texture->SetNumberOfScalarComponents(4); this->Texture->AllocateScalars(VTK_UNSIGNED_CHAR, 4);
this->Texture->SetScalarTypeToUnsignedChar();
this->Texture->AllocateScalars();
// TODO: Support log scale ? // TODO: Support log scale ?
double bounds[4]; double bounds[4];
this->GetBounds(bounds); this->GetBounds(bounds);
......
...@@ -108,9 +108,7 @@ void vtkPiecewiseFunctionItem::ComputeTexture() ...@@ -108,9 +108,7 @@ void vtkPiecewiseFunctionItem::ComputeTexture()
this->Texture->SetExtent(0, dimension-1, this->Texture->SetExtent(0, dimension-1,
0, 0, 0, 0,
0, 0); 0, 0);
this->Texture->SetNumberOfScalarComponents(4); this->Texture->AllocateScalars(VTK_UNSIGNED_CHAR, 4);
this->Texture->SetScalarTypeToUnsignedChar();
this->Texture->AllocateScalars();
this->PiecewiseFunction->GetTable(bounds[0], bounds[1], dimension, values); this->PiecewiseFunction->GetTable(bounds[0], bounds[1], dimension, values);
unsigned char* ptr = unsigned char* ptr =
......
...@@ -126,9 +126,7 @@ void vtkPlotHistogram2D::GenerateHistogram() ...@@ -126,9 +126,7 @@ void vtkPlotHistogram2D::GenerateHistogram()
this->Output = vtkSmartPointer<vtkImageData>::New(); this->Output = vtkSmartPointer<vtkImageData>::New();
} }
this->Output->SetExtent(this->Input->GetExtent()); this->Output->SetExtent(this->Input->GetExtent());
this->Output->SetNumberOfScalarComponents(4); this->Output->AllocateScalars(VTK_UNSIGNED_CHAR, 4);
this->Output->SetScalarTypeToUnsignedChar();
this->Output->AllocateScalars();
int dimension = this->Input->GetDimensions()[0] * this->Input->GetDimensions()[1]; int dimension = this->Input->GetDimensions()[0] * this->Input->GetDimensions()[1];
double *input = reinterpret_cast<double *>(this->Input->GetScalarPointer()); double *input = reinterpret_cast<double *>(this->Input->GetScalarPointer());
......
...@@ -228,8 +228,6 @@ void vtkPlotPoints::GeneraterMarker(int width, bool highlight) ...@@ -228,8 +228,6 @@ void vtkPlotPoints::GeneraterMarker(int width, bool highlight)
if (!this->Marker) if (!this->Marker)
{ {
this->Marker = vtkImageData::New(); this->Marker = vtkImageData::New();
this->Marker->SetScalarTypeToUnsignedChar();
this->Marker->SetNumberOfScalarComponents(4);
} }
else else
{ {
...@@ -247,8 +245,6 @@ void vtkPlotPoints::GeneraterMarker(int width, bool highlight) ...@@ -247,8 +245,6 @@ void vtkPlotPoints::GeneraterMarker(int width, bool highlight)
if (!this->HighlightMarker) if (!this->HighlightMarker)
{ {
this->HighlightMarker = vtkImageData::New(); this->HighlightMarker = vtkImageData::New();
this->HighlightMarker->SetScalarTypeToUnsignedChar();
this->HighlightMarker->SetNumberOfScalarComponents(4);
data = this->HighlightMarker; data = this->HighlightMarker;
} }
else else
...@@ -264,7 +260,7 @@ void vtkPlotPoints::GeneraterMarker(int width, bool highlight) ...@@ -264,7 +260,7 @@ void vtkPlotPoints::GeneraterMarker(int width, bool highlight)
} }
data->SetExtent(0, width-1, 0, width-1, 0, 0); data->SetExtent(0, width-1, 0, width-1, 0, 0);
data->AllocateScalars(); data->AllocateScalars(VTK_UNSIGNED_CHAR, 4);
unsigned char* image = unsigned char* image =
static_cast<unsigned char*>(data->GetScalarPointer()); static_cast<unsigned char*>(data->GetScalarPointer());
......
...@@ -122,7 +122,6 @@ int ComparePointLocators(vtkAbstractPointLocator* locator1, vtkAbstractPointLoca ...@@ -122,7 +122,6 @@ int ComparePointLocators(vtkAbstractPointLocator* locator1, vtkAbstractPointLoca
} }
} }
sgrid->SetPoints(points); sgrid->SetPoints(points);
sgrid->Update();
points->Delete(); points->Delete();
locator1->SetDataSet(sgrid); locator1->SetDataSet(sgrid);
......
...@@ -1338,6 +1338,17 @@ void vtkAlgorithm::Update() ...@@ -1338,6 +1338,17 @@ void vtkAlgorithm::Update()
this->GetExecutive()->Update(); this->GetExecutive()->Update();
} }
//----------------------------------------------------------------------------
void vtkAlgorithm::PropagateUpdateExtent()
{
vtkStreamingDemandDrivenPipeline* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(this->GetExecutive());
if (sddp)
{
sddp->PropagateUpdateExtent(-1);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkAlgorithm::UpdateInformation() void vtkAlgorithm::UpdateInformation()
{ {
...@@ -1532,3 +1543,53 @@ double vtkAlgorithm::ComputePriority() ...@@ -1532,3 +1543,53 @@ double vtkAlgorithm::ComputePriority()
return sddp->ComputePriority(0); return sddp->ComputePriority(0);
} }
//-------------------------------------------------------------
int vtkAlgorithm::SetUpdateExtentToWholeExtent(
int port, int connection)
{
if (this->GetInputInformation(port, connection))
{
return
vtkStreamingDemandDrivenPipeline::SetUpdateExtentToWholeExtent(
this->GetInputInformation(port, connection));
}
else
{
return 0;
}
}
//-------------------------------------------------------------
int vtkAlgorithm::SetUpdateExtentToWholeExtent()
{
return this->SetUpdateExtentToWholeExtent(0, 0);
}
//-------------------------------------------------------------
void vtkAlgorithm::SetUpdateExtent(int port, int connection,
int piece,
int numPieces,
int ghostLevel)
{
if (this->GetInputInformation(port, connection))
{
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
this->GetInputInformation(port, connection),
piece,
numPieces,
ghostLevel);
}
}
//-------------------------------------------------------------
void vtkAlgorithm::SetUpdateExtent(int port,
int connection,
int extent[6])
{
if (this->GetInputInformation(port, connection))
{
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
this->GetInputInformation(port, connection),
extent);
}
}
...@@ -371,9 +371,13 @@ public: ...@@ -371,9 +371,13 @@ public:
virtual void Update(); virtual void Update();
// Description: // Description:
// Backward compatibility method to invoke UpdateInformation on executive. // Bring the algorithm's information up-to-date.
virtual void UpdateInformation(); virtual void UpdateInformation();
// Description::
// Propagate meta-data upstream.
virtual void PropagateUpdateExtent();
// Description: // Description:
// Bring this algorithm's outputs up-to-date. // Bring this algorithm's outputs up-to-date.
virtual void UpdateWholeExtent(); virtual void UpdateWholeExtent();
...@@ -427,6 +431,47 @@ public: ...@@ -427,6 +431,47 @@ public:
static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES(); static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES();
static vtkInformationIntegerKey* PRESERVES_RANGES(); static vtkInformationIntegerKey* PRESERVES_RANGES();
// Description:
// If the whole input extent is required to generate the requested output
// extent, this method can be called to set the input update extent to the
// whole input extent. This method assumes that the whole extent is known
// (that UpdateInformation has been called).
// This function has no effect is input connection is not established.
int SetUpdateExtentToWholeExtent(int port, int connection);
// Description:
// Convenience function equivalent to SetUpdateExtentToWholeExtent(0, 0)
// This function has no effect is input connection is not established.
int SetUpdateExtentToWholeExtent();
// Description:
// Set the update extent in terms of piece and ghost levels.
// This function has no effect is input connection is not established.
void SetUpdateExtent(int port, int connection,
int piece,int numPieces, int ghostLevel);
// Description:
// Convenience function equivalent to SetUpdateExtent(0, 0, piece,
// numPieces, ghostLevel)
// This function has no effect is input connection is not established.
void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
{
this->SetUpdateExtent(0, 0, piece, numPieces, ghostLevel);
}
// Description:
// Set the update extent for data objects that use 3D extents
// This function has no effect is input connection is not established.
void SetUpdateExtent(int port, int connection, int extent[6]);
// Description:
// Convenience function equivalent to SetUpdateExtent(0, 0, extent)
// This function has no effect is input connection is not established.
void SetUpdateExtent(int extent[6])
{
this->SetUpdateExtent(0, 0, extent);
}
protected: protected:
vtkAlgorithm(); vtkAlgorithm();
~vtkAlgorithm(); ~vtkAlgorithm();
......
...@@ -752,7 +752,7 @@ void vtkDataObject::InternalDataObjectCopy(vtkDataObject *src) ...@@ -752,7 +752,7 @@ void vtkDataObject::InternalDataObjectCopy(vtkDataObject *src)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// This should be a pure virutal method. // This should be a pure virutal method.
void vtkDataObject::Crop() void vtkDataObject::Crop(const int* updateExtent)
{ {
} }
......
...@@ -249,7 +249,7 @@ public: ...@@ -249,7 +249,7 @@ public:
// Description: // Description:
// This method crops the data object (if necesary) so that the extent // This method crops the data object (if necesary) so that the extent
// matches the update extent. // matches the update extent.
virtual void Crop(); virtual void Crop(const int* updateExtent);
//BTX //BTX
// Description: // Description:
......
...@@ -78,9 +78,9 @@ vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PREVIOUS_FAST_PATH_ID_T ...@@ -78,9 +78,9 @@ vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PREVIOUS_FAST_PATH_ID_T
class vtkStreamingDemandDrivenPipelineToDataObjectFriendship class vtkStreamingDemandDrivenPipelineToDataObjectFriendship
{ {
public: public:
static void Crop(vtkDataObject* obj) static void Crop(vtkDataObject* obj, const int* extent)
{ {
obj->Crop(); obj->Crop(extent);
} }
}; };
...@@ -270,7 +270,8 @@ int vtkStreamingDemandDrivenPipeline ...@@ -270,7 +270,8 @@ int vtkStreamingDemandDrivenPipeline
if(info->Has(EXACT_EXTENT()) && info->Get(EXACT_EXTENT())) if(info->Has(EXACT_EXTENT()) && info->Get(EXACT_EXTENT()))
{ {
vtkDataObject* data = info->Get(vtkDataObject::DATA_OBJECT()); vtkDataObject* data = info->Get(vtkDataObject::DATA_OBJECT());
vtkStreamingDemandDrivenPipelineToDataObjectFriendship::Crop(data); vtkStreamingDemandDrivenPipelineToDataObjectFriendship::Crop(
data, info->Get(UPDATE_EXTENT()));
} }
// Clear combined update extent, since the update cycle has completed // Clear combined update extent, since the update cycle has completed
if (info->Has(COMBINED_UPDATE_EXTENT())) if (info->Has(COMBINED_UPDATE_EXTENT()))
......
...@@ -371,8 +371,7 @@ void vtkGeoAlignedImageSource::CropImageForNode(vtkGeoImageNode* node, vtkImageD ...@@ -371,8 +371,7 @@ void vtkGeoAlignedImageSource::CropImageForNode(vtkGeoImageNode* node, vtkImageD
vtkSmartPointer<vtkImageData> cropped = vtkSmartPointer<vtkImageData>::New(); vtkSmartPointer<vtkImageData> cropped = vtkSmartPointer<vtkImageData>::New();
cropped->ShallowCopy(image); cropped->ShallowCopy(image);
cropped->SetUpdateExtent(ext); cropped->Crop(ext);
cropped->Crop();
// Now set the longitude and latitude range based on the actual image size. // Now set the longitude and latitude range based on the actual image size.
double lonRange[2]; double lonRange[2];
......
...@@ -160,8 +160,7 @@ void vtkGeoImageNode::CropImageForTile( ...@@ -160,8 +160,7 @@ void vtkGeoImageNode::CropImageForTile(
this->Image = vtkSmartPointer<vtkImageData>::New(); this->Image = vtkSmartPointer<vtkImageData>::New();
} }
this->Image->ShallowCopy(image); this->Image->ShallowCopy(image);
this->Image->SetUpdateExtent(ext); this->Image->Crop(ext);
this->Image->Crop();
// Now set the longitude and latitude range based on the actual image size. // Now set the longitude and latitude range based on the actual image size.
this->LongitudeRange[0] = origin[0] + ext[0]*spacing[0]; this->LongitudeRange[0] = origin[0] + ext[0]*spacing[0];
......
...@@ -118,8 +118,6 @@ public: ...@@ -118,8 +118,6 @@ public:
static void CheckWinding(vtkUnstructuredGrid *data) static void CheckWinding(vtkUnstructuredGrid *data)
{ {
data->Update();
vtkPoints *points = data->GetPoints(); vtkPoints *points = data->GetPoints();
vtkCellArray *cells = data->GetCells(); vtkCellArray *cells = data->GetCells();
......
...@@ -124,9 +124,10 @@ class BoxClipTriangulateFailed { }; ...@@ -124,9 +124,10 @@ class BoxClipTriangulateFailed { };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void CheckWinding(vtkUnstructuredGrid *data) static void CheckWinding(vtkBoxClipDataSet* alg)
{ {
data->Update(); alg->Update();
vtkUnstructuredGrid* data = alg->GetOutput();
vtkPoints *points = data->GetPoints(); vtkPoints *points = data->GetPoints();
...@@ -307,7 +308,7 @@ static void Check3DPrimitive(int type, vtkIdType numcells, ...@@ -307,7 +308,7 @@ static void Check3DPrimitive(int type, vtkIdType numcells,
iren->Start(); iren->Start();
#endif #endif
CheckWinding(output); CheckWinding(clipper);
VTK_CREATE(vtkDataSetSurfaceFilter, surface); VTK_CREATE(vtkDataSetSurfaceFilter, surface);
surface->SetInput(output); surface->SetInput(output);
......
...@@ -151,7 +151,6 @@ int TestBareScalarsToColors(int argc, char *argv[]) ...@@ -151,7 +151,6 @@ int TestBareScalarsToColors(int argc, char *argv[])
vtkNew<vtkImageData> image; vtkNew<vtkImageData> image;
image->SetDimensions(80, 80, 1); image->SetDimensions(80, 80, 1);
image->SetScalarTypeToUnsignedChar();
vtkUnsignedCharArray *colors = vtkUnsignedCharArray *colors =
table2->MapScalars(outputs[i], VTK_COLOR_MODE_DEFAULT, outputc); table2->MapScalars(outputs[i], VTK_COLOR_MODE_DEFAULT, outputc);
image->GetPointData()->SetScalars(colors); image->GetPointData()->SetScalars(colors);
......
...@@ -156,7 +156,6 @@ int TestExtraction(int argc, char *argv[]) ...@@ -156,7 +156,6 @@ int TestExtraction(int argc, char *argv[])
sampleData->SetSpacing(1.0,1.0,1.0); sampleData->SetSpacing(1.0,1.0,1.0);
sampleData->SetOrigin(0.0,0.0,0.0); sampleData->SetOrigin(0.0,0.0,0.0);
sampleData->SetDimensions(XCELLS+1,YCELLS+1,ZCELLS+1); sampleData->SetDimensions(XCELLS+1,YCELLS+1,ZCELLS+1);
sampleData->SetWholeExtent(0,XCELLS+1,0,YCELLS+1,0,ZCELLS+1);
sampleData->AllocateScalars(); sampleData->AllocateScalars();
vtkIdTypeArray *pia = vtkIdTypeArray::New(); vtkIdTypeArray *pia = vtkIdTypeArray::New();
......
...@@ -135,7 +135,6 @@ int TestMapVectorsAsRGBColors(int argc, char *argv[]) ...@@ -135,7 +135,6 @@ int TestMapVectorsAsRGBColors(int argc, char *argv[])
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData> image =
vtkSmartPointer<vtkImageData>::New(); vtkSmartPointer<vtkImageData>::New();
image->SetDimensions(80, 80, 1); image->SetDimensions(80, 80, 1);
image->SetScalarTypeToUnsignedChar();
vtkUnsignedCharArray *colors = vtkUnsignedCharArray *colors =
table2->MapScalars(outputs[i], VTK_COLOR_MODE_DEFAULT, outputc); table2->MapScalars(outputs[i], VTK_COLOR_MODE_DEFAULT, outputc);
image->GetPointData()->SetScalars(colors); image->GetPointData()->SetScalars(colors);
......
...@@ -81,13 +81,13 @@ int TestQuadraturePoints(int argc,char *argv[]) ...@@ -81,13 +81,13 @@ int TestQuadraturePoints(int argc,char *argv[])
if (xusgr->CanReadFile(inputFileName.c_str())) if (xusgr->CanReadFile(inputFileName.c_str()))
{ {
input=xusgr->GetOutput(); input=xusgr->GetOutput();
input->Update(); xusgr->Update();
} }
else if (lusgr->IsFileValid("unstructured_grid")) else if (lusgr->IsFileValid("unstructured_grid"))
{ {
lusgr->SetFileName(inputFileName.c_str()); lusgr->SetFileName(inputFileName.c_str());
input=lusgr->GetOutput(); input=lusgr->GetOutput();
input->Update(); lusgr->Update();
} }
if (input==0) if (input==0)
{ {
...@@ -129,7 +129,7 @@ int TestQuadraturePoints(int argc,char *argv[]) ...@@ -129,7 +129,7 @@ int TestQuadraturePoints(int argc,char *argv[])
xusgr->SetFileName(tempFile.c_str()); xusgr->SetFileName(tempFile.c_str());
input=xusgr->GetOutput();*/ input=xusgr->GetOutput();*/
input = vtkUnstructuredGrid::SafeDownCast(fieldInterp->GetOutput()); input = vtkUnstructuredGrid::SafeDownCast(fieldInterp->GetOutput());
input->Update(); fieldInterp->Update();
input->GetPointData()->SetActiveVectors(warpName.c_str()); input->GetPointData()->SetActiveVectors(warpName.c_str());
input->GetPointData()->SetActiveScalars(threshName.c_str()); input->GetPointData()->SetActiveScalars(threshName.c_str());
// Demonstrate warp by vector. // Demonstrate warp by vector.
...@@ -155,7 +155,7 @@ int TestQuadraturePoints(int argc,char *argv[]) ...@@ -155,7 +155,7 @@ int TestQuadraturePoints(int argc,char *argv[])
pointGen->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "QuadratureOffset"); pointGen->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "QuadratureOffset");
pointGen->SetInputConnection(thresholder->GetOutputPort()); pointGen->SetInputConnection(thresholder->GetOutputPort());
vtkPolyData *output=vtkPolyData::SafeDownCast(pointGen->GetOutput()); vtkPolyData *output=vtkPolyData::SafeDownCast(pointGen->GetOutput());
output->Update(); pointGen->Update();
const char* activeScalars = "pressure"; const char* activeScalars = "pressure";
output->GetPointData()->SetActiveScalars(activeScalars); output->GetPointData()->SetActiveScalars(activeScalars);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "vtkMatrixToLinearTransform.h" #include "vtkMatrixToLinearTransform.h"
#include "vtkTransformPolyDataFilter.h" #include "vtkTransformPolyDataFilter.h"
#include "vtkMatrix4x4.h" #include "vtkMatrix4x4.h"
#include "vtkTrivialProducer.h"
#include "vtkTesting.h" #include "vtkTesting.h"
...@@ -82,8 +83,7 @@ CreateBoxStencilData(double d1, double d2 ) ...@@ -82,8 +83,7 @@ CreateBoxStencilData(double d1, double d2 )
image->SetOrigin( 0.0, 0.0, 0.0 ); image->SetOrigin( 0.0, 0.0, 0.0 );
image->SetExtent(static_cast<int>(d1)-2,static_cast<int>(d2)+2, image->SetExtent(static_cast<int>(d1)-2,static_cast<int>(d2)+2,
static_cast<int>(d1)-2,static_cast<int>(d2)+2, 0, 0 ); static_cast<int>(d1)-2,static_cast<int>(d2)+2, 0, 0 );
image->SetScalarTypeToUnsignedChar(); image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
image->AllocateScalars();
vtkImageStencil *stencil = vtkImageStencil::New(); vtkImageStencil *stencil = vtkImageStencil::New();
stencil->SetInput( image ); stencil->SetInput( image );
...@@ -112,9 +112,7 @@ static void GetStencilDataAsImageData( ...@@ -112,9 +112,7 @@ static void GetStencilDataAsImageData(
extent[5] = extent[4]; // Otherwise we cannot write it out as a PNG! extent[5] = extent[4]; // Otherwise we cannot write it out as a PNG!