Commit 60b0dd8d authored by Charles Law's avatar Charles Law

Streaming graphics pipeline. Multiple input/output. Eliminate vtkImageCache.

parent e68ee3bd
......@@ -32,8 +32,6 @@ vtkCell \
vtkDataArray \
vtkDataSet \
vtkImplicitFunction \
vtkImageCache \
vtkImageSource \
vtkLocator \
vtkPointSet \
vtkScalarsToColors \
......@@ -65,7 +63,7 @@ vtkGenericCell \
vtkHexahedron \
vtkIdList \
vtkImageData \
vtkImageSimpleCache \
vtkImageSource \
vtkImageToStructuredPoints \
vtkIndent \
vtkIntArray \
......@@ -108,7 +106,6 @@ vtkStructuredData \
vtkStructuredGrid \
vtkStructuredPoints \
vtkStructuredPointsSource \
vtkStructuredPointsToImage \
vtkTCoords \
vtkTensor \
vtkTensors \
......
......@@ -86,6 +86,41 @@ void vtkByteSwap::Swap4BERange(char *mem_ptr1,int num)
}
#endif
// Swap bunch of bytes. Num is the number of four byte words to swap.
void vtkByteSwap::SwapWrite4BERange(char *mem_ptr1,int num, ostream *fp)
{
#ifndef VTK_WORDS_BIGENDIAN
char one_byte;
char *pos;
int i;
char *cpy;
cpy = new char [num*4];
memcpy(cpy, mem_ptr1,num*4);
pos = cpy;
for (i = 0; i < num; i++)
{
one_byte = pos[0];
pos[0] = pos[3];
pos[3] = one_byte;
one_byte = pos[1];
pos[1] = pos[2];
pos[2] = one_byte;
pos = pos + 4;
}
fp->write((unsigned char *)cpy, 4*num);
delete [] cpy;
#else
fp->write((unsigned char *)mem_ptr1, 4*num);
#endif
}
// Swap bunch of bytes. Num is the number of four byte words to swap.
void vtkByteSwap::SwapWrite4BERange(char *mem_ptr1,int num, FILE *fp)
{
......@@ -240,6 +275,38 @@ void vtkByteSwap::Swap2LERange(char *mem_ptr1,int num)
void vtkByteSwap::Swap2LERange(char *mem_ptr1,int num){}
#endif
// Swap bunch of bytes. Num is the number of four byte words to swap.
void vtkByteSwap::SwapWrite2BERange(char *mem_ptr1,int num, ostream *fp)
{
#ifndef VTK_WORDS_BIGENDIAN
char one_byte;
char *pos;
int i;
char *cpy;
cpy = new char [num*2];
memcpy(cpy, mem_ptr1,num*2);
pos = cpy;
for (i = 0; i < num; i++)
{
one_byte = pos[0];
pos[0] = pos[1];
pos[1] = one_byte;
pos = pos + 2;
}
fp->write((unsigned char *)cpy, 2*num);
delete [] cpy;
#else
fp->write((unsigned char *)mem_ptr1, 2*num);
#endif
}
// Swap bunch of bytes. Num is the number of four byte words to swap.
void vtkByteSwap::SwapWrite2BERange(char *mem_ptr1,int num, FILE *fp)
{
......
......@@ -48,6 +48,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#define __vtkByteSwap_h
#include <stdio.h>
#include <fstream.h>
#include "vtkObject.h"
class VTK_EXPORT vtkByteSwap : public vtkObject
......@@ -114,6 +115,14 @@ public:
static void SwapWrite4BERange(unsigned long *i,int num, FILE *fp)
{ vtkByteSwap::SwapWrite4BERange((char *)i,num,fp);};
static void SwapWrite4BERange(char *c,int num, ostream *fp);
static void SwapWrite4BERange(float *p,int num, ostream *fp)
{ vtkByteSwap::SwapWrite4BERange((char *)p,num,fp);};
static void SwapWrite4BERange(int *i,int num, ostream *fp)
{ vtkByteSwap::SwapWrite4BERange((char *)i,num,fp);};
static void SwapWrite4BERange(unsigned long *i,int num, ostream *fp)
{ vtkByteSwap::SwapWrite4BERange((char *)i,num,fp);};
// Description:
// Swap 2 byte word to BE.
......@@ -140,6 +149,10 @@ public:
static void SwapWrite2BERange(short *i,int num, FILE *fp)
{vtkByteSwap::SwapWrite2BERange((char *)i,num,fp);};
static void SwapWrite2BERange(char *c,int num, ostream *fp);
static void SwapWrite2BERange(short *i,int num, ostream *fp)
{vtkByteSwap::SwapWrite2BERange((char *)i,num,fp);};
// Description:
// Swaps the bytes of a buffer. Uses an arbitrary word size, but
// assumes the word size is divisible by two.
......
......@@ -72,9 +72,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkGenericCell.h"
#include "vtkHexahedron.h"
#include "vtkIdList.h"
#include "vtkImageCache.h"
#include "vtkImageData.h"
#include "vtkImageSimpleCache.h"
#include "vtkImageSource.h"
#include "vtkImageToStructuredPoints.h"
#include "vtkImplicitFunction.h"
......@@ -123,7 +121,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkStructuredGrid.h"
#include "vtkStructuredPoints.h"
#include "vtkStructuredPointsSource.h"
#include "vtkStructuredPointsToImage.h"
#include "vtkTCoords.h"
#include "vtkTensors.h"
#include "vtkTetra.h"
......
......@@ -44,19 +44,31 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// Initialize static member that controls global data release after use by filter
static int vtkDataObjectGlobalReleaseDataFlag = 0;
//----------------------------------------------------------------------------
vtkDataObject::vtkDataObject()
{
this->Source = NULL;
this->DataReleased = 1;
this->ReleaseDataFlag = 0;
this->FieldData = vtkFieldData::New();
// --- streaming stuff ---
this->PipelineMTime = 0;
this->MemoryLimit = VTK_LARGE_INTEGER;
this->EstimatedMemorySize = 0;
this->PointLock = vtkMutexLock::New();
this->CellLock = vtkMutexLock::New();
}
//----------------------------------------------------------------------------
vtkDataObject::~vtkDataObject()
{
this->FieldData->Delete();
this->PointLock->Delete();
this->CellLock->Delete();
}
//----------------------------------------------------------------------------
// Determine the modified time of this object
unsigned long int vtkDataObject::GetMTime()
{
......@@ -71,6 +83,7 @@ unsigned long int vtkDataObject::GetMTime()
return result;
}
//----------------------------------------------------------------------------
void vtkDataObject::Initialize()
{
//
......@@ -80,6 +93,7 @@ void vtkDataObject::Initialize()
this->FieldData->Initialize();
};
//----------------------------------------------------------------------------
void vtkDataObject::SetGlobalReleaseDataFlag(int val)
{
if (val == vtkDataObjectGlobalReleaseDataFlag)
......@@ -89,17 +103,20 @@ void vtkDataObject::SetGlobalReleaseDataFlag(int val)
vtkDataObjectGlobalReleaseDataFlag = val;
}
//----------------------------------------------------------------------------
int vtkDataObject::GetGlobalReleaseDataFlag()
{
return vtkDataObjectGlobalReleaseDataFlag;
}
//----------------------------------------------------------------------------
void vtkDataObject::ReleaseData()
{
this->Initialize();
this->DataReleased = 1;
}
//----------------------------------------------------------------------------
int vtkDataObject::ShouldIReleaseData()
{
if ( vtkDataObjectGlobalReleaseDataFlag || this->ReleaseDataFlag )
......@@ -112,23 +129,56 @@ int vtkDataObject::ShouldIReleaseData()
}
}
//----------------------------------------------------------------------------
void vtkDataObject::Update()
{
this->UpdateInformation();
this->InternalUpdate();
}
//----------------------------------------------------------------------------
void vtkDataObject::UpdateInformation()
{
if (this->Source)
{
this->Source->Update();
this->Source->UpdateInformation();
}
}
void vtkDataObject::ForceUpdate()
//----------------------------------------------------------------------------
// If there is no source, just assume user put data here.
void vtkDataObject::InternalUpdate()
{
vtkDebugMacro("InternalUpdate: VT: " << this->UpdateTime << ", PMT: "
<< this->PipelineMTime);
if (this->UpdateTime >= this->PipelineMTime && ! this->DataReleased)
{
return;
}
this->ClipUpdateExtentWithWholeExtent();
if (this->Source)
{
this->Source->Modified();
this->Source->Update();
this->Source->InternalUpdate(this);
}
this->DataReleased = 0;
this->UpdateTime.Modified();
}
//----------------------------------------------------------------------------
void vtkDataObject::CopyUpdateExtent(vtkDataObject *data)
{
vtkErrorMacro("Concrete subclass did not implement CopyUpdateExtent");
}
//----------------------------------------------------------------------------
void vtkDataObject::CopyInformation(vtkDataObject *data)
{
vtkErrorMacro("Concrete subclass did not implement CopyInformation");
}
//----------------------------------------------------------------------------
void vtkDataObject::PrintSelf(ostream& os, vtkIndent indent)
{
vtkObject::PrintSelf(os,indent);
......@@ -144,22 +194,35 @@ void vtkDataObject::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "Release Data: " << (this->ReleaseDataFlag ? "On\n" : "Off\n");
os << indent << "Data Released: " << (this->DataReleased ? "True\n" : "False\n");
os << indent << "Global Release Data: "
<< (vtkDataObjectGlobalReleaseDataFlag ? "On\n" : "Off\n");
os << indent << "UpdateTime: " << this->UpdateTime << endl;
os << indent << "PipelineMTime: " << this->PipelineMTime << endl;
os << indent << "EstimatedMemorySize: " << this->EstimatedMemorySize << endl;
os << indent << "MemoryLimit: " << this->MemoryLimit << endl;
os << indent << "Locality: " << this->Locality << endl;
os << indent << "Field Data:\n";
this->FieldData->PrintSelf(os,indent.GetNextIndent());
}
void vtkDataObject::SetSource(vtkSource *_arg)
void vtkDataObject::SetSource(vtkSource *arg)
{
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Source to " << _arg );
if (this->Source != _arg)
{
vtkSource *tmp = this->Source;
this->Source = _arg;
if (tmp != NULL) { tmp->UnRegister(this); }
if (this->Source != NULL) { this->Source->Register(this); }
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Source to " << arg );
if (this->Source != arg)
{
vtkSource *tmp = this->Source;
this->Source = arg;
if (this->Source != NULL)
{
this->Source->Register(this);
}
if (tmp != NULL)
{
tmp->UnRegister(this);
}
this->Modified();
}
}
......@@ -179,3 +242,22 @@ void vtkDataObject::UnRegister(vtkObject *o)
this->vtkObject::UnRegister(o);
}
//----------------------------------------------------------------------------
unsigned long vtkDataObject::GetUpdateTime()
{
return this->UpdateTime.GetMTime();
}
......@@ -60,6 +60,8 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkObject.h"
#include "vtkFieldData.h"
#include "vtkMutexLock.h"
class vtkSource;
class VTK_EXPORT vtkDataObject : public vtkObject
......@@ -73,7 +75,8 @@ public:
// Description:
// Create concrete instance of this data object.
virtual vtkDataObject *MakeObject() {return new vtkDataObject;};
virtual vtkDataObject *MakeObject() {return new vtkDataObject;}
// Description:
// Set/Get the source object creating this data object.
......@@ -84,22 +87,15 @@ public:
// Data objects are composite objects and need to check each part for MTime.
unsigned long int GetMTime();
// Description:
// Provides opportunity for the data object to insure internal consistency
// before access. Also causes owning source/filter (if any) to update itself.
virtual void Update();
// Rescription:
// Restore data object to initial state,
virtual void Initialize();
// Description:
// Force the data object to update itself no matter what.
virtual void ForceUpdate();
// Description:
// Release data back to system to conserve memory resource. Used during
// visualization network execution.
// visualization network execution. Releasing this data does not make
// down-stream data invalid, so it does not modify the MTime of this
// data object.
void ReleaseData();
// Description:
......@@ -108,10 +104,9 @@ public:
int ShouldIReleaseData();
// Description:
// Set/Get the DataReleased ivar.
vtkSetMacro(DataReleased,int);
// Get the flag indicating the data has been released.
vtkGetMacro(DataReleased,int);
// Description:
// Turn on/off flag to control whether this object's data is released
// after being used by a filter.
......@@ -131,8 +126,7 @@ public:
// Assign or retrieve field data to this data object.
vtkSetObjectMacro(FieldData,vtkFieldData);
vtkGetObjectMacro(FieldData,vtkFieldData);
// Description:
// Handle the source/data loop.
void UnRegister(vtkObject *o);
......@@ -142,12 +136,120 @@ public:
// registration to properly free the objects.
virtual int GetNetReferenceCount() {return this->ReferenceCount;};
//------------- streaming stuff ------------------
// Description:
// Provides opportunity for the data object to insure internal
// consistency before access. Also causes owning source/filter
// (if any) to update itself.
virtual void Update();
// Description:
// This is the same as Update, but it assumes that the "Information"
// (including the PipelineMTime) is up to date.
virtual void InternalUpdate();
// Description:
// This makes sure all "Information" associated with this data object
// is up to date. Information is defined as any thing that is needed
// before the input is updated (like PipelineMTime for the execution check
// and EstimatedMemorySize for streaming).
virtual void UpdateInformation();
// Description:
// A generic way of specifying an update extent. Subclasses
// must decide what a piece is.
virtual void SetUpdateExtent(int piece, int numPieces)
{ vtkErrorMacro("Subclass did not implement 'SetUpdateExtent'");}
// Description:
// Set/Get memory limit. Make this smaller to stream.
// Setting value does not alter MTime.
void SetMemoryLimit(unsigned long v) {this->MemoryLimit = v;}
unsigned long GetMemoryLimit() {return this->MemoryLimit;}
// Description:
// One of the variables set when UpdateInformation is called.
// the estimated size of the data (in kilobytes) after the whole
// extent is updated. Setting the value does not alter MTime.
void SetEstimatedMemorySize(unsigned long v) {this->EstimatedMemorySize = v;}
unsigned long GetEstimatedMemorySize() {return this->EstimatedMemorySize;}
// Description:
// Method implemented in the subclasses to make sure the update extent
// is not bigger than the whole extent. Should be pure virtual.
virtual void ClipUpdateExtentWithWholeExtent() {}
// Description:
// PipelineMTime is the maximum of all the upstream source object mtimes.
// It does not include mtimes of the data objects.
// UpdateInformation must be called for the PipelineMTime to be correct.
// Only the source should set the PipelineMTime.
void SetPipelineMTime(long t) {this->PipelineMTime = t;}
long GetPipelineMTime() {return this->PipelineMTime;}
// Description:
// Implement in the concrete data types.
// Copies the UpdateExtent from another dataset of the same type.
// Used by a filter during UpdateInformation to copy requested
// piece from output to input.
// This method should be pure virtual (in the future).
virtual void CopyUpdateExtent(vtkDataObject *data);
// Description:
// Implement in the concrete data types.
// Copies "Information" (ie WholeDimensions) from another dataset
// of the same type. Used by a filter during UpdateInformation.
// This method should be pure virtual (in the future).
virtual void CopyInformation(vtkDataObject *data);
// Description:
// MutexLocks to keep multiple threads from stepping on each others toes.
// Here as a test for Multi-threaded execution. The alternative is temporary
// buffers.
vtkGetObjectMacro(PointLock, vtkMutexLock);
vtkGetObjectMacro(CellLock, vtkMutexLock);
// Description:
// Part of data's "Information".
// Are upstream filters local to the process?
void SetLocality(int val) {this->Locality = val;}
vtkGetMacro(Locality, int);
// Description:
// Return class name of data type. This is one of VTK_STRUCTURED_GRID,
// VTK_STRUCTURED_POINTS, VTK_UNSTRUCTURED_GRID, VTK_POLY_DATA, or
// VTK_RECTILINEAR_GRID (see vtkSetGet.h for definitions).
// THIS METHOD IS THREAD SAFE
virtual int GetDataObjectType() {return VTK_DATA_OBJECT;}
// Description:
// Used by Threaded ports to determine if they should initiate an
// asynchronous update (still in development).
unsigned long GetUpdateTime();
protected:
vtkSource *Source;
vtkFieldData *FieldData; //General field data associated with data object
vtkFieldData *FieldData; //General field data associated with data object
int DataReleased; //keep track of data release during network execution
int ReleaseDataFlag; //data will release after use by a filter
// ----- streaming stuff -----------
unsigned long MemoryLimit;
unsigned long EstimatedMemorySize;
unsigned long PipelineMTime;
vtkTimeStamp UpdateTime;