Commit 9333d9d1 authored by Bill Lorensen's avatar Bill Lorensen
Browse files

ENH: Introduce vtkMTimeType

This is a fix for:
#14310

Windows applications that run for a long time report that rendered
objects do not change. This is because the modified time on a Windows
system is 32 bits. This causes overflows that defeat the modified time
mechanism. This patch defines a new type, vtkMTimeType that is 64
unsigned integer regardless of the architecture.

A mechanism to provide backward compatibility is introduced. The
preprocessor define "VTK_HAS_MTIME_TYPE" can be used in applications
that must build against VTK versions that use the "unsigned long" type
for MTime's.

Methodology used to find MTime occurences:
1) Identify files as follows:
   git grep "unsigned long" | grep ime | cut -d":" -f1,1 | sort | uniq
2) Hand edit each of those files replacing "unsigned long" with
   "vtkMTimeType" where appropriate.
3) Temporarily change typedef for vtkMTimeType to "double" to detect
   missing conversions
parent 95225bb8
......@@ -120,7 +120,7 @@ void DeepCopy(vtkPistonReference *tr, vtkPistonReference *other)
//-----------------------------------------------------------------------------
bool CheckDirty(vtkDataSet *ds, vtkPistonReference *tr)
{
unsigned long int dstime = ds->GetMTime();
vtkMTimeType dstime = ds->GetMTime();
if (dstime != tr->mtime)
{
tr->mtime = dstime;
......
......@@ -143,7 +143,7 @@ void CudaUnregisterResource(struct cudaGraphicsResource *vboResource)
}
//------------------------------------------------------------------------------
void CudaTransferToGL(vtkPistonDataObject *id, unsigned long dataObjectMTimeCache,
void CudaTransferToGL(vtkPistonDataObject *id, vtkMTimeType dataObjectMTimeCache,
vtkPistonScalarsColors *psc,
cudaGraphicsResource **vboResources,
bool &hasNormals, bool &hasColors)
......
......@@ -43,7 +43,7 @@ namespace vtkpiston {
void CudaRegisterBuffer(struct cudaGraphicsResource **vboResource,
GLuint vboBuffer);
void CudaUnregisterResource(struct cudaGraphicsResource* vboResource);
void CudaTransferToGL(vtkPistonDataObject *id, unsigned long dataObjectMTimeCache,
void CudaTransferToGL(vtkPistonDataObject *id, vtkMTimeType dataObjectMTimeCache,
vtkPistonScalarsColors *psc,
struct cudaGraphicsResource **vboResources,
bool &hasNormals, bool &hasColors);
......@@ -82,7 +82,7 @@ public:
GLuint vboBuffers[3];
struct cudaGraphicsResource* vboResources[3];
unsigned long DataObjectMTimeCache;
vtkMTimeType DataObjectMTimeCache;
vtkPistonScalarsColors *PistonScalarsColors;
};
......
......@@ -54,7 +54,7 @@ public:
vtkpiston::DeepCopy(this, other);
}
unsigned long int mtime; //creation time of the data
vtkMTimeType mtime; //creation time of the data
int type; //description of what data holds
void *data; //the payload on GPU
};
......
......@@ -65,13 +65,13 @@ int vtkPistonSlice::ComputePipelineMTime(
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* vtkNotUsed(outputVector),
int vtkNotUsed(requestFromOutputPort),
unsigned long* mtime)
vtkMTimeType* mtime)
{
unsigned long mTime = this->GetMTime();
vtkMTimeType mTime = this->GetMTime();
if (this->Plane)
{
unsigned long planeMTime = this->Plane->GetMTime();
vtkMTimeType planeMTime = this->Plane->GetMTime();
if (planeMTime > mTime)
{
mTime = planeMTime;
......
......@@ -46,7 +46,7 @@ protected:
virtual int ComputePipelineMTime(
vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector, int requestFromOutputPort,
unsigned long* mtime);
vtkMTimeType* mtime);
// Description:
// Method that does the actual calculation.
......
......@@ -78,7 +78,7 @@ void vtkColorTransferControlPointsItem::emitEvent(unsigned long event, void* par
}
//-----------------------------------------------------------------------------
unsigned long int vtkColorTransferControlPointsItem::GetControlPointsMTime()
vtkMTimeType vtkColorTransferControlPointsItem::GetControlPointsMTime()
{
if (this->ColorTransferFunction)
{
......
......@@ -94,7 +94,7 @@ protected:
virtual void emitEvent(unsigned long event, void* params);
virtual unsigned long int GetControlPointsMTime();
virtual vtkMTimeType GetControlPointsMTime();
virtual void DrawPoint(vtkContext2D* painter, vtkIdType index);
virtual void EditPoint(float tX, float tY);
......
......@@ -100,9 +100,9 @@ void vtkCompositeControlPointsItem::emitEvent(unsigned long event, void* params)
}
//-----------------------------------------------------------------------------
unsigned long int vtkCompositeControlPointsItem::GetControlPointsMTime()
vtkMTimeType vtkCompositeControlPointsItem::GetControlPointsMTime()
{
unsigned long int mTime = this->Superclass::GetControlPointsMTime();
vtkMTimeType mTime = this->Superclass::GetControlPointsMTime();
if (this->OpacityFunction)
{
mTime = std::max(mTime, this->OpacityFunction->GetMTime());
......
......@@ -110,7 +110,7 @@ protected:
virtual void emitEvent(unsigned long event, void* params);
virtual unsigned long int GetControlPointsMTime();
virtual vtkMTimeType GetControlPointsMTime();
virtual vtkIdType GetNumberOfPoints()const;
virtual void DrawPoint(vtkContext2D* painter, vtkIdType index);
......
......@@ -312,7 +312,7 @@ protected:
// Must be reimplemented by subclasses to calculate the points to draw.
// It's subclass responsibility to call ComputePoints() via the callback
virtual void ComputePoints();
virtual unsigned long int GetControlPointsMTime() =0;
virtual vtkMTimeType GetControlPointsMTime() =0;
// Description:
// Returns true if the supplied x, y coordinate is on a control point.
......
......@@ -77,7 +77,7 @@ void vtkPiecewiseControlPointsItem::emitEvent(unsigned long event, void* params)
}
//-----------------------------------------------------------------------------
unsigned long int vtkPiecewiseControlPointsItem::GetControlPointsMTime()
vtkMTimeType vtkPiecewiseControlPointsItem::GetControlPointsMTime()
{
if (this->PiecewiseFunction)
{
......
......@@ -71,7 +71,7 @@ protected:
virtual void emitEvent(unsigned long event, void* params = 0);
virtual unsigned long int GetControlPointsMTime();
virtual vtkMTimeType GetControlPointsMTime();
virtual vtkIdType GetNumberOfPoints()const;
virtual void GetControlPoint(vtkIdType index, double *point)const;
......
......@@ -379,7 +379,7 @@ private:
friend class PIMPL;
vtkWeakPointer<vtkContext2D> CurrentPainter;
unsigned long LayoutUpdatedTime;
vtkMTimeType LayoutUpdatedTime;
// Go through the process of calculating axis ranges, etc...
void UpdateAxes();
......
......@@ -157,7 +157,7 @@ protected:
int ParameterizeByLength;
// Initializing the spline
unsigned long InitializeTime;
vtkMTimeType InitializeTime;
int Initialize();
// Internal variable for managing parametric coordinates
......
......@@ -26,7 +26,7 @@ static vtkAtomicInt64 TotalAtomic64(0);
static const int Target = 1000000;
static int Values32[Target+1];
static int Values64[Target+1];
static unsigned long MTimeValues[Target];
static vtkMTimeType MTimeValues[Target];
static int NumThreads = 5;
......@@ -149,7 +149,7 @@ int TestAtomic(int, char*[])
}
}
unsigned long *from = MTimeValues, *to = MTimeValues + Target;
vtkMTimeType *from = MTimeValues, *to = MTimeValues + Target;
std::sort(from, to);
if (std::unique(from, to) != to)
{
......
......@@ -619,7 +619,7 @@ void SampleProminentValues(
{ // Choose random blocks
vtkNew<vtkMinimalStandardRandomSequence> seq;
// test different blocks each time we're called:
seq->SetSeed(seq->GetMTime() ^ 0xdeadbeef);
seq->SetSeed(static_cast<int>(seq->GetMTime()) ^ 0xdeadbeef);
vtkIdType totalBlockCount =
nt / blockSize +
(nt % blockSize ? 1 : 0);
......
......@@ -340,7 +340,7 @@ struct SetTuplesRangeWorker
template<typename InfoType, typename KeyType>
bool hasValidKey(InfoType info, KeyType key,
unsigned long mtime, double range[2] )
vtkMTimeType mtime, double range[2] )
{
if ( info->Has( key ) )
{
......@@ -355,7 +355,7 @@ bool hasValidKey(InfoType info, KeyType key,
template<typename InfoType, typename KeyType, typename ComponentKeyType>
bool hasValidKey(InfoType info, KeyType key, ComponentKeyType ckey,
unsigned long mtime, double range[2], int comp )
vtkMTimeType mtime, double range[2], int comp )
{
if ( info->Has( key ) )
{
......
......@@ -161,7 +161,7 @@ vtkObject::~vtkObject()
//----------------------------------------------------------------------------
// Return the modification for this object.
unsigned long int vtkObject::GetMTime()
vtkMTimeType vtkObject::GetMTime()
{
return this->MTime.GetMTime();
}
......
......@@ -93,7 +93,7 @@ public:
// Description:
// Return this object's modified time.
virtual unsigned long GetMTime();
virtual vtkMTimeType GetMTime();
// Description:
// Methods invoked by print to print information about the object
......
Supports Markdown
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