Commit 2cfa252d authored by Rusty Blue's avatar Rusty Blue

ENH: Added another array to the point data containing the time at each step.

parent 7a8702ed
......@@ -20,9 +20,10 @@
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkDoubleArray.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkExtractDataOverTime, "1.1");
vtkCxxRevisionMacro(vtkExtractDataOverTime, "1.2");
vtkStandardNewMacro(vtkExtractDataOverTime);
//----------------------------------------------------------------------------
......@@ -115,7 +116,20 @@ int vtkExtractDataOverTime::ProcessRequest(vtkInformation* request,
input->GetPoints()->GetPoint(this->PointIndex) );
output->GetPointData()->CopyData(input->GetPointData(), this->PointIndex,
this->CurrentTimeIndex);
if (input->GetPointData()->GetArray("Time"))
{
output->GetPointData()->GetArray("TimeData")->SetTuple1(
this->CurrentTimeIndex,
input->GetInformation()->Get(vtkDataObject::DATA_TIME()) );
}
else
{
output->GetPointData()->GetArray("Time")->SetTuple1(
this->CurrentTimeIndex,
input->GetInformation()->Get(vtkDataObject::DATA_TIME()) );
}
// increment the time index
this->CurrentTimeIndex++;
if (this->CurrentTimeIndex == this->NumberOfTimeSteps)
......@@ -154,6 +168,21 @@ int vtkExtractDataOverTime::AllocateOutputData(vtkPointSet *input, vtkPointSet *
// now the point data
output->GetPointData()->CopyAllocate(input->GetPointData(), this->NumberOfTimeSteps);
// and finally add an array to hold the time at each step
vtkDoubleArray *timeArray = vtkDoubleArray::New();
timeArray->SetNumberOfComponents(1);
timeArray->SetNumberOfTuples(this->NumberOfTimeSteps);
if (input->GetPointData()->GetArray("Time"))
{
timeArray->SetName("TimeSteps");
}
else
{
timeArray->SetName("Time");
}
output->GetPointData()->AddArray(timeArray);
timeArray->Delete();
return 1;
}
......
......@@ -19,7 +19,8 @@
// and creates an output of the same type as the input but with Points
// containing "number of time steps" points; the point and PointData
// corresponding to the PointIndex are extracted at each time step and added to
// the output.
// the output. A PointData array is added called "Time" (or "TimeData" if
// there is already an array called "Time"), which is the time at each index.
#ifndef __vtkExtractDataOverTime_h
#define __vtkExtractDataOverTime_h
......
Markdown is supported
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