Hi,

I dug deeper into the class FileSeriesReader and found out that despite
what I thought and posted earlier everything is already there to be able
to implement a toggle to use/ignore time step values contained in a file
series. I'd like to propose the attached patch. It can be tested with
the attached minimal time series reader plugin, sample input files are
contained. The plugin's server manager XML has been extended to expose
the IgnoreTimeStepValues checkbox provided by the patched class
FileSeriesReader.

I don't see the patch interfering with existing readers relying on class
FileSeriesReader.
Any thoughts?

Thanks in advance for feedback,
Karl

Attachment: FooReader.tar.gz
Description: GNU Zip compressed data

diff --git a/Servers/Filters/vtkFileSeriesReader.cxx 
b/Servers/Filters/vtkFileSeriesReader.cxx
index 96d86fb..b13963e 100644
--- a/Servers/Filters/vtkFileSeriesReader.cxx
+++ b/Servers/Filters/vtkFileSeriesReader.cxx
@@ -61,10 +61,10 @@ class vtkFileSeriesReaderTimeRanges
 public:
   void Reset();
   void AddTimeRange(int index, vtkInformation *srcInfo);
-  int GetAggregateTimeInfo(vtkInformation *outInfo);
+  int GetAggregateTimeInfo(int ignoreTimeStepValues, vtkInformation *outInfo);
   int GetInputTimeInfo(int index, vtkInformation *outInfo);
   int GetIndexForTime(double time);
-  vtkstd::set<int> ChooseInputs(vtkInformation *outInfo);
+  vtkstd::set<int> ChooseInputs(int ignoreTimeStepValues, vtkInformation 
*outInfo);
   vtkstd::vector<double> GetTimesForInput(int inputId, vtkInformation 
*outInfo);
 private:
   static vtkInformationIntegerKey *INDEX();
@@ -126,7 +126,9 @@ void vtkFileSeriesReaderTimeRanges::AddTimeRange(int index,
 }
 
 //-----------------------------------------------------------------------------
-int vtkFileSeriesReaderTimeRanges::GetAggregateTimeInfo(vtkInformation 
*outInfo)
+int vtkFileSeriesReaderTimeRanges::GetAggregateTimeInfo(
+                                                 int ignoreTimeStepValues,
+                                                 vtkInformation *outInfo)
 {
   if (this->RangeMap.empty())
     {
@@ -134,51 +136,71 @@ int 
vtkFileSeriesReaderTimeRanges::GetAggregateTimeInfo(vtkInformation *outInfo)
     return 0;
     }
 
-  double timeRange[2];
-  timeRange[0] = this->RangeMap.begin()->second
-                       
->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE())[0];
-  timeRange[1] = (--this->RangeMap.end())->second
-                       
->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE())[1];
-
-  // Special case: if the time range is a single value, supress it.  This is
-  // most likely from a data set that is a single file with no time anyway.
-  // Even if it is not, how much value added is there for a single time value?
-  if (timeRange[0] >= timeRange[1])
+  if (ignoreTimeStepValues > 0)
     {
-    outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE());
-    outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-    return 1;
-    }
+      double timeRange[2];
+      timeRange[0] = 0;
+      timeRange[1] = this->InputLookup.size() - 1;
+      outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 
2);
 
-  outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2);
+      vtkstd::vector<double> timeSteps;
 
-  vtkstd::vector<double> timeSteps;
+      for (int i = 0; i < this->InputLookup.size(); i++)
+        {
+        timeSteps.push_back(i);
+        }
 
-  RangeMapType::iterator itr = this->RangeMap.begin();
-  while (itr != this->RangeMap.end())
+      outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
+                   &timeSteps[0], timeSteps.size());
+    }
+  else
     {
-    // First, get all the time steps for this input.
-    double *localTimeSteps
-      = itr->second->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-    int numLocalSteps
-      = itr->second->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-    double localEndTime = vtkTypeTraits<double>::Max();
-    // Second, check where the time range for the next section begins.
-    itr++;
-    if (itr != this->RangeMap.end())
+    double timeRange[2];
+    timeRange[0] = this->RangeMap.begin()->second
+      ->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE())[0];
+    timeRange[1] = (--this->RangeMap.end())->second
+      ->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE())[1];
+
+    // Special case: if the time range is a single value, suppress it.  This is
+    // most likely from a data set that is a single file with no time anyway.
+    // Even if it is not, how much value added is there for a single time 
value?
+    if (timeRange[0] >= timeRange[1])
       {
-      localEndTime
-        = itr->second->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE())[0];
+      outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE());
+      outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+      return 1;
       }
-    // Third, copy the appropriate time steps to the aggregate time steps.
-    for (int i = 0; (i<numLocalSteps) && (localTimeSteps[i]<localEndTime); i++)
+
+    outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2);
+
+    vtkstd::vector<double> timeSteps;
+
+    RangeMapType::iterator itr = this->RangeMap.begin();
+    while (itr != this->RangeMap.end())
       {
-      timeSteps.push_back(localTimeSteps[i]);
+      // First, get all the time steps for this input.
+      double *localTimeSteps
+        = itr->second->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+      int numLocalSteps
+        = itr->second->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+      double localEndTime = vtkTypeTraits<double>::Max();
+      // Second, check where the time range for the next section begins.
+      itr++;
+      if (itr != this->RangeMap.end())
+        {
+        localEndTime
+          = 
itr->second->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE())[0];
+        }
+      // Third, copy the appropriate time steps to the aggregate time steps.
+      for (int i = 0; (i<numLocalSteps) && (localTimeSteps[i]<localEndTime); 
i++)
+        {
+        timeSteps.push_back(localTimeSteps[i]);
+        }
       }
-    }
 
-  outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
-               &timeSteps[0], timeSteps.size());
+    outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
+                 &timeSteps[0], timeSteps.size());
+    }
   return 1;
 }
 
@@ -228,21 +250,33 @@ int vtkFileSeriesReaderTimeRanges::GetIndexForTime(double 
time)
 
 //-----------------------------------------------------------------------------
 vtkstd::set<int> vtkFileSeriesReaderTimeRanges::ChooseInputs(
+                                                        int 
ignoreTimeStepValues,
                                                         vtkInformation 
*outInfo)
 {
   vtkstd::set<int> indices;
   if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()))
     {
-    // get the update times
-    int numUpTimes = 
-      outInfo->Length(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
-    double *upTimes =
-      outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
-
-    for (int i = 0; i < numUpTimes; i++)
+    if (ignoreTimeStepValues > 0)
+      {
+      for (int i = 0; i < this->InputLookup.size(); i++)
+        {
+        indices.insert(i);
+        }
+      }
+    else
       {
-      indices.insert(this->GetIndexForTime(upTimes[i]));
+      // get the update times
+      int numUpTimes = 
+        outInfo->Length(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
+      double *upTimes =
+        outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
+
+      for (int i = 0; i < numUpTimes; i++)
+        {
+        indices.insert(this->GetIndexForTime(upTimes[i]));
+        }
       }
+
     }
   else
     {
@@ -341,6 +375,7 @@ vtkFileSeriesReader::vtkFileSeriesReader()
   this->MetaFileName = NULL;
   this->UseMetaFile = 0;
   this->CurrentFileName = 0;
+  this->IgnoreTimeStepValues = 0;
 
   this->LastRequestInformationIndex = -1;
 }
@@ -494,7 +529,7 @@ int vtkFileSeriesReader::ProcessRequest(vtkInformation* 
request,
     int retVal = this->Reader->ProcessRequest(request, 
                                               inputVector,
                                               outputVector);
-    // Aditional processing requried by us.
+    // Additional processing required by us.
     if 
(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))
       {
       this->RequestUpdateExtent(request, inputVector, outputVector);
@@ -557,7 +592,7 @@ int vtkFileSeriesReader::RequestInformation(
 
   // Now that we have collected all of the time information, set the aggregate
   // time steps in the output.
-  this->Internal->TimeRanges->GetAggregateTimeInfo(outInfo);
+  this->Internal->TimeRanges->GetAggregateTimeInfo(this->IgnoreTimeStepValues, 
outInfo);
   return 1;
 }
 
@@ -568,8 +603,9 @@ int vtkFileSeriesReader::RequestUpdateExtent(
                                  vtkInformationVector* outputVector)
 {
   vtkInformation *outInfo = outputVector->GetInformationObject(0);
-  vtkstd::set<int> inputs = this->Internal->TimeRanges->ChooseInputs(outInfo);
-  if (inputs.size() > 1)
+  vtkstd::set<int> inputs = 
+    this->Internal->TimeRanges->ChooseInputs(this->IgnoreTimeStepValues, 
outInfo);
+  if (this->IgnoreTimeStepValues == 0 && inputs.size() > 1)
     {
     vtkErrorMacro("vtkTemporalDataSet not fully supported.");
     // To support readers that give vtkTemporalDataSet, we would have to 
iterate
@@ -620,7 +656,7 @@ int vtkFileSeriesReader::RequestData(vtkInformation 
*request,
   int retVal = this->Reader->ProcessRequest(request, inputVector, 
outputVector);
 
   // Now restore the information.
-  this->Internal->TimeRanges->GetAggregateTimeInfo(outInfo);
+  this->Internal->TimeRanges->GetAggregateTimeInfo(this->IgnoreTimeStepValues, 
outInfo);
 
   return retVal;
 }
@@ -767,4 +803,5 @@ void vtkFileSeriesReader::PrintSelf(ostream& os, vtkIndent 
indent)
 
   os << indent << "MetaFileName: " << this->MetaFileName << endl;
   os << indent << "UseMetaFile: " << this->UseMetaFile << endl;
+  os << indent << "IgnoreTimeStepValues: " << this->IgnoreTimeStepValues << 
endl;
 }
diff --git a/Servers/Filters/vtkFileSeriesReader.h 
b/Servers/Filters/vtkFileSeriesReader.h
index 93344f5..d0179a2 100644
--- a/Servers/Filters/vtkFileSeriesReader.h
+++ b/Servers/Filters/vtkFileSeriesReader.h
@@ -124,6 +124,13 @@ public:
   vtkSetStringMacro(FileNameMethod);
   vtkGetStringMacro(FileNameMethod);
 
+  // Description:
+  // If true, then treat file series like it does not contain any time step 
+  // values. False by default.
+  vtkGetMacro(IgnoreTimeStepValues, int);
+  vtkSetMacro(IgnoreTimeStepValues, int);
+  vtkBooleanMacro(IgnoreTimeStepValues, int);
+
 protected:
   vtkFileSeriesReader();
   ~vtkFileSeriesReader();
@@ -174,6 +181,8 @@ protected:
   // Re-reads information from the metadata file, if necessary.
   virtual void UpdateMetaData();
 
+  int IgnoreTimeStepValues;
+
 private:
   vtkFileSeriesReader(const vtkFileSeriesReader&); // Not implemented.
   void operator=(const vtkFileSeriesReader&); // Not implemented.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview
            • ... Sven Buijssen
              • ... Utkarsh Ayachit
          • ... Moreland, Kenneth
            • ... Karl König
              • ... Moreland, Kenneth
            • ... Karl König
              • ... Karl König
              • ... Moreland, Kenneth
              • ... Stephane PLOIX
              • ... Karl König
              • ... Karl König
              • ... Moreland, Kenneth
              • ... Karl König
              • ... Moreland, Kenneth
              • ... Karl König
              • ... Moreland, Kenneth
      • [... Maxwell, Thomas P. (GSFC-606.2)[SCIENCE APPLICATIONS INTL CORP]
        • ... Utkarsh Ayachit
  • Re: [Parav... Karl König

Reply via email to