vtkFileSeriesHelper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkFileSeriesHelper.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
27 #ifndef vtkFileSeriesHelper_h
28 #define vtkFileSeriesHelper_h
29 
30 #include "vtkObject.h"
31 
32 #include "vtkPVVTKExtensionsCGNSReaderModule.h" // for export macros
33 #include "vtkSmartPointer.h" // for vtkSmartPointer.
34 #include <string> // for std::string
35 #include <utility> // for std::pair
36 #include <vector> // for std::vector
37 
38 class vtkAlgorithm;
40 class vtkInformation;
42 
44 {
45 public:
46  static vtkFileSeriesHelper* New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
50  typedef bool (*FileNameFunctorType)(vtkAlgorithm* reader, const std::string& filename);
51 
53 
56  void RemoveAllFileNames();
57  void AddFileName(const char* fname);
58  void SetFileNames(const std::vector<std::string>& filenames);
60 
64  unsigned int GetNumberOfFiles() const;
65 
77  virtual bool ReadMetaFile(const char* metafilename);
78 
80 
84  void SetController(vtkMultiProcessController*);
85  vtkGetObjectMacro(Controller, vtkMultiProcessController);
87 
89 
98  vtkSetMacro(IgnoreReaderTime, bool);
99  vtkGetMacro(IgnoreReaderTime, bool);
100  vtkBooleanMacro(IgnoreReaderTime, bool);
102 
120  virtual bool UpdateInformation(vtkAlgorithm* reader, const FileNameFunctorType& ftor);
121 
126  vtkGetMacro(UpdateInformationTime, vtkMTimeType);
127 
132  const std::vector<double>& GetTimeSteps() const { return this->AggregatedTimeSteps; }
133 
137  const std::pair<double, double>& GetTimeRange(bool* isvalid = NULL) const
138  {
139  if (isvalid != NULL)
140  {
141  *isvalid = this->AggregatedTimeRangeValid;
142  }
143  return this->AggregatedTimeRange;
144  }
145 
149  void FillTimeInformation(vtkInformation* info) const;
150 
155  vtkGetMacro(PartitionedFiles, bool);
156 
166  std::vector<std::string> GetActiveFiles(vtkInformation* outInfo) const;
167 
168 protected:
170  ~vtkFileSeriesHelper() override;
171 
173  {
174  public:
176  vtkTimeInformation(double time);
178  bool operator==(const vtkTimeInformation& other) const;
179 
180  const std::pair<double, double>& GetTimeRange() const { return this->TimeRange; }
181  const std::vector<double>& GetTimeSteps() const { return this->TimeSteps; }
182  bool GetTimeStepsValid() const { return this->TimeStepsValid; }
183  bool GetTimeRangeValid() const { return this->TimeRangeValid; }
184 
185  void Save(vtkMultiProcessStream& stream) const;
186  void Load(vtkMultiProcessStream& stream);
187 
188  private:
189  std::pair<double, double> TimeRange;
190  std::vector<double> TimeSteps;
191  bool TimeRangeValid;
192  bool TimeStepsValid;
193  };
194 
196  std::vector<std::string> FileNames;
199  std::vector<vtkTimeInformation> Information;
200 
201 private:
202  vtkFileSeriesHelper(const vtkFileSeriesHelper&) = delete;
203  void operator=(const vtkFileSeriesHelper&) = delete;
204 
205  std::vector<std::string> SplitFiles(
206  const std::vector<std::string>& files, int piece, int numPieces) const;
207 
208  void Broadcast(int srcRank);
209 
210  std::vector<double> AggregatedTimeSteps;
211  bool AggregatedTimeRangeValid;
212  std::pair<double, double> AggregatedTimeRange;
213  vtkTimeStamp UpdateInformationTime;
214 };
215 
216 #endif
const std::vector< double > & GetTimeSteps() const
Returns the timesteps determined.
#define VTKPVVTKEXTENSIONSCGNSREADER_EXPORT
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
info
vtkTypeUInt64 vtkMTimeType
time
std::vector< std::string > FileNames
const std::pair< double, double > & GetTimeRange() const
const std::pair< double, double > & GetTimeRange(bool *isvalid=NULL) const
Returns the time range determined.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
Helper class to process file series.
static vtkObject * New()
const std::vector< double > & GetTimeSteps() const
vtkMultiProcessController * Controller
std::vector< vtkTimeInformation > Information