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

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
Pipeline #22628 passed with stage
......@@ -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
......
......@@ -103,9 +103,9 @@ void vtkPoints::GetBounds(double bounds[6])
memcpy(bounds, this->Bounds, 6 * sizeof(double));
}
unsigned long int vtkPoints::GetMTime()
vtkMTimeType vtkPoints::GetMTime()
{
unsigned long int doTime = this->Superclass::GetMTime();
vtkMTimeType doTime = this->Superclass::GetMTime();
if ( this->Data->GetMTime() > doTime )
{
doTime = this->Data->GetMTime();
......
......@@ -190,7 +190,7 @@ public:
// Description:
// The modified time of the points.
unsigned long int GetMTime();
vtkMTimeType GetMTime();
protected:
vtkPoints(int dataType = VTK_FLOAT);
......
......@@ -33,10 +33,9 @@ vtkTimeStamp* vtkTimeStamp::New()
void vtkTimeStamp::Modified()
{
#if VTK_SIZEOF_VOID_P == 8
static vtkAtomicInt64 GlobalTimeStamp(0);
static vtkAtomicUInt64 GlobalTimeStamp(0);
#else
static vtkAtomicInt32 GlobalTimeStamp(0);
static vtkAtomicUInt32 GlobalTimeStamp(0);
#endif
this->ModifiedTime = (unsigned long)++GlobalTimeStamp;
this->ModifiedTime = (vtkMTimeType)++GlobalTimeStamp;
}
......@@ -46,7 +46,7 @@ public:
// Description:
// Return this object's Modified time.
unsigned long GetMTime() const {return this->ModifiedTime;};
vtkMTimeType GetMTime() const {return this->ModifiedTime;};
// Description:
// Support comparisons of time stamp objects directly.
......@@ -57,10 +57,10 @@ public:
// Description:
// Allow for typecasting to unsigned long.
operator unsigned long() const {return this->ModifiedTime;};
operator vtkMTimeType() const {return this->ModifiedTime;};
private:
unsigned long ModifiedTime;
vtkMTimeType ModifiedTime;
};
#endif
......
......@@ -229,6 +229,25 @@ typedef signed long vtkTypeInt64;
# error "No native data type can represent a 64-bit integer."
#endif
// Provide this define to facilitate apps that need to support older
// versions that do not have vtkMTimeType
// #ifndef VTK_HAS_MTIME_TYPE
// #if VTK_SIZEOF_LONG == 8
// typedef unsigned long vtkMTimeType;
// #else
// typedef vtkTypeUInt64 vtkMTimeType;
// #endif
// #endif
#define VTK_HAS_MTIME_TYPE
// Select an unsigned 64-bit integer type for use in MTime values.
// If possible, use 'unsigned long' as we have historically.
#if VTK_SIZEOF_LONG == 8
typedef unsigned long vtkMTimeType;
#else
typedef vtkTypeUInt64 vtkMTimeType;
#endif
/* Select a 32-bit floating point type. */
#if VTK_SIZEOF_FLOAT == 4
typedef float vtkTypeFloat32;
......
......@@ -163,12 +163,12 @@ void vtkAnnotation::DeepCopy(vtkDataObject* other)
}
}
unsigned long vtkAnnotation::GetMTime()
vtkMTimeType vtkAnnotation::GetMTime()
{
unsigned long mtime = this->Superclass::GetMTime();
vtkMTimeType mtime = this->Superclass::GetMTime();
if (this->Selection)
{
unsigned long stime = this->Selection->GetMTime();
vtkMTimeType stime = this->Selection->GetMTime();
if (stime > mtime)
{
mtime = stime;
......
......@@ -106,7 +106,7 @@ public:
// Description:
// Get the modified time of this object.
virtual unsigned long GetMTime();
virtual vtkMTimeType GetMTime();
protected:
vtkAnnotation();
......
......@@ -159,15 +159,15 @@ void vtkAnnotationLayers::DeepCopy(vtkDataObject* other)
}
}
unsigned long vtkAnnotationLayers::GetMTime()
vtkMTimeType vtkAnnotationLayers::GetMTime()
{
unsigned long mtime = this->Superclass::GetMTime();
vtkMTimeType mtime = this->Superclass::GetMTime();
for (unsigned int a = 0; a < this->GetNumberOfAnnotations(); ++a)
{
vtkAnnotation* ann = this->GetAnnotation(a);
if (ann)
{
unsigned long atime = ann->GetMTime();
vtkMTimeType atime = ann->GetMTime();
if (atime > mtime)
{
mtime = atime;
......@@ -177,7 +177,7 @@ unsigned long vtkAnnotationLayers::GetMTime()
vtkAnnotation* s = this->GetCurrentAnnotation();
if (s)
{
unsigned long stime = this->GetCurrentAnnotation()->GetMTime();
vtkMTimeType stime = this->GetCurrentAnnotation()->GetMTime();
if (stime > mtime)
{
mtime = stime;
......
......@@ -91,7 +91,7 @@ public:
// Description:
// The modified time for this object.
virtual unsigned long GetMTime();
virtual vtkMTimeType GetMTime();
protected:
vtkAnnotationLayers();
......
......@@ -141,7 +141,7 @@ protected:
vtkBSPIntersections();
~vtkBSPIntersections();
vtkGetMacro(RegionListBuildTime, unsigned long);
vtkGetMacro(RegionListBuildTime, vtkMTimeType);
int BuildRegionList();
......
......@@ -138,14 +138,14 @@ void vtkDataObject::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
// Determine the modified time of this object
unsigned long int vtkDataObject::GetMTime()
vtkMTimeType vtkDataObject::GetMTime()
{
unsigned long result;
vtkMTimeType result;
result = vtkObject::GetMTime();
if ( this->FieldData )
{
unsigned long mtime = this->FieldData->GetMTime();
vtkMTimeType mtime = this->FieldData->GetMTime();
result = ( mtime > result ? mtime : result);
}
......@@ -502,7 +502,7 @@ void vtkDataObject::ReleaseData()
}
//----------------------------------------------------------------------------
unsigned long vtkDataObject::GetUpdateTime()
vtkMTimeType vtkDataObject::GetUpdateTime()
{
return this->UpdateTime.GetMTime();
}
......
......@@ -68,7 +68,7 @@ public:
// Description:
// Data objects are composite objects and need to check each part for MTime.
// The information object also needs to be considered.
unsigned long int GetMTime();
vtkMTimeType GetMTime();
// Description:
// Restore data object to initial state,
......@@ -109,7 +109,7 @@ public:
// Description:
// Used by Threaded ports to determine if they should initiate an
// asynchronous update (still in development).
unsigned long GetUpdateTime();
vtkMTimeType GetUpdateTime();
// Description:
// Return the actual size of the data in kibibytes (1024 bytes). This number
......
......@@ -253,9 +253,9 @@ double vtkDataSet::GetLength()
}
//----------------------------------------------------------------------------
unsigned long int vtkDataSet::GetMTime()
vtkMTimeType vtkDataSet::GetMTime()
{
unsigned long mtime, result;
vtkMTimeType mtime, result;
result = vtkDataObject::GetMTime();
......
......@@ -210,7 +210,7 @@ public:
// Description:
// Datasets are composite objects and need to check each part for MTime
// THIS METHOD IS THREAD SAFE
unsigned long int GetMTime();
vtkMTimeType GetMTime();
// Description:
// Return a pointer to this dataset's cell data.
......
......@@ -596,10 +596,10 @@ unsigned long vtkFieldData::GetActualMemorySize()
}
//----------------------------------------------------------------------------
unsigned long int vtkFieldData::GetMTime()
vtkMTimeType vtkFieldData::GetMTime()
{
unsigned long int mTime = this->MTime;
unsigned long int otherMTime;
vtkMTimeType mTime = this->MTime;
vtkMTimeType otherMTime;
vtkAbstractArray* aa;
for(int i=0; i < this->NumberOfActiveArrays; i++)
......
......@@ -227,7 +227,7 @@ public:
// Description:
// Check object's components for modified times.
unsigned long int GetMTime();
vtkMTimeType GetMTime();
// Description:
// Get a field from a list of ids. Supplied field f should have same
......
......@@ -360,10 +360,10 @@ void vtkGenericAttributeCollection::ShallowCopy(vtkGenericAttributeCollection *o
//----------------------------------------------------------------------------
// Description:
// Collection is composite object and need to check each part for MTime.
unsigned long int vtkGenericAttributeCollection::GetMTime()
vtkMTimeType vtkGenericAttributeCollection::GetMTime()
{
unsigned long result;
unsigned long mtime;
vtkMTimeType result;
vtkMTimeType mtime;
result = vtkObject::GetMTime();
......