Skip to content
Snippets Groups Projects
Commit 743efb2d authored by Spiros Tsalikis's avatar Spiros Tsalikis
Browse files

vtkPeriodicDataArray: Support GetVoidPointer

This is needed by vtkWriter subclasses.
parent c84dc8aa
No related branches found
No related tags found
No related merge requests found
......@@ -301,6 +301,12 @@ public:
vtkGetMacro(Normalize, bool);
///@}
/**
* Use of this method is discouraged, it creates a memory copy of the data into
* a contiguous AoS-ordered buffer internally.
*/
void* GetVoidPointer(vtkIdType valueIdx) override;
protected:
vtkPeriodicDataArray();
~vtkPeriodicDataArray() override;
......@@ -361,10 +367,11 @@ private:
friend class vtkGenericDataArray<vtkPeriodicDataArray<Scalar>, Scalar>;
Scalar* TempScalarArray; // Temporary array used by GetTypedTuple methods
double* TempDoubleArray; // Temporary array used by GetTuple vethods
vtkIdType TempTupleIdx; // Location of currently stored Temp Tuple to use as cache
vtkAOSDataArrayTemplate<Scalar>* Data; // Original data
Scalar* TempScalarArray; // Temporary array used by GetTypedTuple methods
double* TempDoubleArray; // Temporary array used by GetTuple vethods
vtkIdType TempTupleIdx; // Location of currently stored Temp Tuple to use as cache
vtkAOSDataArrayTemplate<Scalar>* Data; // Original data
vtkAOSDataArrayTemplate<Scalar>* Cache; // Only used by void pointer
bool InvalidRange = true;
double PeriodicRange[6]; // Transformed periodic range
......
......@@ -683,6 +683,18 @@ void vtkPeriodicDataArray<Scalar>::InvalidateRange()
this->InvalidRange = true;
}
//------------------------------------------------------------------------------
template <class Scalar>
void* vtkPeriodicDataArray<Scalar>::GetVoidPointer(vtkIdType valueIdx)
{
if (!this->Cache)
{
this->Cache = vtkAOSDataArrayTemplate<Scalar>::New();
this->Cache->DeepCopy(this);
}
return this->Cache->GetVoidPointer(valueIdx);
}
//------------------------------------------------------------------------------
template <class Scalar>
vtkPeriodicDataArray<Scalar>::vtkPeriodicDataArray()
......@@ -692,6 +704,7 @@ vtkPeriodicDataArray<Scalar>::vtkPeriodicDataArray()
this->TempDoubleArray = nullptr;
this->TempTupleIdx = -1;
this->Data = nullptr;
this->Cache = nullptr;
this->MaxId = -1;
this->Size = 0;
......@@ -706,5 +719,10 @@ template <class Scalar>
vtkPeriodicDataArray<Scalar>::~vtkPeriodicDataArray()
{
this->Initialize();
if (this->Cache)
{
this->Cache->Delete();
this->Cache = nullptr;
}
}
VTK_ABI_NAMESPACE_END
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment