VTK  9.3.0
vtkFileSeriesHelper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3 // SPDX-License-Identifier: BSD-3-Clause
16 #ifndef vtkFileSeriesHelper_h
17 #define vtkFileSeriesHelper_h
18 
19 #include "vtkObject.h"
20 
21 #include "vtkIOCGNSReaderModule.h" // for export macros
22 #include "vtkSmartPointer.h" // for vtkSmartPointer.
23 #include <string> // for std::string
24 #include <utility> // for std::pair
25 #include <vector> // for std::vector
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkAlgorithm;
30 class vtkInformation;
32 
33 class VTKIOCGNSREADER_EXPORT vtkFileSeriesHelper : public vtkObject
34 {
35 public:
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
40  typedef bool (*FileNameFunctorType)(vtkAlgorithm* reader, const std::string& filename);
41 
43 
47  void AddFileName(const char* fname);
48  void SetFileNames(const std::vector<std::string>& filenames);
50 
54  unsigned int GetNumberOfFiles() const;
55 
67  virtual bool ReadMetaFile(const char* metafilename);
68 
70 
75  vtkGetObjectMacro(Controller, vtkMultiProcessController);
77 
79 
88  vtkSetMacro(IgnoreReaderTime, bool);
89  vtkGetMacro(IgnoreReaderTime, bool);
90  vtkBooleanMacro(IgnoreReaderTime, bool);
92 
110  virtual bool UpdateInformation(vtkAlgorithm* reader, const FileNameFunctorType& ftor);
111 
116  vtkGetMacro(UpdateInformationTime, vtkMTimeType);
117 
122  const std::vector<double>& GetTimeSteps() const { return this->AggregatedTimeSteps; }
123 
127  const std::pair<double, double>& GetTimeRange(bool* isvalid = nullptr) const
128  {
129  if (isvalid != nullptr)
130  {
131  *isvalid = this->AggregatedTimeRangeValid;
132  }
133  return this->AggregatedTimeRange;
134  }
135 
140 
145  vtkGetMacro(PartitionedFiles, bool);
146 
156  std::vector<std::string> GetActiveFiles(vtkInformation* outInfo) const;
157 
158 protected:
161 
163  {
164  public:
168  bool operator==(const vtkTimeInformation& other) const;
169 
170  const std::pair<double, double>& GetTimeRange() const { return this->TimeRange; }
171  const std::vector<double>& GetTimeSteps() const { return this->TimeSteps; }
172  bool GetTimeStepsValid() const { return this->TimeStepsValid; }
173  bool GetTimeRangeValid() const { return this->TimeRangeValid; }
174 
175  void Save(vtkMultiProcessStream& stream) const;
177 
178  private:
179  std::pair<double, double> TimeRange;
180  std::vector<double> TimeSteps;
181  bool TimeRangeValid;
182  bool TimeStepsValid;
183  };
184 
186  std::vector<std::string> FileNames;
189  std::vector<vtkTimeInformation> Information;
190 
191 private:
192  vtkFileSeriesHelper(const vtkFileSeriesHelper&) = delete;
193  void operator=(const vtkFileSeriesHelper&) = delete;
194 
195  std::vector<std::string> SplitFiles(
196  const std::vector<std::string>& files, int piece, int numPieces) const;
197 
198  void Broadcast(int srcRank);
199 
200  std::vector<double> AggregatedTimeSteps;
201  bool AggregatedTimeRangeValid;
202  std::pair<double, double> AggregatedTimeRange;
203  vtkTimeStamp UpdateInformationTime;
204 };
205 
206 VTK_ABI_NAMESPACE_END
207 #endif
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:61
void Load(vtkMultiProcessStream &stream)
const std::pair< double, double > & GetTimeRange() const
const std::vector< double > & GetTimeSteps() const
bool operator==(const vtkTimeInformation &other) const
vtkTimeInformation(vtkInformation *outInfo)
void Save(vtkMultiProcessStream &stream) const
Helper class to process file series.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetController(vtkMultiProcessController *)
Get/Set the parallel controller.
virtual bool ReadMetaFile(const char *metafilename)
Setup file names in the series using a meta-file.
const std::pair< double, double > & GetTimeRange(bool *isvalid=nullptr) const
Returns the time range determined.
void FillTimeInformation(vtkInformation *info) const
Fills up info with information about timesteps and timerange.
void AddFileName(const char *fname)
Specify the set of files that comprise the series.
static vtkFileSeriesHelper * New()
std::vector< std::string > FileNames
void SetFileNames(const std::vector< std::string > &filenames)
Specify the set of files that comprise the series.
std::vector< std::string > GetActiveFiles(vtkInformation *outInfo) const
Returns the list of files to read on current rank to satisfy the request.
virtual bool UpdateInformation(vtkAlgorithm *reader, const FileNameFunctorType &ftor)
vtkFileSeriesHelper needs to collect information about the nature of the fileseries.
const std::vector< double > & GetTimeSteps() const
Returns the timesteps determined.
~vtkFileSeriesHelper() override
vtkMultiProcessController * Controller
void RemoveAllFileNames()
Specify the set of files that comprise the series.
unsigned int GetNumberOfFiles() const
Get the number of files in the series.
std::vector< vtkTimeInformation > Information
a simple class to control print indentation
Definition: vtkIndent.h:38
Store vtkAlgorithm input/output information.
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition: vtkObject.h:61
record modification and/or execution time
Definition: vtkTimeStamp.h:34
@ info
Definition: vtkX3D.h:376
@ time
Definition: vtkX3D.h:497
@ string
Definition: vtkX3D.h:490
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270